Overriding dynamic_project_options on CMake command line does not work
JesusKrists opened this issue · comments
Trying to run a command such as:
cmake -S . -B ./build -G "Ninja Multi-Config" -DCMAKE_BUILD_TYPE:STRING=Debug -DENABLE_DEVELOPER_MODE:BOOL=OFF -DOPT_ENABLE_COVERAGE:BOOL=ON -DOPT_ENABLE_INCLUDE_WHAT_YOU_USE:BOOL=OFF
Results in the options not being overriden.
The CMakeCache.txt contains
//Analyze and report on coverage
OPT_ENABLE_COVERAGE:INTERNAL=ON
//Enable include-what-you-use analysis during compilation
OPT_ENABLE_INCLUDE_WHAT_YOU_USE:INTERNAL=OFF
Which seems correct, but my compile_commands.json does not contain any coverage flags and digging further into this I found that when DynamicProjectOptions.cmake:130 is parsed
cmake_dependent_option(
OPT_${option_name}
"${option_description}"
${option_developer_default}
ENABLE_DEVELOPER_MODE
${option_user_default})
it overrides the command line option by the developer default or user default. In ENABLE_COVERAGE case it disables coverage in both configurations no matter what I pass to the command line
So this if here
if(OPT_${option_name})
set(${option_name}_VALUE ${option_name})
else()
unset(${option_name}_VALUE)
endif()
always unsets the value
This is related to dynamic_project_options
, which is maintained by @lefticus
Fixed in #209