summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2006-02-10 00:23:18 (GMT)
committerBrad King <brad.king@kitware.com>2006-02-10 00:23:18 (GMT)
commitf0a1da00c1d46bd3ffd0e1f4cfd76a3bbf2a2155 (patch)
tree2cbfbb98abe5416da719d9960563efbd7419bc8f /Modules
parentf8a8e88a081600e8f6bbad8172f77fb4f422b5cd (diff)
downloadCMake-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')
-rw-r--r--Modules/CheckCSourceCompiles.cmake11
-rw-r--r--Modules/CheckCXXSourceCompiles.cmake11
-rw-r--r--Modules/CheckFunctionExists.cmake22
-rw-r--r--Modules/CheckIncludeFile.cmake14
-rw-r--r--Modules/CheckIncludeFileCXX.cmake14
-rw-r--r--Modules/CheckIncludeFiles.cmake13
-rw-r--r--Modules/CheckLibraryExists.cmake15
-rw-r--r--Modules/CheckSymbolExists.cmake14
-rw-r--r--Modules/CheckVariableExists.cmake16
9 files changed, 101 insertions, 29 deletions
diff --git a/Modules/CheckCSourceCompiles.cmake b/Modules/CheckCSourceCompiles.cmake
index 35b3d7e..b08ea0a 100644
--- a/Modules/CheckCSourceCompiles.cmake
+++ b/Modules/CheckCSourceCompiles.cmake
@@ -3,10 +3,14 @@
# - macro which checks if the source code compiles
# SOURCE - source code to try to compile
# VAR - variable to store size if the type exists.
-# Checks the following optional VARIABLES (not arguments)
-# CMAKE_REQUIRED_LIBRARIES - Link to extra libraries
-# CMAKE_REQUIRED_FLAGS - Extra flags to C compiler
#
+# 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_C_SOURCE_COMPILES SOURCE VAR)
IF("${VAR}" MATCHES "^${VAR}$")
@@ -31,6 +35,7 @@ MACRO(CHECK_C_SOURCE_COMPILES SOURCE VAR)
TRY_COMPILE(${VAR}
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/src.c
+ COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
CMAKE_FLAGS
"${CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES}"
"${CHECK_C_SOURCE_COMPILES_ADD_INCLUDES}"
diff --git a/Modules/CheckCXXSourceCompiles.cmake b/Modules/CheckCXXSourceCompiles.cmake
index 8f6e12b..2fcf38c 100644
--- a/Modules/CheckCXXSourceCompiles.cmake
+++ b/Modules/CheckCXXSourceCompiles.cmake
@@ -3,10 +3,14 @@
# - macro which checks if the source code compiles\
# SOURCE - source code to try to compile
# VAR - variable to store size if the type exists.
-# Checks the following optional VARIABLES (not arguments)
-# CMAKE_REQUIRED_LIBRARIES - Link to extra libraries
-# CMAKE_REQUIRED_FLAGS - Extra flags to C compiler
#
+# 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_CXX_SOURCE_COMPILES SOURCE VAR)
IF("${VAR}" MATCHES "^${VAR}$")
@@ -31,6 +35,7 @@ MACRO(CHECK_CXX_SOURCE_COMPILES SOURCE VAR)
TRY_COMPILE(${VAR}
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/src.cxx
+ COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
CMAKE_FLAGS
"${CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES}"
"${CHECK_CXX_SOURCE_COMPILES_ADD_INCLUDES}"
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}")
diff --git a/Modules/CheckIncludeFile.cmake b/Modules/CheckIncludeFile.cmake
index a3de4cf..aafe7a8 100644
--- a/Modules/CheckIncludeFile.cmake
+++ b/Modules/CheckIncludeFile.cmake
@@ -7,8 +7,20 @@
# an optional third argument is the CFlags to add to the compile line
# or you can use CMAKE_REQUIRED_FLAGS
#
+# 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
+#
MACRO(CHECK_INCLUDE_FILE INCLUDE VARIABLE)
IF("${VARIABLE}" MATCHES "^${VARIABLE}$")
+ IF(CMAKE_REQUIRED_INCLUDES)
+ SET(CHECK_INCLUDE_FILE_C_INCLUDE_DIRS "-DINCLUDE_DIRECTORIES=${CMAKE_REQUIRED_INCLUDES}")
+ ELSE(CMAKE_REQUIRED_INCLUDES)
+ SET(CHECK_INCLUDE_FILE_C_INCLUDE_DIRS)
+ ENDIF(CMAKE_REQUIRED_INCLUDES)
SET(MACRO_CHECK_INCLUDE_FILE_FLAGS ${CMAKE_REQUIRED_FLAGS})
SET(CHECK_INCLUDE_FILE_VAR ${INCLUDE})
CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CheckIncludeFile.c.in
@@ -22,8 +34,10 @@ MACRO(CHECK_INCLUDE_FILE INCLUDE VARIABLE)
TRY_COMPILE(${VARIABLE}
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/CheckIncludeFile.c
+ COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
CMAKE_FLAGS
-DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_INCLUDE_FILE_FLAGS}
+ "${CHECK_INCLUDE_FILE_C_INCLUDE_DIRS}"
OUTPUT_VARIABLE OUTPUT)
IF(${ARGC} EQUAL 3)
diff --git a/Modules/CheckIncludeFileCXX.cmake b/Modules/CheckIncludeFileCXX.cmake
index f165b48..9d8eaac 100644
--- a/Modules/CheckIncludeFileCXX.cmake
+++ b/Modules/CheckIncludeFileCXX.cmake
@@ -7,8 +7,20 @@
# An optional third argument is the CFlags to add to the compile line
# or you can use CMAKE_REQUIRED_FLAGS.
#
+# 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
+#
MACRO(CHECK_INCLUDE_FILE_CXX INCLUDE VARIABLE)
IF("${VARIABLE}" MATCHES "^${VARIABLE}$")
+ IF(CMAKE_REQUIRED_INCLUDES)
+ SET(CHECK_INCLUDE_FILE_CXX_INCLUDE_DIRS "-DINCLUDE_DIRECTORIES=${CMAKE_REQUIRED_INCLUDES}")
+ ELSE(CMAKE_REQUIRED_INCLUDES)
+ SET(CHECK_INCLUDE_FILE_CXX_INCLUDE_DIRS)
+ ENDIF(CMAKE_REQUIRED_INCLUDES)
SET(MACRO_CHECK_INCLUDE_FILE_FLAGS ${CMAKE_REQUIRED_FLAGS})
SET(CHECK_INCLUDE_FILE_VAR ${INCLUDE})
CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CheckIncludeFile.cxx.in
@@ -22,8 +34,10 @@ MACRO(CHECK_INCLUDE_FILE_CXX INCLUDE VARIABLE)
TRY_COMPILE(${VARIABLE}
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/CheckIncludeFile.cxx
+ COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
CMAKE_FLAGS
-DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_INCLUDE_FILE_FLAGS}
+ "${CHECK_INCLUDE_FILE_CXX_INCLUDE_DIRS}"
OUTPUT_VARIABLE OUTPUT)
IF(${ARGC} EQUAL 3)
diff --git a/Modules/CheckIncludeFiles.cmake b/Modules/CheckIncludeFiles.cmake
index 45e5c89..bc923f0 100644
--- a/Modules/CheckIncludeFiles.cmake
+++ b/Modules/CheckIncludeFiles.cmake
@@ -4,11 +4,13 @@
#
# INCLUDE - list of files to include
# VARIABLE - variable to return result
-#
-# If CMAKE_REQUIRED_FLAGS is set then those flags will be passed into the
-# compile of the program
-# If CMAKE_REQUIRED_INCLUDES is set then those directories will be passed
-# as include paths to the compiler
+#
+# 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
MACRO(CHECK_INCLUDE_FILES INCLUDE VARIABLE)
IF("${VARIABLE}" MATCHES "^${VARIABLE}$")
@@ -32,6 +34,7 @@ MACRO(CHECK_INCLUDE_FILES INCLUDE VARIABLE)
TRY_COMPILE(${VARIABLE}
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/CheckIncludeFiles.c
+ COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
CMAKE_FLAGS
-DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_INCLUDE_FILES_FLAGS}
"${CHECK_INCLUDE_FILES_INCLUDE_DIRS}"
diff --git a/Modules/CheckLibraryExists.cmake b/Modules/CheckLibraryExists.cmake
index 822c3f3..fbdac5f 100644
--- a/Modules/CheckLibraryExists.cmake
+++ b/Modules/CheckLibraryExists.cmake
@@ -5,11 +5,13 @@
# FUNCTION - the name of the function
# LOCATION - location where the library should be found
# 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_LIBRARIES = list of libraries to link
MACRO(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE)
IF("${VARIABLE}" MATCHES "^${VARIABLE}$")
@@ -20,10 +22,13 @@ MACRO(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE)
IF(CMAKE_REQUIRED_LIBRARIES)
SET(CHECK_LIBRARY_EXISTS_LIBRARIES
${CHECK_LIBRARY_EXISTS_LIBRARIES} ${CMAKE_REQUIRED_LIBRARIES})
+ ELSE(CMAKE_REQUIRED_LIBRARIES)
+ SET(CHECK_LIBRARY_EXISTS_LIBRARIES)
ENDIF(CMAKE_REQUIRED_LIBRARIES)
TRY_COMPILE(${VARIABLE}
${CMAKE_BINARY_DIR}
${CMAKE_ROOT}/Modules/CheckFunctionExists.c
+ COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
CMAKE_FLAGS
-DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_LIBRARY_EXISTS_DEFINITION}
-DLINK_DIRECTORIES:STRING=${LOCATION}
diff --git a/Modules/CheckSymbolExists.cmake b/Modules/CheckSymbolExists.cmake
index f75e43b..ab4298a 100644
--- a/Modules/CheckSymbolExists.cmake
+++ b/Modules/CheckSymbolExists.cmake
@@ -4,11 +4,14 @@
# SYMBOL - symbol
# FILES - include files to check
# VARIABLE - variable to return 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_SYMBOL_EXISTS SYMBOL FILES VARIABLE)
IF("${VARIABLE}" MATCHES "^${VARIABLE}$")
@@ -40,6 +43,7 @@ MACRO(CHECK_SYMBOL_EXISTS SYMBOL FILES VARIABLE)
TRY_COMPILE(${VARIABLE}
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/CheckSymbolExists.c
+ COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
CMAKE_FLAGS
-DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_SYMBOL_EXISTS_FLAGS}
"${CHECK_SYMBOL_EXISTS_LIBS}"
diff --git a/Modules/CheckVariableExists.cmake b/Modules/CheckVariableExists.cmake
index 97413f4..2b0bdab 100644
--- a/Modules/CheckVariableExists.cmake
+++ b/Modules/CheckVariableExists.cmake
@@ -3,23 +3,31 @@
#
# VAR - the name of the variable
# 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.
+#
# This macro is only for C variables.
#
+# 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_LIBRARIES = list of libraries to link
+
MACRO(CHECK_VARIABLE_EXISTS VAR VARIABLE)
IF("${VARIABLE}" MATCHES "^${VARIABLE}$")
SET(MACRO_CHECK_VARIABLE_DEFINITIONS
"-DCHECK_VARIABLE_EXISTS=${VAR} ${CMAKE_REQUIRED_FLAGS}")
MESSAGE(STATUS "Looking for ${VAR}")
IF(CMAKE_REQUIRED_LIBRARIES)
- SET(CHECK_VARIABLE_EXISTS_ADD_LIBRARIES
+ SET(CHECK_VARIABLE_EXISTS_ADD_LIBRARIES
"-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
+ ELSE(CMAKE_REQUIRED_LIBRARIES)
+ SET(CHECK_VARIABLE_EXISTS_ADD_LIBRARIES)
ENDIF(CMAKE_REQUIRED_LIBRARIES)
TRY_COMPILE(${VARIABLE}
${CMAKE_BINARY_DIR}
${CMAKE_ROOT}/Modules/CheckVariableExists.c
+ COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_VARIABLE_DEFINITIONS}
"${CHECK_VARIABLE_EXISTS_ADD_LIBRARIES}"
OUTPUT_VARIABLE OUTPUT)