Add ability to set CMake options with env variables
This commit is contained in:
parent
d88e9df9de
commit
f162a181b5
1 changed files with 17 additions and 5 deletions
|
@ -51,15 +51,27 @@ else()
|
|||
add_compile_options(-g)
|
||||
endif()
|
||||
|
||||
option(BUILD_SHARED_LIBS "Build a shared library" OFF)
|
||||
macro(xoption OPTION_NAME OPTION_TEXT OPTION_DEFAULT)
|
||||
option(${OPTION_NAME} ${OPTION_TEXT} ${OPTION_DEFAULT})
|
||||
if(DEFINED ENV{${OPTION_NAME}})
|
||||
# Allow setting the option through an environment variable.
|
||||
set(${OPTION_NAME} $ENV{${OPTION_NAME}})
|
||||
endif()
|
||||
if(${OPTION_NAME})
|
||||
add_definitions(-D${OPTION_NAME})
|
||||
endif()
|
||||
message(STATUS " ${OPTION_NAME}: ${${OPTION_NAME}}")
|
||||
endmacro()
|
||||
|
||||
xoption(BUILD_SHARED_LIBS "Build a shared library" OFF)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
message(STATUS "Building a shared library")
|
||||
endif()
|
||||
|
||||
option(BUILD_EXAMPLES "Build examples" OFF)
|
||||
option(CONFIG_ASAN "Enable AddressSanitizer (ASan)" OFF)
|
||||
option(CONFIG_MSAN "Enable MemorySanitizer (MSan)" OFF)
|
||||
option(CONFIG_UBSAN "Enable UndefinedBehaviorSanitizer (UBSan)" OFF)
|
||||
xoption(BUILD_EXAMPLES "Build examples" OFF)
|
||||
xoption(CONFIG_ASAN "Enable AddressSanitizer (ASan)" OFF)
|
||||
xoption(CONFIG_MSAN "Enable MemorySanitizer (MSan)" OFF)
|
||||
xoption(CONFIG_UBSAN "Enable UndefinedBehaviorSanitizer (UBSan)" OFF)
|
||||
|
||||
if(CONFIG_ASAN)
|
||||
message(STATUS "Building with ASan")
|
||||
|
|
Loading…
Reference in a new issue