Do not use CMakeParseArguments for wrappers
This commit is contained in:
parent
fe28e29c0d
commit
fa53033962
@ -47,70 +47,36 @@ def autogenerated_notice():
|
|||||||
|
|
||||||
def gen_cmake_options_wrappers():
|
def gen_cmake_options_wrappers():
|
||||||
s = """\n# Options handling utilities
|
s = """\n# Options handling utilities
|
||||||
include(CMakeParseArguments)
|
|
||||||
include(CMakeDependentOption)
|
include(CMakeDependentOption)
|
||||||
# Macro for printing an option in a consistent manner
|
# Macro for printing an option in a consistent manner
|
||||||
# Written by Lori A. Burns (@loriab) and Ryan M. Richard (@ryanmrichard)
|
# Written by Lori A. Burns (@loriab) and Ryan M. Richard (@ryanmrichard)
|
||||||
# Syntax: print_option(NAME <option to print> DEFAULT <was specified>)
|
# Syntax: print_option(<option to print> <was specified>)
|
||||||
macro(print_option)
|
macro(print_option variable default)
|
||||||
set(options)
|
if(NOT DEFINED ${variable} OR "${${variable}}" STREQUAL "")
|
||||||
set(oneValueArgs NAME DEFAULT)
|
message(STATUS "Setting (unspecified) option ${variable}: ${default}")
|
||||||
set(multiValueArgs)
|
|
||||||
cmake_parse_arguments(print_option
|
|
||||||
"${options}"
|
|
||||||
"${oneValueArgs}"
|
|
||||||
"${multiValueArgs}"
|
|
||||||
${ARGN}
|
|
||||||
)
|
|
||||||
if(NOT DEFINED ${print_option_NAME} OR "${${print_option_NAME}}" STREQUAL "")
|
|
||||||
message(STATUS "Setting (unspecified) option ${print_option_NAME}: ${print_option_DEFAULT}")
|
|
||||||
else()
|
else()
|
||||||
message(STATUS "Setting option ${print_option_NAME}: ${print_option_DEFAULT}")
|
message(STATUS "Setting option ${variable}: ${${variable}}")
|
||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
# Wraps an option with default ON/OFF. Adds nice messaging to option()
|
# Wraps an option with default ON/OFF. Adds nice messaging to option()
|
||||||
# Written by Lori A. Burns (@loriab) and Ryan M. Richard (@ryanmrichard)
|
# Written by Lori A. Burns (@loriab) and Ryan M. Richard (@ryanmrichard)
|
||||||
# Syntax: option_with_print(NAME <option name> MESSAGE <description> DEFAULT <default value>)
|
# Syntax: option_with_print(<option name> <description> <default value>)
|
||||||
macro(option_with_print)
|
macro(option_with_print variable msge default)
|
||||||
set(options)
|
print_option(${variable} ${default})
|
||||||
set(oneValueArgs NAME MESSAGE DEFAULT)
|
option(${variable} ${msge} ${default})
|
||||||
set(multiValueArgs)
|
|
||||||
cmake_parse_arguments(option_with_print
|
|
||||||
"${options}"
|
|
||||||
"${oneValueArgs}"
|
|
||||||
"${multiValueArgs}"
|
|
||||||
${ARGN}
|
|
||||||
)
|
|
||||||
print_option(
|
|
||||||
NAME ${option_with_print_NAME}
|
|
||||||
DEFAULT ${option_with_print_DEFAULT}
|
|
||||||
)
|
|
||||||
option(${option_with_print_NAME} ${option_with_print_MESSAGE} ${option_with_print_DEFAULT})
|
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
# Wraps an option with a default other than ON/OFF and prints it
|
# Wraps an option with a default other than ON/OFF and prints it
|
||||||
# Written by Lori A. Burns (@loriab) and Ryan M. Richard (@ryanmrichard)
|
# Written by Lori A. Burns (@loriab) and Ryan M. Richard (@ryanmrichard)
|
||||||
# NOTE: Can\'t combine with above b/c CMake handles ON/OFF options specially
|
# NOTE: Can't combine with above b/c CMake handles ON/OFF options specially
|
||||||
# NOTE2: CMake variables are always defined so need to further check for if
|
# NOTE2: CMake variables are always defined so need to further check for if
|
||||||
# they are the NULL string. This is also why we need the force
|
# they are the NULL string. This is also why we need the force
|
||||||
# Syntax: option_with_default(NAME <option name> MESSAGE <description> DEFAULT <default value>)
|
# Syntax: option_with_default(<option name> <description> <default value>)
|
||||||
macro(option_with_default)
|
macro(option_with_default variable msge default)
|
||||||
set(options)
|
print_option(${variable} "${default}")
|
||||||
set(oneValueArgs NAME MESSAGE DEFAULT)
|
if(NOT DEFINED ${variable} OR "${${variable}}" STREQUAL "")
|
||||||
set(multiValueArgs)
|
set(${variable} "${default}" CACHE STRING ${msge} FORCE)
|
||||||
cmake_parse_arguments(option_with_default
|
|
||||||
"${options}"
|
|
||||||
"${oneValueArgs}"
|
|
||||||
"${multiValueArgs}"
|
|
||||||
${ARGN}
|
|
||||||
)
|
|
||||||
print_option(
|
|
||||||
NAME ${option_with_default_NAME}
|
|
||||||
DEFAULT "${option_with_default_DEFAULT}"
|
|
||||||
)
|
|
||||||
if(NOT DEFINED ${option_with_default_NAME} OR "${${option_with_default_NAME}}" STREQUAL "")
|
|
||||||
set(${option_with_default_NAME} "${option_with_default_DEFAULT}" CACHE STRING ${option_with_default_MESSAGE} FORCE)
|
|
||||||
endif()
|
endif()
|
||||||
endmacro()"""
|
endmacro()"""
|
||||||
return s
|
return s
|
||||||
|
Loading…
x
Reference in New Issue
Block a user