[Cmake-commits] CMake branch, next, updated. v2.8.7-1969-g9064b55

Rolf Eike Beer eike at sf-mail.de
Thu Jan 5 12:29:45 EST 2012


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  9064b55fd578f876714dd9a529491c0252d67841 (commit)
       via  e23afd1f34f477cf56973cea69d15a492028c2af (commit)
       via  d53db53e1b1a54ecf3459f67368b6b5d724112e1 (commit)
      from  ccfe52012ac0df9baad45aa567dabd223feff580 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9064b55fd578f876714dd9a529491c0252d67841
commit 9064b55fd578f876714dd9a529491c0252d67841
Merge: ccfe520 e23afd1
Author:     Rolf Eike Beer <eike at sf-mail.de>
AuthorDate: Thu Jan 5 12:29:43 2012 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Thu Jan 5 12:29:43 2012 -0500

    Merge topic 'test-symbol-exists' into next
    
    e23afd1 add a test for Check{,CXX}SymbolExists
    d53db53 CheckSymbolExists: force the compiler to keep the referenced symbol


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e23afd1f34f477cf56973cea69d15a492028c2af
commit e23afd1f34f477cf56973cea69d15a492028c2af
Author:     Rolf Eike Beer <eike at sf-mail.de>
AuthorDate: Mon Jan 2 23:04:42 2012 +0100
Commit:     Rolf Eike Beer <eike at sf-mail.de>
CommitDate: Thu Jan 5 18:28:57 2012 +0100

    add a test for Check{,CXX}SymbolExists
    
    Now that we think that CheckSymbolExists really works for all cases it is time
    to prove that. If this code fails too many other things will break.

diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 42b3ef7..4e6e255 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -242,6 +242,9 @@ IF(BUILD_TESTING)
 
   ADD_TEST_MACRO(Module.CheckCXXCompilerFlag CheckCXXCompilerFlag)
 
+  ADD_SUBDIRECTORY(Module/CheckSymbolExists)
+  ADD_SUBDIRECTORY(Module/CheckCXXSymbolExists)
+
   ADD_TEST(LinkFlags-prepare
     ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE}
     --build-and-test
