1. Make the vcpkg hack minimal by only defining the options it needs
before `include(Platforms)`.
Every dependent option needed by vcpkg has to be recalculated
after `include(Platforms)`. This brings the count of such options
down to 1 (`PACKET_ENCRYPTION`).
2. `include(Platforms)` before the rest of the options.
3. Group related options together into sections and add comments.
4. Fix `--gc-sections` for C files. Also adds `-Wl,--as-needed`.
Note: `PIE` can now be `ON` even if `BUILD_TESTING` is `OFF`.
1. Platform and toolchain files are now all under `platforms/`, with a
single `CMake/platforms/${platform}.cmake` per platform.
2. Custom functions/macros are under `functions/`.
3. Finder modules are in `/finders`.
Generator expressions are the only way to distinguish between build
types in multi-configuration builds (Visual Studio).
This adds generator expressions for some of build type dependent
values as a starting point.
See a more detailed explanation at:
https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html#build-specification-with-generator-expressions
Notably:
> Some buildsystems generated by cmake(1) have a predetermined build-configuration set in the CMAKE_BUILD_TYPE variable. The buildsystem for the IDEs such as Visual Studio and Xcode are generated independent of the build-configuration, and the actual build configuration is not known until build-time. Therefore, code such as
>
> string(TOLOWER ${CMAKE_BUILD_TYPE} _type)
> if (_type STREQUAL debug)
> target_compile_definitions(exe1 PRIVATE DEBUG_BUILD)
> endif()
>
> may appear to work for Makefile Generators and Ninja generators, but is not portable to IDE generators.