-macro(internal_set VARIABLE REASON)
- if (NOT DEFINED ${VARIABLE})
- set(${VARIABLE} ${ARGN})
- set(${VARIABLE}_REASON ${REASON} CACHE STRING "reason")
+macro(set_feature_switch_default VARIABLE REASON ENABLE)
+ if ((NOT DEFINED ${VARIABLE}) # variable not in cache (first run)
+ OR ((DEFINED ${VARIABLE}_ORIGINAL) AND # variable in cache -> check for change
+ ((${VARIABLE}_ORIGINAL AND ${VARIABLE}) OR # poor man's boolean equal
+ (NOT ${VARIABLE}_ORIGINAL AND NOT ${VARIABLE}))))
+ set(${VARIABLE}_REASON ${REASON})
+ set(${VARIABLE} ${ENABLE} CACHE BOOL "feature switch")
else()
- set(${VARIABLE}_REASON "User defined" CACHE STRING "reason")
+ set(${VARIABLE}_REASON "User defined")
endif()
+ set(${VARIABLE}_ORIGINAL ${ENABLE} CACHE INTERNAL "original value set by build script")
endmacro()
macro(set_with_reason VARIABLE REASON ENABLE)
if (DEFINED ${VARIABLE}_REASON AND NOT ${VARIABLE}_REASON STREQUAL "User defined")
- set(${VARIABLE} ${ENABLE})
+ set(${VARIABLE} ${ENABLE} CACHE BOOL "feature switch" FORCE)
+ set(${VARIABLE}_ORIGINAL ${ENABLE} CACHE INTERNAL "original value set by build script")
set(${VARIABLE}_REASON ${REASON})
string(REPLACE "/" "_" VARIABLE_NAMES ${VARIABLE})
set(${VARIABLE_NAMES}_LIBS ${ARGN})
else()
- message("Do not change user defined settings for ${VARIABLE}")
+ message(WARNING "Do not change user defined settings for ${VARIABLE}")
endif()
endmacro()
macro(add_feature FEATURE REASON ENABLE)
list(APPEND ALL_FEATURES ${FEATURE})
- internal_set(${FEATURE} ${REASON} ${ENABLE})
+ set_feature_switch_default(${FEATURE} ${REASON} ${ENABLE})
endmacro()
macro(cfg_feature FEATURE REASON ENABLE)
set(${FEATURE} ${ENABLE})
- set(${FEATURE}_REASON ${REASON})
+ if (${FEATURE}_REASON STREQUAL "User defined")
+ set(${FEATURE}_REASON "${REASON} *user setting overridden*")
+ else()
+ set(${FEATURE}_REASON ${REASON})
+ endif()
endmacro()
macro(add_module MODULE_PATH REASON ENABLE)
list(APPEND ALL_MODULES ${MODULE_PATH})
- internal_set(${MODULE_PATH} ${REASON} ${ENABLE})
+ set_feature_switch_default(${MODULE_PATH} ${REASON} ${ENABLE})
endmacro()
# plugins are always linked static
macro(add_plugin PLUGIN_PATH REASON ENABLE)
list(APPEND ALL_PLUGINS ${PLUGIN_PATH})
- internal_set(${PLUGIN_PATH} ${REASON} ${ENABLE})
+ set_feature_switch_default(${PLUGIN_PATH} ${REASON} ${ENABLE})
endmacro()
# module plugins are always linked static
macro(add_module_plugin PLUGIN_PATH REASON ENABLE)
list(APPEND ALL_MODULE_PLUGINS ${PLUGIN_PATH})
- internal_set(${PLUGIN_PATH} ${REASON} ${ENABLE})
+ set_feature_switch_default(${PLUGIN_PATH} ${REASON} ${ENABLE})
endmacro()
macro(module_add_library MODULE_NAME )