diff options
author | Michael Dickens <michael.dickens@ettus.com> | 2016-03-02 11:59:28 -0500 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2016-03-04 17:43:03 -0800 |
commit | dc8cb7f40f2add8424a232bc190e428f53e13759 (patch) | |
tree | 3c810e7d9254ecbf5677b537db56658e8bd64146 | |
parent | fdc2abb088d3b1c7499c6b66591f436a855b3c77 (diff) | |
download | uhd-dc8cb7f40f2add8424a232bc190e428f53e13759.tar.gz uhd-dc8cb7f40f2add8424a232bc190e428f53e13759.tar.bz2 uhd-dc8cb7f40f2add8424a232bc190e428f53e13759.zip |
cmake: add compiler minimum version check for GNU and Clang.
-rw-r--r-- | host/CMakeLists.txt | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt index 46615bd19..412154fcd 100644 --- a/host/CMakeLists.txt +++ b/host/CMakeLists.txt @@ -31,6 +31,55 @@ ENABLE_TESTING() list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake/Modules) ######################################################################## +# Check Compiler Version +######################################################################## +# Full C++11 came with GCC 4.7. +SET(GCC_MIN_VERSION "4.4.0") +# for c++0x or c++11 support, require: +# Apple Clang >= 500 +# or +# Clang >= 3.3.0 +SET(CLANG_MIN_VERSION "3.3.0") +SET(APPLECLANG_MIN_VERSION "500") + +IF(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") + IF(DEFINED CMAKE_CXX_COMPILER_VERSION) + IF(${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS ${GCC_MIN_VERSION}) + MESSAGE(WARNING "\nThe compiler selected to build UHD (GCC version ${CMAKE_CXX_COMPILER_VERSION} : ${CMAKE_CXX_COMPILER}) is older than that officially supported (${GCC_MIN_VERSION} minimum). This build may or not work. We highly recommend using a more recent GCC version.") + ENDIF() + ELSE() + MESSAGE(WARNING "\nCannot determine the version of the compiler selected to build UHD (GCC : ${CMAKE_CXX_COMPILER}). This build may or not work. We highly recommend using GCC version ${GCC_MIN_VERSION} or more recent.") + ENDIF() +ELSEIF(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") + EXECUTE_PROCESS(COMMAND + ${CMAKE_CXX_COMPILER} -v + RESULT_VARIABLE res ERROR_VARIABLE err + ERROR_STRIP_TRAILING_WHITESPACE) + IF(${res} STREQUAL "0") + # output is in error stream + STRING(REGEX MATCH "^Apple.*" IS_APPLE ${err}) + IF("${IS_APPLE}" STREQUAL "") + SET(MIN_VERSION ${CLANG_MIN_VERSION}) + SET(APPLE_STR "") + # retrieve the compiler's version from it + STRING(REGEX MATCH "clang version [0-9.]+" CLANG_OTHER_VERSION ${err}) + STRING(REGEX MATCH "[0-9.]+" CLANG_VERSION ${CLANG_OTHER_VERSION}) + ELSE() + SET(MIN_VERSION ${APPLECLANG_MIN_VERSION}) + SET(APPLE_STR "Apple ") + # retrieve the compiler's version from it + STRING(REGEX MATCH "(clang-[0-9.]+)" CLANG_APPLE_VERSION ${err}) + STRING(REGEX MATCH "[0-9.]+" CLANG_VERSION ${CLANG_APPLE_VERSION}) + ENDIF() + IF(${CLANG_VERSION} VERSION_LESS "${MIN_VERSION}") + MESSAGE(WARNING "\nThe compiler selected to build UHD (${APPLE_STR}Clang version ${CLANG_VERSION} : ${CMAKE_CXX_COMPILER}) is older than that officially supported (${MIN_VERSION} minimum). This build may or not work. We highly recommend using Apple Clang version ${APPLECLANG_MIN_VERSION} or more recent, or Clang version ${CLANG_MIN_VERSION} or more recent.") + ENDIF() + ELSE() + MESSAGE(WARNING "\nCannot determine the version of the compiler selected to build UHD (${APPLE_STR}Clang : ${CMAKE_CXX_COMPILER}). This build may or not work. We highly recommend using Apple Clang version ${APPLECLANG_MIN_VERSION} or more recent, or Clang version ${CLANG_MIN_VERSION} or more recent.") + ENDIF() +ENDIF() + +######################################################################## # Packaging Variables ######################################################################## @@ -214,7 +263,7 @@ ENDIF(MSVC) SET(Boost_ADDITIONAL_VERSIONS "1.46.0" "1.46" "1.47.0" "1.47" "1.48.0" "1.48" "1.48.0" "1.49" "1.50.0" "1.50" "1.51.0" "1.51" "1.52.0" "1.52" "1.53.0" "1.53" "1.54.0" "1.54" "1.55.0" "1.55" - "1.56.0" "1.56" + "1.56.0" "1.56" "1.57" "1.57" "1.58" "1.59" "1.60" ) FIND_PACKAGE(Boost 1.46 COMPONENTS ${BOOST_REQUIRED_COMPONENTS}) |