diff --git a/Tests/Module/CheckCXXSymbolExists/CMakeLists.txt b/Tests/Module/CheckCXXSymbolExists/CMakeLists.txt
new file mode 100644
index 0000000..fbe9810
--- /dev/null
+++ b/Tests/Module/CheckCXXSymbolExists/CMakeLists.txt
@@ -0,0 +1,25 @@
+# This test will verify if CheckCXXSymbolExists only report symbols available
+# for linking that really are. You can find some documentation on this in
+# bug 11333 where we found out that gcc would optimize out the actual
+# reference to the symbol, so symbols that are in fact _not_ available in the
+# given libraries (but seen in header) were reported as present.
+#
+# If you change this test do not forget to change the CheckSymbolExists
+# test, too.
+
+cmake_minimum_required(VERSION 2.8)
+
+set(_test_dir "${CMAKE_CURRENT_BINARY_DIR}/symbol_cxx")
+set(_test_build_dir "${CMAKE_CURRENT_BINARY_DIR}/symbol_build")
+file(REMOVE_RECURSE "${_test_build_dir}")
+file(MAKE_DIRECTORY "${_test_dir}" "${_test_build_dir}")
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt.in"
+  "${_test_dir}/CMakeLists.txt" @ONLY)
+ADD_TEST(CheckCXXSymbolExists
+  ${CMAKE_CMAKE_COMMAND}
+    -G "${CMAKE_GENERATOR}"
+    --debug-trycompile
+    "${_test_dir}"
+  )
+set_tests_properties(CheckCXXSymbolExists PROPERTIES
+  WORKING_DIRECTORY "${_test_build_dir}")
diff --git a/Tests/Module/CheckCXXSymbolExists/CMakeLists.txt.in b/Tests/Module/CheckCXXSymbolExists/CMakeLists.txt.in
new file mode 100644
index 0000000..be31acb
--- /dev/null
+++ b/Tests/Module/CheckCXXSymbolExists/CMakeLists.txt.in
@@ -0,0 +1,42 @@
+PROJECT(CheckCXXSymbolExistsTest CXX)
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
+
+SET(CMAKE_REQUIRED_INCLUDES "@CMAKE_CURRENT_SOURCE_DIR@/../CheckSymbolExists")
+
+INCLUDE(CheckCXXSymbolExists)
+
+foreach(_config_type Release RelWithDebInfo MinSizeRel Debug)
+  set(CMAKE_TRY_COMPILE_CONFIGURATION ${_config_type})
+  MESSAGE(STATUS "Testing configuration ${_config_type}")
+  check_cxx_symbol_exists(non_existent_function_for_symbol_test "cm_cse.h" CSE_RESULT_${_config_type})
+
+  IF (CSE_RESULT_${_config_type})
+    MESSAGE(SEND_ERROR "CheckCXXSymbolExists reported a nonexistent symbol as existing in configuration ${_config_type}")
+  ELSE (CSE_RESULT_${_config_type})
+    MESSAGE(STATUS "Nonexistent symbol was not found")
+  ENDIF (CSE_RESULT_${_config_type})
+endforeach()
+
+set(CMAKE_TRY_COMPILE_CONFIGURATION ${CMAKE_BUILD_TYPE})
+
+check_cxx_symbol_exists(errno "errno.h" CSE_RESULT_ERRNO)
+
+IF (NOT CSE_RESULT_ERRNO)
+  MESSAGE(FATAL_ERROR "CheckCXXSymbolExists did not find errno in <errno.h>")
+ELSE (NOT CSE_RESULT_ERRNO)
+  MESSAGE(STATUS "errno found as expected")
+ENDIF (NOT CSE_RESULT_ERRNO)
+
+IF (CMAKE_COMPILER_IS_GNUCXX)
+  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
+  MESSAGE(STATUS "Testing with optimization -O3")
+
+  check_cxx_symbol_exists(non_existent_function_for_symbol_test "cm_cse.h" CSE_RESULT_O3)
+
+  IF (CSE_RESULT_O3)
+    MESSAGE(SEND_ERROR "CheckCXXSymbolExists reported a nonexistent symbol as existing with optimization -O3")
+  ELSE (CSE_RESULT_O3)
+    MESSAGE(STATUS "Nonexistent symbol was not found")
+  ENDIF (CSE_RESULT_O3)
+ENDIF (CMAKE_COMPILER_IS_GNUCXX)
diff --git a/Tests/Module/CheckSymbolExists/CMakeLists.txt b/Tests/Module/CheckSymbolExists/CMakeLists.txt
new file mode 100644
index 0000000..a52fd3b
--- /dev/null
+++ b/Tests/Module/CheckSymbolExists/CMakeLists.txt
@@ -0,0 +1,24 @@
+# This test will verify if CheckSymbolExists only report symbols available
+# for linking that really are. You can find some documentation on this in
+# bug 11333 where we found out that gcc would optimize out the actual
+# reference to the symbol, so symbols that are in fact _not_ available in the
+# given libraries (but seen in header) were reported as present.
+#
+# If you change this test do not forget to change the CheckCXXSymbolExists
+# test, too.
+
+cmake_minimum_required(VERSION 2.8)
+
+set(_test_dir "${CMAKE_CURRENT_BINARY_DIR}/symbol_c")
+set(_test_build_dir "${CMAKE_CURRENT_BINARY_DIR}/symbol_build")
+file(REMOVE_RECURSE "${_test_build_dir}")
+file(MAKE_DIRECTORY "${_test_dir}" "${_test_build_dir}")
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt.in"
+  "${_test_dir}/CMakeLists.txt" @ONLY)
+ADD_TEST(CheckSymbolExists
+  ${CMAKE_CMAKE_COMMAND}
+    -G "${CMAKE_GENERATOR}"
+    "${_test_dir}"
+  )
+set_tests_properties(CheckSymbolExists PROPERTIES
+  WORKING_DIRECTORY "${_test_build_dir}")
diff --git a/Tests/Module/CheckSymbolExists/CMakeLists.txt.in b/Tests/Module/CheckSymbolExists/CMakeLists.txt.in
new file mode 100644
index 0000000..00758c0
--- /dev/null
+++ b/Tests/Module/CheckSymbolExists/CMakeLists.txt.in
@@ -0,0 +1,42 @@
+PROJECT(CheckSymbolExistsTest C)
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
+
+SET(CMAKE_REQUIRED_INCLUDES "@CMAKE_CURRENT_SOURCE_DIR@")
+
+INCLUDE(CheckSymbolExists)
+
+foreach(_config_type Release RelWithDebInfo MinSizeRel Debug)
+  set(CMAKE_TRY_COMPILE_CONFIGURATION ${_config_type})
+  MESSAGE(STATUS "Testing configuration ${_config_type}")
+  check_symbol_exists(non_existent_function_for_symbol_test "cm_cse.h" CSE_RESULT_${_config_type})
+
+  IF (CSE_RESULT_${_config_type})
+    MESSAGE(SEND_ERROR "CheckSymbolExists reported a nonexistent symbol as existing in configuration ${_config_type}")
+  ELSE (CSE_RESULT_${_config_type})
+    MESSAGE(STATUS "Nonexistent symbol was not found")
+  ENDIF (CSE_RESULT_${_config_type})
+endforeach()
+
+set(CMAKE_TRY_COMPILE_CONFIGURATION ${CMAKE_BUILD_TYPE})
+
+check_symbol_exists(errno "errno.h" CSE_RESULT_ERRNO)
+
+IF (NOT CSE_RESULT_ERRNO)
+  MESSAGE(FATAL_ERROR "CheckSymbolExists did not find errno in <errno.h>")
+ELSE (NOT CSE_RESULT_ERRNO)
+  MESSAGE(STATUS "errno found as expected")
+ENDIF (NOT CSE_RESULT_ERRNO)
+
+IF (CMAKE_COMPILER_IS_GNUC)
+  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3")
+  MESSAGE(STATUS "Testing with optimization -O3")
+
+  check_symbol_exists(non_existent_function_for_symbol_test "cm_cse.h" CSE_RESULT_O3)
+
+  IF (CSE_RESULT_O3)
+    MESSAGE(SEND_ERROR "CheckSymbolExists reported a nonexistent symbol as existing with optimization -O3")
+  ELSE (CSE_RESULT_O3)
+    MESSAGE(STATUS "Nonexistent symbol was not found")
+  ENDIF (CSE_RESULT_O3)
+ENDIF (CMAKE_COMPILER_IS_GNUC)
diff --git a/Tests/Module/CheckSymbolExists/cm_cse.h b/Tests/Module/CheckSymbolExists/cm_cse.h
new file mode 100644
index 0000000..4f41c76
--- /dev/null
+++ b/Tests/Module/CheckSymbolExists/cm_cse.h
@@ -0,0 +1,6 @@
+#ifndef _CSE_DUMMY_H
+#define _CSE_DUMMY_H
+
+int non_existent_function_for_symbol_test();
+
+#endif

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d53db53e1b1a54ecf3459f67368b6b5d724112e1
commit d53db53e1b1a54ecf3459f67368b6b5d724112e1
Author:     Rolf Eike Beer <eike at sf-mail.de>
AuthorDate: Tue Jan 3 19:54:43 2012 +0100
Commit:     Rolf Eike Beer <eike at sf-mail.de>
CommitDate: Wed Jan 4 23:10:32 2012 +0100

    CheckSymbolExists: force the compiler to keep the referenced symbol
    
    Otherwise the compiler may optimize out the reference to the symbol as the
    previous version was not really using this. This leads to symbols that are
    only in a header but not in the given libraries to be reported as present.
    
    This came up on the first try to fix bug 11333 as "gcc -O3" would optimize
    out the reference to pthread_create() so the correct library the symbol is in
    was not detected.
    
    The new test code was suggested by Brad King.

