diff options
author | Brad King <brad.king@kitware.com> | 2015-09-25 14:12:37 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2015-09-25 14:12:37 (GMT) |
commit | 910ea2100425289ec4f13327141b5c45ede320bd (patch) | |
tree | e4f0baf8c87443cf77e882bee7b6c3f9c670d76b /Modules/CheckFunctionExists.cmake | |
parent | ede54544f1cbaa623628317887ffc34fce4bc89b (diff) | |
parent | fff9434d455600320be1809c6d64577eeb21d6aa (diff) | |
download | CMake-910ea2100425289ec4f13327141b5c45ede320bd.zip CMake-910ea2100425289ec4f13327141b5c45ede320bd.tar.gz CMake-910ea2100425289ec4f13327141b5c45ede320bd.tar.bz2 |
Merge topic 'Threads-CXX'
fff9434d FindThreads: officially announce it works with only C++ enabled
66db914a FindThreads: fix printing a pointer value in test code
0b38424c FindThreads: make the call to try_run() work also if only C++ is enabled
9924a212 FindThreads: replace CheckIncludeFiles by CheckIncludeFile
a27bc0cc Check(Function|Library|Symbol)Exists: make it work if only C++ is enabled
7279f293 FindThreads: add simple testcase
Diffstat (limited to 'Modules/CheckFunctionExists.cmake')
-rw-r--r-- | Modules/CheckFunctionExists.cmake | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/Modules/CheckFunctionExists.cmake b/Modules/CheckFunctionExists.cmake index d277c32..5dd3751 100644 --- a/Modules/CheckFunctionExists.cmake +++ b/Modules/CheckFunctionExists.cmake @@ -57,14 +57,26 @@ macro(CHECK_FUNCTION_EXISTS FUNCTION VARIABLE) else() set(CHECK_FUNCTION_EXISTS_ADD_INCLUDES) endif() + + if(CMAKE_C_COMPILER_LOADED) + set(_cfe_source ${CMAKE_ROOT}/Modules/CheckFunctionExists.c) + elseif(CMAKE_CXX_COMPILER_LOADED) + set(_cfe_source ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckFunctionExists/CheckFunctionExists.cxx) + configure_file(${CMAKE_ROOT}/Modules/CheckFunctionExists.c "${_cfe_source}" COPYONLY) + else() + message(FATAL_ERROR "CHECK_FUNCTION_EXISTS needs either C or CXX language enabled") + endif() + try_compile(${VARIABLE} ${CMAKE_BINARY_DIR} - ${CMAKE_ROOT}/Modules/CheckFunctionExists.c + ${_cfe_source} COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES} CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} "${CHECK_FUNCTION_EXISTS_ADD_INCLUDES}" OUTPUT_VARIABLE OUTPUT) + unset(_cfe_source) + if(${VARIABLE}) set(${VARIABLE} 1 CACHE INTERNAL "Have function ${FUNCTION}") if(NOT CMAKE_REQUIRED_QUIET) |