From 61bc0f7363ca2917707d57fefb52b79b0114bb19 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 29 Sep 2015 11:22:50 -0400 Subject: [PATCH 1/3] Features: Disable support for Oracle SolarisStudio on non-Linux On SunOS the -std=c++11 flag must be used for linking as well as compiling. Until we implement support for this we cannot support the CXX_STANDARD property except on Linux (where it was tested). --- Help/manual/cmake-compile-features.7.rst | 2 +- Modules/Compiler/SunPro-CXX.cmake | 30 ++++++++++++++---------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/Help/manual/cmake-compile-features.7.rst b/Help/manual/cmake-compile-features.7.rst index caf5bac2a..2dc67bcf9 100644 --- a/Help/manual/cmake-compile-features.7.rst +++ b/Help/manual/cmake-compile-features.7.rst @@ -308,4 +308,4 @@ versions specified for each: * ``Clang``: Clang compiler versions 2.9 through 3.4. * ``GNU``: GNU compiler versions 4.4 through 5.0. * ``MSVC``: Microsoft Visual Studio versions 2010 through 2015. -* ``SunPro``: Oracle SolarisStudio version 12.4. +* ``SunPro``: Oracle SolarisStudio version 12.4 on a Linux host. diff --git a/Modules/Compiler/SunPro-CXX.cmake b/Modules/Compiler/SunPro-CXX.cmake index 50d68eebf..dccc25e35 100644 --- a/Modules/Compiler/SunPro-CXX.cmake +++ b/Modules/Compiler/SunPro-CXX.cmake @@ -31,17 +31,19 @@ set(CMAKE_CXX_CREATE_STATIC_LIBRARY " -xar -o " " ") -if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13) - set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11") - set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=c++11") -endif() +if (CMAKE_SYSTEM_NAME STREQUAL Linux) + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13) + set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11") + set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=c++11") + endif() -if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13) - if (NOT CMAKE_CXX_COMPILER_FORCED) - if (NOT CMAKE_CXX_STANDARD_COMPUTED_DEFAULT) - message(FATAL_ERROR "CMAKE_CXX_STANDARD_COMPUTED_DEFAULT should be set for ${CMAKE_CXX_COMPILER_ID} (${CMAKE_CXX_COMPILER}) version ${CMAKE_CXX_COMPILER_VERSION}") + if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13) + if (NOT CMAKE_CXX_COMPILER_FORCED) + if (NOT CMAKE_CXX_STANDARD_COMPUTED_DEFAULT) + message(FATAL_ERROR "CMAKE_CXX_STANDARD_COMPUTED_DEFAULT should be set for ${CMAKE_CXX_COMPILER_ID} (${CMAKE_CXX_COMPILER}) version ${CMAKE_CXX_COMPILER_VERSION}") + endif() + set(CMAKE_CXX_STANDARD_DEFAULT ${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT}) endif() - set(CMAKE_CXX_STANDARD_DEFAULT ${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT}) endif() endif() @@ -51,10 +53,12 @@ macro(cmake_record_cxx_compile_features) endmacro() set(_result 0) - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13) - _get_solaris_studio_features(${CMAKE_CXX11_STANDARD_COMPILE_OPTION} CMAKE_CXX11_COMPILE_FEATURES) - if (_result EQUAL 0) - _get_solaris_studio_features("" CMAKE_CXX98_COMPILE_FEATURES) + if (CMAKE_SYSTEM_NAME STREQUAL Linux) + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13) + _get_solaris_studio_features(${CMAKE_CXX11_STANDARD_COMPILE_OPTION} CMAKE_CXX11_COMPILE_FEATURES) + if (_result EQUAL 0) + _get_solaris_studio_features("" CMAKE_CXX98_COMPILE_FEATURES) + endif() endif() endif() endmacro() From c824b23d15b92247f3527f1b884c23d34e6749b5 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 30 Sep 2015 09:46:49 -0400 Subject: [PATCH 2/3] Features: Fix C++98 flags on Oracle SolarisStudio 12.4 on Linux --- Modules/Compiler/SunPro-CXX.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Modules/Compiler/SunPro-CXX.cmake b/Modules/Compiler/SunPro-CXX.cmake index dccc25e35..0e936cad0 100644 --- a/Modules/Compiler/SunPro-CXX.cmake +++ b/Modules/Compiler/SunPro-CXX.cmake @@ -33,6 +33,8 @@ set(CMAKE_CXX_CREATE_STATIC_LIBRARY if (CMAKE_SYSTEM_NAME STREQUAL Linux) if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13) + set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++03") + set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=c++03") set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11") set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=c++11") endif() From 5fdf75947822bc17d30a9e60022a4fc77b4cdf63 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 30 Sep 2015 09:53:52 -0400 Subject: [PATCH 3/3] Tests: Suppress WriteCompilerDetectionHeader failure on SunPro We do support SunPro 5.13 compiler features, but only on Linux. Suppress the portion of the test that fails on Solaris until the larger problem can be addressed. --- Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt index c53828074..ffee035a3 100644 --- a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt +++ b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt @@ -25,7 +25,8 @@ if (NOT CMAKE_CXX_COMPILE_FEATURES AND NOT CMAKE_C_COMPILE_FEATURES) ) add_executable(WriteCompilerDetectionHeader "${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp") - if(UNIX OR NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + if((UNIX OR NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + AND NOT CMAKE_CXX_COMPILER_ID STREQUAL "SunPro") include(CheckCXXSourceCompiles) check_cxx_source_compiles("#include \"${CMAKE_CURRENT_BINARY_DIR}/test_compiler_detection.h\"\nint main() { return 0; }\n" file_include_works