cmake set subdirectory options

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)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)