diff options
author | Brad King <brad.king@kitware.com> | 2006-02-10 00:23:18 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2006-02-10 00:23:18 (GMT) |
commit | f0a1da00c1d46bd3ffd0e1f4cfd76a3bbf2a2155 (patch) | |
tree | 2cbfbb98abe5416da719d9960563efbd7419bc8f /Modules/CheckFunctionExists.cmake | |
parent | f8a8e88a081600e8f6bbad8172f77fb4f422b5cd (diff) | |
download | CMake-f0a1da00c1d46bd3ffd0e1f4cfd76a3bbf2a2155.zip CMake-f0a1da00c1d46bd3ffd0e1f4cfd76a3bbf2a2155.tar.gz CMake-f0a1da00c1d46bd3ffd0e1f4cfd76a3bbf2a2155.tar.bz2 |
ENH: Made Check* modules more consistent and well documented. Added CMAKE_REQUIRED_DEFINITIONS option.
Diffstat (limited to 'Modules/CheckFunctionExists.cmake')
-rw-r--r-- | Modules/CheckFunctionExists.cmake | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/Modules/CheckFunctionExists.cmake b/Modules/CheckFunctionExists.cmake index 6e43f9c..80ff365 100644 --- a/Modules/CheckFunctionExists.cmake +++ b/Modules/CheckFunctionExists.cmake @@ -3,10 +3,14 @@ # - macro which checks if the function exists # FUNCTION - the name of the function # VARIABLE - variable to store the result -# If CMAKE_REQUIRED_FLAGS is set then those flags will be passed into the -# compile of the program likewise if CMAKE_REQUIRED_LIBRARIES is set then -# those libraries will be linked against the test program # +# 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 +# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) +# CMAKE_REQUIRED_INCLUDES = list of include directories +# CMAKE_REQUIRED_LIBRARIES = list of libraries to link MACRO(CHECK_FUNCTION_EXISTS FUNCTION VARIABLE) IF("${VARIABLE}" MATCHES "^${VARIABLE}$") @@ -14,14 +18,24 @@ MACRO(CHECK_FUNCTION_EXISTS FUNCTION VARIABLE) "-DCHECK_FUNCTION_EXISTS=${FUNCTION} ${CMAKE_REQUIRED_FLAGS}") MESSAGE(STATUS "Looking for ${FUNCTION}") IF(CMAKE_REQUIRED_LIBRARIES) - SET(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES + SET(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") + ELSE(CMAKE_REQUIRED_LIBRARIES) + SET(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES) ENDIF(CMAKE_REQUIRED_LIBRARIES) + IF(CMAKE_REQUIRED_INCLUDES) + SET(CHECK_FUNCTION_EXISTS_ADD_INCLUDES + "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}") + ELSE(CMAKE_REQUIRED_INCLUDES) + SET(CHECK_FUNCTION_EXISTS_ADD_INCLUDES) + ENDIF(CMAKE_REQUIRED_INCLUDES) TRY_COMPILE(${VARIABLE} ${CMAKE_BINARY_DIR} ${CMAKE_ROOT}/Modules/CheckFunctionExists.c + COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} "${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES}" + "${CHECK_FUNCTION_EXISTS_ADD_INCLUDES}" OUTPUT_VARIABLE OUTPUT) IF(${VARIABLE}) SET(${VARIABLE} 1 CACHE INTERNAL "Have function ${FUNCTION}") |