diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2018-11-26 16:32:06 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@gmail.com> | 2018-12-01 16:56:23 (GMT) |
commit | f266182aecb687f0c20c7fa7019ad0dde3222f46 (patch) | |
tree | 329ec6152a0290856004f3ac263c71acc740a4b3 /Modules/CheckVariableExists.cmake | |
parent | 29f9db5c63dbfa53acdb449fad78d716a4113a88 (diff) | |
download | CMake-f266182aecb687f0c20c7fa7019ad0dde3222f46.zip CMake-f266182aecb687f0c20c7fa7019ad0dde3222f46.tar.gz CMake-f266182aecb687f0c20c7fa7019ad0dde3222f46.tar.bz2 |
Check* functions family: add support for LINK_OPTIONS
Fixes: #18521
Diffstat (limited to 'Modules/CheckVariableExists.cmake')
-rw-r--r-- | Modules/CheckVariableExists.cmake | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/Modules/CheckVariableExists.cmake b/Modules/CheckVariableExists.cmake index f30165e..f4953a3 100644 --- a/Modules/CheckVariableExists.cmake +++ b/Modules/CheckVariableExists.cmake @@ -7,20 +7,21 @@ CheckVariableExists Check if the variable exists. -:: +.. command:: CHECK_VARIABLE_EXISTS - CHECK_VARIABLE_EXISTS(VAR VARIABLE) + .. code-block:: cmake + CHECK_VARIABLE_EXISTS(VAR VARIABLE) -:: + :: - VAR - the name of the variable - VARIABLE - variable to store the result - Will be created as an internal cache variable. + VAR - the name of the variable + VARIABLE - variable to store the result + Will be created as an internal cache variable. -This macro is only for C variables. + This macro is only for ``C`` variables. The following variables may be set before calling this macro to modify the way the check is run: @@ -29,6 +30,7 @@ the way the check is run: CMAKE_REQUIRED_FLAGS = string of compile command line flags CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) + CMAKE_REQUIRED_LINK_OPTIONS = list of options to pass to link command CMAKE_REQUIRED_LIBRARIES = list of libraries to link CMAKE_REQUIRED_QUIET = execute quietly without messages #]=======================================================================] @@ -42,6 +44,12 @@ macro(CHECK_VARIABLE_EXISTS VAR VARIABLE) if(NOT CMAKE_REQUIRED_QUIET) message(STATUS "Looking for ${VAR}") endif() + if(CMAKE_REQUIRED_LINK_OPTIONS) + set(CHECK_VARIABLE_EXISTS_ADD_LINK_OPTIONS + LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS}) + else() + set(CHECK_VARIABLE_EXISTS_ADD_LINK_OPTIONS) + endif() if(CMAKE_REQUIRED_LIBRARIES) set(CHECK_VARIABLE_EXISTS_ADD_LIBRARIES LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) @@ -52,6 +60,7 @@ macro(CHECK_VARIABLE_EXISTS VAR VARIABLE) ${CMAKE_BINARY_DIR} ${CMAKE_ROOT}/Modules/CheckVariableExists.c COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} + ${CHECK_VARIABLE_EXISTS_ADD_LINK_OPTIONS} ${CHECK_VARIABLE_EXISTS_ADD_LIBRARIES} CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_VARIABLE_DEFINITIONS} OUTPUT_VARIABLE OUTPUT) |