summaryrefslogtreecommitdiffstats
path: root/Modules/CheckFunctionExists.cmake
diff options
context:
space:
mode:
authorRolf Eike Beer <eike@sf-mail.de>2015-09-22 04:11:50 (GMT)
committerBrad King <brad.king@kitware.com>2015-09-25 14:07:54 (GMT)
commita27bc0ccacff7bc590ace2ce941f0552d05fd14c (patch)
treeb9f4b5e0ce15408cf38aa7db19af5ac4d900c850 /Modules/CheckFunctionExists.cmake
parent7279f2939e98ae9ecfb8fda2dc82f6b0048b9316 (diff)
downloadCMake-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/CheckFunctionExists.cmake')
-rw-r--r--Modules/CheckFunctionExists.cmake14
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)