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/CheckFunctionExists.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/CheckFunctionExists.cmake')
-rw-r--r-- | Modules/CheckFunctionExists.cmake | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/Modules/CheckFunctionExists.cmake b/Modules/CheckFunctionExists.cmake index cbec739..c39144f 100644 --- a/Modules/CheckFunctionExists.cmake +++ b/Modules/CheckFunctionExists.cmake @@ -7,27 +7,33 @@ CheckFunctionExists Check if a C function can be linked -.. code-block:: cmake +.. command:: check_function_exists - check_function_exists(<function> <variable>) + .. code-block:: cmake -Checks that the ``<function>`` is provided by libraries on the system and store -the result in a ``<variable>``, which will be created as an internal -cache variable. + check_function_exists(<function> <variable>) + + Checks that the ``<function>`` is provided by libraries on the system and store + the result in a ``<variable>``, which will be created as an internal + cache variable. The following variables may be set before calling this macro to modify the way the check is run: ``CMAKE_REQUIRED_FLAGS`` - string of compile command line flags + string of compile command line flags. ``CMAKE_REQUIRED_DEFINITIONS`` - list of macros to define (-DFOO=bar) + a :ref:`;-list <CMake Language Lists>` of macros to define (-DFOO=bar). ``CMAKE_REQUIRED_INCLUDES`` - list of include directories + a :ref:`;-list <CMake Language Lists>` of header search paths to pass to + the compiler. +``CMAKE_REQUIRED_LINK_OPTIONS`` + a :ref:`;-list <CMake Language Lists>` of options to add to the link command. ``CMAKE_REQUIRED_LIBRARIES`` - list of libraries to link + a :ref:`;-list <CMake Language Lists>` of libraries to add to the link + command. See policy :policy:`CMP0075`. ``CMAKE_REQUIRED_QUIET`` - execute quietly without messages + execute quietly without messages. .. note:: @@ -53,6 +59,12 @@ macro(CHECK_FUNCTION_EXISTS FUNCTION VARIABLE) if(NOT CMAKE_REQUIRED_QUIET) message(STATUS "Looking for ${FUNCTION}") endif() + if(CMAKE_REQUIRED_LINK_OPTIONS) + set(CHECK_FUNCTION_EXISTS_ADD_LINK_OPTIONS + LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS}) + else() + set(CHECK_FUNCTION_EXISTS_ADD_LINK_OPTIONS) + endif() if(CMAKE_REQUIRED_LIBRARIES) set(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) @@ -79,6 +91,7 @@ macro(CHECK_FUNCTION_EXISTS FUNCTION VARIABLE) ${CMAKE_BINARY_DIR} ${_cfe_source} COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} + ${CHECK_FUNCTION_EXISTS_ADD_LINK_OPTIONS} ${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES} CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} "${CHECK_FUNCTION_EXISTS_ADD_INCLUDES}" |