Is there anyway to set the options of a subdirectory?
So I have a project that depends on a subproject, the subproject has an option: OPTION(WITH_FUNCTION_X "enable X functionality" ON)
And in my parent project I want to include the subproject, but without functionality X.
thanks!
CMake's option
command more or less adds a boolean variable to the cache.
If you want to override the default value of an option, simply add a variable of the same name to the cache yourself before pulling in the subproject:
set(WITH_FUNCTION_X OFF CACHE BOOL "enable X functionality") add_subdirectory(subproject)
Note that the set
command does nothing if there is already a value of that name in the cache. If you want to overwrite any existing value, add the FORCE
option to that command.
Sample with FORCE
set(WITH_FUNCTION_X OFF CACHE BOOL "enable X functionality" FORCE) add_subdirectory(subproject)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With