Warning, /acts/cmake/ActsOptionHelpers.cmake is written in an unsupported language. File is not indexed.
0001 # Provide helper macros to handle option interdependencies.
0002 #
0003 # Ensure an option is set if a condition is met. Can be used to encode
0004 # dependencies between different options, e.g. if OptionA is on, OptionB has
0005 # to be on as well.
0006 #
0007 # set_option_if(OptionB OptionA)
0008 #
0009 # The macro can take arbitrary conditions as the second parameter, e.g.
0010 #
0011 # set_option_if(OptionB OptionA AND ConditionB OR ConditionC)
0012 #
0013
0014 macro(set_option_if option)
0015 if(${ARGN})
0016 if(NOT ${option})
0017 string(JOIN " " _acts_option_reason ${ARGN})
0018 message(
0019 STATUS
0020 "Option '${option}' auto-enabled by: ${_acts_option_reason}"
0021 )
0022 set_property(
0023 DIRECTORY
0024 APPEND
0025 PROPERTY _acts_auto_enabled_options "${option}"
0026 )
0027 set_property(
0028 DIRECTORY
0029 PROPERTY _acts_option_reason_${option} "${_acts_option_reason}"
0030 )
0031 unset(_acts_option_reason)
0032 endif()
0033 # create a regular (directory-scope) variable that should take precedence
0034 # over a cache entry of the same name. that means that automatically
0035 # activated options are not stored in the cache.
0036 set(${option} ON)
0037 endif()
0038 endmacro()
0039
0040 # Summarize only options changed by set_option_if in this directory. Tracking
0041 # these explicitly keeps internal cache entries out, including on reconfigure.
0042 function(acts_print_auto_enabled_options)
0043 get_property(_options DIRECTORY PROPERTY _acts_auto_enabled_options)
0044 if(NOT _options)
0045 return()
0046 endif()
0047 list(REMOVE_DUPLICATES _options)
0048 list(SORT _options)
0049
0050 message(STATUS "Automatically enabled options (effective values):")
0051 foreach(_option IN LISTS _options)
0052 get_property(_reason DIRECTORY PROPERTY _acts_option_reason_${_option})
0053 message(STATUS " ${_option} = ${${_option}} (condition: ${_reason})")
0054 endforeach()
0055 message(STATUS "Dependency overrides do not change cached option values.")
0056 endfunction()