VS: WholeProgramOptimization project-level setting
Visual Studio has 3 settings in its vcxproj file for WholeProgramOptimization:
- compiler-level (ItemDefinitionGroup/ClCompile/WholeProgramOptimization)
- linker-level (ItemDefinitionGroup/Link/LinkTimeCodeGeneration)
- "convenience" setting at project level (PropertyGroup/WholeProgramOptimization) that sets previous two options at once.
In CMake file I set compiler and linker level settings:
# Whole program optimization
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /GL")
# Use link-time code generation
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG")
and they work just fine.
But project level setting is not set. I found explanation for this issue at StackOverflow for CMake 3.10: https://stackoverflow.com/questions/48431918/wholeprogramoptimization-in-cmake but it is still the case for CMake 3.25.3.
So this issue is not show-stopper but just confusing and takes time for investigation. It would be handy if CMake would set the third option if the first two are set. I understand that this issue is not critical so may be low priority, but on the other hand the change seems easy.
Edited by Valentyn