ENH: Made Check* modules more consistent and well documented. Added CMAKE_REQUIRED_DEFINITIONS option.
This commit is contained in:
parent
f8a8e88a08
commit
f0a1da00c1
|
@ -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}"
|
||||
|
|
|
@ -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}"
|
||||
|
|
|
@ -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}")
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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}"
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -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}"
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue