From 8de3b3d13ed40e97b74eeac4ce2d966a73c5168a Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Tue, 17 Jan 2012 23:53:26 +0100 Subject: CheckCXXCompilerFlag test: make it a CMakeOnly test --- Tests/CMakeLists.txt | 2 - Tests/CMakeOnly/CMakeLists.txt | 2 + .../CMakeOnly/CheckCXXCompilerFlag/CMakeLists.txt | 58 +++++++++++++++++ Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt | 74 ---------------------- 4 files changed, 60 insertions(+), 76 deletions(-) create mode 100644 Tests/CMakeOnly/CheckCXXCompilerFlag/CMakeLists.txt delete mode 100644 Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index badc76b..2c5acd9 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -241,8 +241,6 @@ IF(BUILD_TESTING) ADD_TEST_MACRO(Module.GenerateExportHeader GenerateExportHeader) - ADD_TEST_MACRO(Module.CheckCXXCompilerFlag CheckCXXCompilerFlag) - ADD_TEST(LinkFlags-prepare ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE} --build-and-test diff --git a/Tests/CMakeOnly/CMakeLists.txt b/Tests/CMakeOnly/CMakeLists.txt index 20e6a3a..2209b20 100644 --- a/Tests/CMakeOnly/CMakeLists.txt +++ b/Tests/CMakeOnly/CMakeLists.txt @@ -15,4 +15,6 @@ add_CMakeOnly_test(CheckSymbolExists) add_CMakeOnly_test(CheckCXXSymbolExists) +add_CMakeOnly_test(CheckCXXCompilerFlag) + add_CMakeOnly_test(AllFindModules) diff --git a/Tests/CMakeOnly/CheckCXXCompilerFlag/CMakeLists.txt b/Tests/CMakeOnly/CheckCXXCompilerFlag/CMakeLists.txt new file mode 100644 index 0000000..e205330 --- /dev/null +++ b/Tests/CMakeOnly/CheckCXXCompilerFlag/CMakeLists.txt @@ -0,0 +1,58 @@ +cmake_minimum_required(VERSION 2.8) +project(CheckCXXCompilerFlag) + +message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)") +set(CMAKE_VERBOSE_MAKEFILE 1) + +macro(TEST_FAIL value msg) + if (${value}) + message (SEND_ERROR "Test fail:" ${msg} ${Out} ) + endif () +endmacro() + +macro(TEST_PASS value msg) + if (NOT ${value}) + message (SEND_ERROR "Test fail:" ${msg} ${Out} ) + endif () +endmacro() + +if(CMAKE_COMPILER_IS_GNUCXX) + exec_program(${CMAKE_C_COMPILER} ARGS --version OUTPUT_VARIABLE _gcc_version_info) + string (REGEX MATCH "[345]\\.[0-9]\\.[0-9]" _gcc_version "${_gcc_version_info}") + # gcc on mac just reports: "gcc (GCC) 3.3 20030304 ..." without the + # patch level, handle this here: + if(NOT _gcc_version) + string (REGEX REPLACE ".*\\(GCC\\).* ([34]\\.[0-9]) .*" "\\1.0" _gcc_version "${_gcc_version_info}") + endif() +endif() + +if(CMAKE_CXX_COMPILER_ID MATCHES Clang) + exec_program(${CMAKE_CXX_COMPILER} ARGS --version OUTPUT_VARIABLE _clang_version_info) + string (REGEX REPLACE ".*version ([0-9]\\.[0-9]).*" "\\1" _clang_version "${_clang_version_info}") +endif() + +if(CMAKE_CXX_COMPILER_ID MATCHES Intel) + exec_program(${CMAKE_CXX_COMPILER} ARGS -V OUTPUT_VARIABLE _intel_version_info) + string (REGEX REPLACE ".*Version ([0-9]+(\\.[0-9]+)+).*" "\\1" _intel_version "${_intel_version_info}") +endif() + +message("Platform:\n WIN32: ${WIN32}\n UNIX: ${UNIX}\n APPLE: ${APPLE}\n MINGW: ${MINGW}\n CYGWIN: ${CYGWIN}\n" + " MSVC: ${MSVC}\n MSVC60: ${MSVC60}\n MSVC70: ${MSVC70}\n MSVC71: ${MSVC71}\n MSVC80: ${MSVC80}\n MSVC90: ${MSVC90}\n MSVC10: ${MSVC10}\n" + " GCC: ${_gcc_version}\n" + " Clang: ${_clang_version}\n" + " Intel: ${_intel_version}\n" +) + +include(CheckCXXCompilerFlag) + +check_cxx_compiler_flag(-fvisibility=hidden HAS_HIDDEN_VISIBILITY) + +message("HAS_HIDDEN_VISIBILITY: ${HAS_HIDDEN_VISIBILITY}\n\nCOMPILE OUTPUT:\n${OUTPUT}") + +if(CMAKE_COMPILER_IS_GNUCXX) + if(NOT WIN32) +# test_pass(HAS_HIDDEN_VISIBILITY "GCC should support hidden visibility, but does not.") + endif() +else() + message("Unhandled Platform") +endif() diff --git a/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt b/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt deleted file mode 100644 index 77f5006..0000000 --- a/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt +++ /dev/null @@ -1,74 +0,0 @@ -cmake_minimum_required(VERSION 2.8) -project(CheckCXXCompilerFlag) - -message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)") -set(CMAKE_VERBOSE_MAKEFILE 1) - -macro(TEST_FAIL value msg) - if (${value}) - message (SEND_ERROR "Test fail:" ${msg} ${Out} ) - endif () -endmacro() - -macro(TEST_PASS value msg) - if (NOT ${value}) - message (SEND_ERROR "Test fail:" ${msg} ${Out} ) - endif () -endmacro() - -if(CMAKE_COMPILER_IS_GNUCXX) - exec_program(${CMAKE_C_COMPILER} ARGS --version OUTPUT_VARIABLE _gcc_version_info) - string (REGEX MATCH "[345]\\.[0-9]\\.[0-9]" _gcc_version "${_gcc_version_info}") - # gcc on mac just reports: "gcc (GCC) 3.3 20030304 ..." without the - # patch level, handle this here: - if(NOT _gcc_version) - string (REGEX REPLACE ".*\\(GCC\\).* ([34]\\.[0-9]) .*" "\\1.0" _gcc_version "${_gcc_version_info}") - endif() -endif() - -if(CMAKE_CXX_COMPILER_ID MATCHES Clang) - exec_program(${CMAKE_CXX_COMPILER} ARGS --version OUTPUT_VARIABLE _clang_version_info) - string (REGEX REPLACE ".*version ([0-9]\\.[0-9]).*" "\\1" _clang_version "${_clang_version_info}") -endif() - -if(CMAKE_CXX_COMPILER_ID MATCHES Intel) - exec_program(${CMAKE_CXX_COMPILER} ARGS -V OUTPUT_VARIABLE _intel_version_info) - string (REGEX REPLACE ".*Version ([0-9]+(\\.[0-9]+)+).*" "\\1" _intel_version "${_intel_version_info}") -endif() - -message("Platform:\n WIN32: ${WIN32}\n UNIX: ${UNIX}\n APPLE: ${APPLE}\n MINGW: ${MINGW}\n CYGWIN: ${CYGWIN}\n" - " MSVC: ${MSVC}\n MSVC60: ${MSVC60}\n MSVC70: ${MSVC70}\n MSVC71: ${MSVC71}\n MSVC80: ${MSVC80}\n MSVC90: ${MSVC90}\n MSVC10: ${MSVC10}\n" - " GCC: ${_gcc_version}\n" - " Clang: ${_clang_version}\n" - " Intel: ${_intel_version}\n" -) - -include(CheckCXXCompilerFlag) - -check_cxx_compiler_flag(-fvisibility=hidden HAS_HIDDEN_VISIBILITY) - -message("HAS_HIDDEN_VISIBILITY: ${HAS_HIDDEN_VISIBILITY}\n\nCOMPILE OUTPUT:\n${OUTPUT}") - -if(CMAKE_COMPILER_IS_GNUCXX) - if(NOT WIN32) -# test_pass(HAS_HIDDEN_VISIBILITY "GCC should support hidden visibility, but does not.") - endif() -else() - message("Unhandled Platform") -endif() - -# -# This is a no-op executable... If this test is going to fail, it fails during -# the configure step while cmake is configuring this CMakeLists.txt file... -# - -file(WRITE - "${CMAKE_CURRENT_BINARY_DIR}/main.cxx" - "int main() { return 0; } -" -) - -add_executable( - CheckCXXCompilerFlag - "${CMAKE_CURRENT_BINARY_DIR}/main.cxx" -) -- cgit v0.12