diff options
author | Rolf Eike Beer <eike@sf-mail.de> | 2015-09-22 04:11:50 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2015-09-25 14:07:54 (GMT) |
commit | a27bc0ccacff7bc590ace2ce941f0552d05fd14c (patch) | |
tree | b9f4b5e0ce15408cf38aa7db19af5ac4d900c850 /Modules/CheckLibraryExists.cmake | |
parent | 7279f2939e98ae9ecfb8fda2dc82f6b0048b9316 (diff) | |
download | CMake-a27bc0ccacff7bc590ace2ce941f0552d05fd14c.zip CMake-a27bc0ccacff7bc590ace2ce941f0552d05fd14c.tar.gz CMake-a27bc0ccacff7bc590ace2ce941f0552d05fd14c.tar.bz2 |
Check(Function|Library|Symbol)Exists: make it work if only C++ is enabled
Diffstat (limited to 'Modules/CheckLibraryExists.cmake')
-rw-r--r-- | Modules/CheckLibraryExists.cmake | 13 |
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) |