mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2024-12-02 02:05:41 +00:00
53 lines
1.7 KiB
CMake
53 lines
1.7 KiB
CMake
|
function(set_switchable)
|
||
|
set(options "")
|
||
|
set(one_value_args PREFIX INFIX OUT_INFIX NAME)
|
||
|
set(multi_value_args ONVALUE OFFVALUE)
|
||
|
|
||
|
cmake_parse_arguments(SS "${options}" "${one_value_args}" "${multi_value_args}" ${ARGN})
|
||
|
|
||
|
if (NOT SS_PREFIX)
|
||
|
message(FATAL_ERROR "No PREFIX given")
|
||
|
endif()
|
||
|
if (NOT SS_INFIX)
|
||
|
set(SS_INFIX "ENABLED")
|
||
|
endif()
|
||
|
if (NOT SS_OUT_INFIX)
|
||
|
set(SS_OUT_INFIX "CURR")
|
||
|
endif()
|
||
|
if (NOT SS_NAME)
|
||
|
message(FATAL_ERROR "No NAME given")
|
||
|
endif()
|
||
|
|
||
|
list(FIND SS_ONVALUE CACHE on_is_cachevar)
|
||
|
list(FIND SS_ONVALUE PARENT_SCOPE on_is_parentscope)
|
||
|
list(FIND SS_OFFVALUE CACHE off_is_cachevar)
|
||
|
list(FIND SS_OFFVALUE PARENT_SCOPE off_is_parentscope)
|
||
|
|
||
|
set(on_parentscope)
|
||
|
if (${on_is_cachevar} LESS 0 AND ${on_is_parentscope} LESS 1)
|
||
|
list(APPEND on_parentscope "PARENT_SCOPE")
|
||
|
endif()
|
||
|
set(off_parentscope)
|
||
|
if (${off_is_cachevar} LESS 0 AND ${off_is_parentscope} LESS 1)
|
||
|
list(APPEND off_parentscope "PARENT_SCOPE")
|
||
|
endif()
|
||
|
|
||
|
#Set some alisases to make the following code less yelling-at-me
|
||
|
set(prefix "${SS_PREFIX}")
|
||
|
set(infix "${SS_INFIX}")
|
||
|
set(out_infix "${SS_OUT_INFIX}")
|
||
|
set(suffix "${SS_NAME}")
|
||
|
|
||
|
set(${prefix}_${infix}_${suffix} ${SS_ONVALUE} ${on_parentscope})
|
||
|
set(${prefix}_${suffix} ${SS_OFFVALUE} ${off_parentscope})
|
||
|
|
||
|
#message(STATUS "${prefix}_${suffix} set to \"${${prefix}_${suffix}}\"")
|
||
|
#message(STATUS "${prefix}_${infix}_${suffix} set to \"${${prefix}_${infix}_${suffix}}\"")
|
||
|
|
||
|
if (${prefix}_${infix}_MODE)
|
||
|
set(${prefix}_${out_infix}_${suffix} "${${prefix}_${infix}_${suffix}}" PARENT_SCOPE)
|
||
|
else()
|
||
|
set(${prefix}_${out_infix}_${suffix} "${${prefix}_${suffix}}" PARENT_SCOPE)
|
||
|
endif()
|
||
|
endfunction()
|