[Cmake-commits] [cmake-commits] king committed CheckCSourceCompiles.cmake 1.19 1.20 CheckCXXSourceCompiles.cmake 1.16 1.17
cmake-commits at cmake.org
cmake-commits at cmake.org
Thu Sep 17 15:29:03 EDT 2009
Update of /cvsroot/CMake/CMake/Modules
In directory public:/mounts/ram/cvs-serv29032/Modules
Modified Files:
CheckCSourceCompiles.cmake CheckCXXSourceCompiles.cmake
Log Message:
Add FAIL_REGEX to CHECK_(C|CXX)_SOURCE_COMPILES
This teaches the CHECK_C_SOURCE_COMPILES and CHECK_CXX_SOURCE_COMPILES
macros to recognize a FAIL_REGEX option. If they see the regular
expression in the output of the test compilation, the check fails.
Index: CheckCSourceCompiles.cmake
===================================================================
RCS file: /cvsroot/CMake/CMake/Modules/CheckCSourceCompiles.cmake,v
retrieving revision 1.19
retrieving revision 1.20
diff -C 2 -d -r1.19 -r1.20
*** CheckCSourceCompiles.cmake 17 Sep 2009 19:28:50 -0000 1.19
--- CheckCSourceCompiles.cmake 17 Sep 2009 19:29:01 -0000 1.20
***************
*** 1,6 ****
# - Check if the given C source code compiles.
! # CHECK_C_SOURCE_COMPILES(<code> <var>)
# <code> - source code to try to compile
# <var> - variable to store whether the source code compiled
# The following variables may be set before calling this macro to
# modify the way the check is run:
--- 1,7 ----
# - Check if the given C source code compiles.
! # CHECK_C_SOURCE_COMPILES(<code> <var> [FAIL_REGEX <fail-regex>])
# <code> - source code to try to compile
# <var> - variable to store whether the source code compiled
+ # <fail-regex> - fail if test output matches this regex
# The following variables may be set before calling this macro to
# modify the way the check is run:
***************
*** 13,16 ****
--- 14,28 ----
MACRO(CHECK_C_SOURCE_COMPILES SOURCE VAR)
IF("${VAR}" MATCHES "^${VAR}$")
+ SET(_FAIL_REGEX)
+ SET(_key)
+ FOREACH(arg ${ARGN})
+ IF("${arg}" MATCHES "^(FAIL_REGEX)$")
+ SET(_key "${arg}")
+ ELSEIF(_key)
+ LIST(APPEND _${_key} "${arg}")
+ ELSE()
+ MESSAGE(FATAL_ERROR "Unknown argument:\n ${arg}\n")
+ ENDIF()
+ ENDFOREACH()
SET(MACRO_CHECK_FUNCTION_DEFINITIONS
"-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
***************
*** 39,42 ****
--- 51,61 ----
"${CHECK_C_SOURCE_COMPILES_ADD_INCLUDES}"
OUTPUT_VARIABLE OUTPUT)
+
+ FOREACH(_regex ${_FAIL_REGEX})
+ IF("${OUTPUT}" MATCHES "${_regex}")
+ SET(${VAR} 0)
+ ENDIF()
+ ENDFOREACH()
+
IF(${VAR})
SET(${VAR} 1 CACHE INTERNAL "Test ${VAR}")
Index: CheckCXXSourceCompiles.cmake
===================================================================
RCS file: /cvsroot/CMake/CMake/Modules/CheckCXXSourceCompiles.cmake,v
retrieving revision 1.16
retrieving revision 1.17
diff -C 2 -d -r1.16 -r1.17
*** CheckCXXSourceCompiles.cmake 17 Sep 2009 19:28:51 -0000 1.16
--- CheckCXXSourceCompiles.cmake 17 Sep 2009 19:29:01 -0000 1.17
***************
*** 1,6 ****
# - Check if the given C++ source code compiles.
! # CHECK_CXX_SOURCE_COMPILES(<code> <var>)
# <code> - source code to try to compile
# <var> - variable to store whether the source code compiled
# The following variables may be set before calling this macro to
# modify the way the check is run:
--- 1,7 ----
# - Check if the given C++ source code compiles.
! # CHECK_CXX_SOURCE_COMPILES(<code> <var> [FAIL_REGEX <fail-regex>])
# <code> - source code to try to compile
# <var> - variable to store whether the source code compiled
+ # <fail-regex> - fail if test output matches this regex
# The following variables may be set before calling this macro to
# modify the way the check is run:
***************
*** 13,16 ****
--- 14,29 ----
MACRO(CHECK_CXX_SOURCE_COMPILES SOURCE VAR)
IF("${VAR}" MATCHES "^${VAR}$")
+ SET(_FAIL_REGEX)
+ SET(_key)
+ FOREACH(arg ${ARGN})
+ IF("${arg}" MATCHES "^(FAIL_REGEX)$")
+ SET(_key "${arg}")
+ ELSEIF(_key)
+ LIST(APPEND _${_key} "${arg}")
+ ELSE()
+ MESSAGE(FATAL_ERROR "Unknown argument:\n ${arg}\n")
+ ENDIF()
+ ENDFOREACH()
+
SET(MACRO_CHECK_FUNCTION_DEFINITIONS
"-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
***************
*** 39,42 ****
--- 52,62 ----
"${CHECK_CXX_SOURCE_COMPILES_ADD_INCLUDES}"
OUTPUT_VARIABLE OUTPUT)
+
+ FOREACH(_regex ${_FAIL_REGEX})
+ IF("${OUTPUT}" MATCHES "${_regex}")
+ SET(${VAR} 0)
+ ENDIF()
+ ENDFOREACH()
+
IF(${VAR})
SET(${VAR} 1 CACHE INTERNAL "Test ${VAR}")
More information about the Cmake-commits
mailing list