summaryrefslogtreecommitdiffstats
path: root/Modules/CheckLibraryExists.cmake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-09-25 14:12:37 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2015-09-25 14:12:37 (GMT)
commit910ea2100425289ec4f13327141b5c45ede320bd (patch)
treee4f0baf8c87443cf77e882bee7b6c3f9c670d76b /Modules/CheckLibraryExists.cmake
parentede54544f1cbaa623628317887ffc34fce4bc89b (diff)
parentfff9434d455600320be1809c6d64577eeb21d6aa (diff)
downloadCMake-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/CheckLibraryExists.cmake')
-rw-r--r--Modules/CheckLibraryExists.cmake13
1 files changed, 12 insertions, 1 deletions
diff --git a/Modules/CheckLibraryExists.cmake b/Modules/CheckLibraryExists.cmake
index 95c595a..6b53823 100644
--- a/Modules/CheckLibraryExists.cmake
+++ b/Modules/CheckLibraryExists.cmake
@@ -53,15 +53,26 @@ macro(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE)
set(CHECK_LIBRARY_EXISTS_LIBRARIES
${CHECK_LIBRARY_EXISTS_LIBRARIES} ${CMAKE_REQUIRED_LIBRARIES})
endif()
+
+ if(CMAKE_C_COMPILER_LOADED)
+ set(_cle_source ${CMAKE_ROOT}/Modules/CheckFunctionExists.c)
+ elseif(CMAKE_CXX_COMPILER_LOADED)
+ set(_cle_source ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckLibraryExists/CheckFunctionExists.cxx)
+ configure_file(${CMAKE_ROOT}/Modules/CheckFunctionExists.c "${_cle_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
+ ${_cle_source}
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
LINK_LIBRARIES ${CHECK_LIBRARY_EXISTS_LIBRARIES}
CMAKE_FLAGS
-DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_LIBRARY_EXISTS_DEFINITION}
-DLINK_DIRECTORIES:STRING=${LOCATION}
OUTPUT_VARIABLE OUTPUT)
+ unset(_cle_source)
if(${VARIABLE})
if(NOT CMAKE_REQUIRED_QUIET)