From 7b2d529bdef9f6a5fa2bc3665a6b88cf52b110e1 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 8 May 2017 10:26:36 -0400 Subject: cmBase32: Cast pointer subtraction result to size explicitly The SunPro 5.13 compiler with `-std=c++11` complains otherwise. --- Source/cmBase32.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmBase32.cxx b/Source/cmBase32.cxx index 091d619..1dac212 100644 --- a/Source/cmBase32.cxx +++ b/Source/cmBase32.cxx @@ -58,7 +58,7 @@ std::string cmBase32Encoder::encodeString(const unsigned char* input, input += blockSize; } - size_t remain(end - input); + size_t remain = static_cast(end - input); if (remain != 0) { // Temporary source buffer filled up with 0s unsigned char extended[blockSize]; -- cgit v0.12 From 86edc5b6a5f9ef74d8807a6b90d209cce4e3a2d7 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 8 May 2017 10:26:48 -0400 Subject: Choose compiler-specific flags earlier in CMake's own build Add the flags early enough be used in the checks for C++ features. --- CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4dcf2f0..6b88538 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,6 +63,10 @@ if(NOT DEFINED CMAKE_CXX_STANDARD AND NOT CMake_NO_CXX_STANDARD) endif() endif() if(NOT CMake_TEST_EXTERNAL_CMAKE) + # include special compile flags for some compilers + include(CompileFlags.cmake) + + # check for available C++ features include(${CMake_SOURCE_DIR}/Source/Checks/cm_cxx_features.cmake) endif() @@ -648,9 +652,6 @@ if(NOT CMake_TEST_EXTERNAL_CMAKE) include(${CMake_SOURCE_DIR}/Tests/CMakeInstall.cmake) endif() - # include special compile flags for some compilers - include(CompileFlags.cmake) - # no clue why we are testing for this here include(CheckSymbolExists) CHECK_SYMBOL_EXISTS(unsetenv "stdlib.h" HAVE_UNSETENV) -- cgit v0.12 From 2731a91c98ad8b48aaecc2fa3039cc9601d48fbc Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 8 May 2017 10:26:54 -0400 Subject: Update SunPro flags used for CMake itself to support C++11 --- CMakeLists.txt | 12 ++++++++---- CompileFlags.cmake | 9 ++++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b88538..eb46c3b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,11 +55,15 @@ if(NOT DEFINED CMAKE_C_STANDARD AND NOT CMake_NO_C_STANDARD) endif() endif() if(NOT DEFINED CMAKE_CXX_STANDARD AND NOT CMake_NO_CXX_STANDARD) - include(${CMake_SOURCE_DIR}/Source/Checks/cm_cxx14_cstdio.cmake) - if(NOT CMake_CXX14_CSTDIO_BROKEN) - set(CMAKE_CXX_STANDARD 14) + if (CMAKE_CXX_COMPILER_ID STREQUAL SunPro AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.14) + set(CMAKE_CXX_STANDARD 98) else() - set(CMAKE_CXX_STANDARD 11) + include(${CMake_SOURCE_DIR}/Source/Checks/cm_cxx14_cstdio.cmake) + if(NOT CMake_CXX14_CSTDIO_BROKEN) + set(CMAKE_CXX_STANDARD 14) + else() + set(CMAKE_CXX_STANDARD 11) + endif() endif() endif() if(NOT CMake_TEST_EXTERNAL_CMAKE) diff --git a/CompileFlags.cmake b/CompileFlags.cmake index d70e3af..d1f4f13 100644 --- a/CompileFlags.cmake +++ b/CompileFlags.cmake @@ -61,7 +61,14 @@ endif() if (CMAKE_CXX_COMPILER_ID STREQUAL SunPro) if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++03") + if (NOT CMAKE_CXX_STANDARD OR CMAKE_CXX_STANDARD EQUAL 98) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++03") + elseif(CMAKE_VERSION VERSION_LESS 3.8.20170502) + # CMake knows how to add this flag for compilation as C++11, + # but has not been taught that SunPro needs it for linking too. + # Add it in a place that will be used for both. + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + endif() else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -library=stlport4") endif() -- cgit v0.12