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.
1. Move `project` before `check_ipo_supported`, so that the check knows
the languages to check.
2. Better error message if LTO is not supported.
3. Use a separate flag for LTO
4. Enable LTO for the nightly build.
5. Move git commands to a separate file.