diff --git a/Modules/CheckSymbolExists.cmake b/Modules/CheckSymbolExists.cmake
index 183b2bb..515319d 100644
--- a/Modules/CheckSymbolExists.cmake
+++ b/Modules/CheckSymbolExists.cmake
@@ -60,7 +60,7 @@ MACRO(_CHECK_SYMBOL_EXISTS SOURCEFILE SYMBOL FILES VARIABLE)
         "${CMAKE_CONFIGURABLE_FILE_CONTENT}#include <${FILE}>\n")
     ENDFOREACH(FILE)
     SET(CMAKE_CONFIGURABLE_FILE_CONTENT
-      "${CMAKE_CONFIGURABLE_FILE_CONTENT}\nvoid cmakeRequireSymbol(int dummy,...){(void)dummy;}\nint main()\n{\n#ifndef ${SYMBOL}\n  cmakeRequireSymbol(0,&${SYMBOL});\n#endif\n  return 0;\n}\n")
+      "${CMAKE_CONFIGURABLE_FILE_CONTENT}\nint main(int argc, char** argv)\n{\n  (void)argv;\n#ifndef ${SYMBOL}\n  return ((int*)(&${SYMBOL}))[argc];\n#else\n  (void)argc;\n  return 0;\n#endif\n}\n")
 
     CONFIGURE_FILE("${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in"
       "${SOURCEFILE}" @ONLY IMMEDIATE)

-----------------------------------------------------------------------

Summary of changes:
 Modules/CheckSymbolExists.cmake                    |    2 +-
 Tests/CMakeLists.txt                               |    3 +
 Tests/Module/CheckCXXSymbolExists/CMakeLists.txt   |   25 ++++++++++++
 .../Module/CheckCXXSymbolExists/CMakeLists.txt.in  |   42 ++++++++++++++++++++
 Tests/Module/CheckSymbolExists/CMakeLists.txt      |   24 +++++++++++
 Tests/Module/CheckSymbolExists/CMakeLists.txt.in   |   42 ++++++++++++++++++++
 Tests/Module/CheckSymbolExists/cm_cse.h            |    6 +++
 7 files changed, 143 insertions(+), 1 deletions(-)
 create mode 100644 Tests/Module/CheckCXXSymbolExists/CMakeLists.txt
 create mode 100644 Tests/Module/CheckCXXSymbolExists/CMakeLists.txt.in
 create mode 100644 Tests/Module/CheckSymbolExists/CMakeLists.txt
 create mode 100644 Tests/Module/CheckSymbolExists/CMakeLists.txt.in
 create mode 100644 Tests/Module/CheckSymbolExists/cm_cse.h


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list