diff options
author | Johnathan Corgan <johnathan@corganlabs.com> | 2017-09-21 11:22:16 -0700 |
---|---|---|
committer | Johnathan Corgan <johnathan@corganlabs.com> | 2017-09-21 11:22:16 -0700 |
commit | bd7196f084593e7aa92e48ffac3c5a06cb3c4f2c (patch) | |
tree | bcd540bed070e3407ab93c070b8bb48f0e6f3d38 | |
parent | b014fb6e26d9a363870b477dccc9dfafd890eac0 (diff) | |
parent | d885776952e6b1177d71be8f65b1979a7f87620d (diff) |
Merge branch 'next' into python3
-rw-r--r-- | CMakeLists.txt | 58 | ||||
-rw-r--r-- | cmake/Modules/FindCppUnit.cmake | 7 |
2 files changed, 44 insertions, 21 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 98ad5ec3b0..4e5cf18954 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -131,30 +131,33 @@ ELSE() MESSAGE(status "Skipping compiler version check.") ENDIF() -# Configure C++ and C standards -IF(CMAKE_VERSION VERSION_LESS "3.1") - IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - ELSE() - MESSAGE(warning "C++ standard could not be set because compiler is not GNU, Clang or MSVC.") - ENDIF() +# Configure C++ standard if not externally specified (will actually be +# set after CppUnit check below). Use the variable CMAKE_CXX_STANDARD +# since it will actually be used for this purposes starting in CMake 3.1. - IF(CMAKE_C_COMPILER_ID STREQUAL "GNU") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99") - ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "Clang") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99") - ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "MSVC") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11") - ELSE() - MESSAGE(warning "C standard could not be set because compiler is not GNU, Clang or MSVC.") - ENDIF() +IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + SET(CMAKE_CXX_STANDARD 98) +ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + SET(CMAKE_CXX_STANDARD 98) +ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + SET(CMAKE_CXX_STANDARD 98) ELSE() + message(warning "C++ standard could not be set because compiler is not GNU, Clang or MSVC.") +ENDIF() + +IF(CMAKE_C_COMPILER_ID STREQUAL "GNU") SET(CMAKE_C_STANDARD 99) - SET(CMAKE_CXX_STANDARD 11) +ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "Clang") + SET(CMAKE_C_STANDARD 99) +ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "MSVC") + SET(CMAKE_C_STANDARD 11) +ELSE() + message(warning "C standard could not be set because compiler is not GNU, Clang or MSVC.") +ENDIF() + +# if cmake version is < 3.1, explicitly set C standard to use. +IF(${CMAKE_VERSION} VERSION_LESS "3.1") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c${CMAKE_C_STANDARD}") ENDIF() ######################################################################## @@ -371,6 +374,19 @@ GR_REGISTER_COMPONENT("testing-support" ENABLE_TESTING CPPUNIT_FOUND ) +# check if CppUnit version is 1.14.0 or greater; requires c++11 ... + +if(CPPUNIT_FOUND AND NOT "${CPPUNIT_VERSION}" VERSION_LESS "1.14.0") + message(WARNING "\nWarning: CppUnit version is ${CPPUNIT_VERSION} which requires C++11 for building. Trying to set CMake internally to use C++11 ...") + SET(CMAKE_CXX_STANDARD 11) +endif() + +# if cmake version is < 3.1, explicitly set C++ standard to use. + +if(${CMAKE_VERSION} VERSION_LESS "3.1") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++${CMAKE_CXX_STANDARD}") +endif() + if(${CMAKE_BUILD_TYPE} STREQUAL "Coverage") include(CodeCoverage) setup_target_for_coverage(coverage "ctest" coverage) diff --git a/cmake/Modules/FindCppUnit.cmake b/cmake/Modules/FindCppUnit.cmake index f93ade3412..4e9469f9f6 100644 --- a/cmake/Modules/FindCppUnit.cmake +++ b/cmake/Modules/FindCppUnit.cmake @@ -37,3 +37,10 @@ LIST(APPEND CPPUNIT_LIBRARIES ${CMAKE_DL_LIBS}) INCLUDE(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(CPPUNIT DEFAULT_MSG CPPUNIT_LIBRARIES CPPUNIT_INCLUDE_DIRS) MARK_AS_ADVANCED(CPPUNIT_LIBRARIES CPPUNIT_INCLUDE_DIRS) + + +# set version to be useable by calling script + +IF(CPPUNIT_FOUND) + set(CPPUNIT_VERSION ${PC_CPPUNIT_VERSION} CACHE INTERNAL "CppUnit Version" FORCE) +ENDIF() |