mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-13 10:32:57 +01:00
add CXX1x compiler capability detection to cmake
This commit is contained in:
parent
76c5bf8dc7
commit
dea76c8e2e
@ -24,6 +24,7 @@ string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" CPACK_PACKAGE_VERSION_
|
||||
set(COMPLETE_VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
|
||||
set(RELEASE_NAME "Unstable-trunk")
|
||||
set(PROJECT_VERSION ${COMPLETE_VERSION})
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
|
||||
# Put the libaries and binaries that get built into directories at the
|
||||
# top of the build tree rather than in hard-to-find leaf
|
||||
@ -43,6 +44,33 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
||||
# Setup C/C++ compiler options
|
||||
#################################################################################
|
||||
|
||||
option(DISABLE_CPP11 "Disable C++11 if available" OFF)
|
||||
option(DISABLE_CPP14 "Disable C++14 if available" OFF)
|
||||
|
||||
if (DISABLE_CPP11 OR DISABLE_CPP14)
|
||||
add_definitions(-DPOCO_DISABLE_CPP11)
|
||||
|
||||
if (DISABLE_CPP14)
|
||||
add_definitions(-DPOCO_DISABLE_CPP14)
|
||||
endif()
|
||||
else()
|
||||
# C++11/14 compiler flags
|
||||
include(CXX1x)
|
||||
check_for_cxx11_compiler(CXX11_COMPILER)
|
||||
|
||||
# If a C++11 compiler is available, then set the appropriate flags
|
||||
if(CXX11_COMPILER)
|
||||
enable_cxx11()
|
||||
check_for_cxx14_compiler(CXX14_COMPILER)
|
||||
|
||||
# If a C++14 compiler is available, then set the appropriate flags
|
||||
if(CXX14_COMPILER)
|
||||
enable_cxx14()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
if(NOT MSVC_IDE)
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
|
||||
|
61
cmake/CXX1x.cmake
Normal file
61
cmake/CXX1x.cmake
Normal file
@ -0,0 +1,61 @@
|
||||
# Copyright (c) 2013 Nathan Osman
|
||||
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
|
||||
# Determines whether or not the compiler supports C++11
|
||||
macro(check_for_cxx11_compiler _VAR)
|
||||
message(STATUS "Checking for C++11 compiler")
|
||||
set(${_VAR})
|
||||
if((MSVC AND (MSVC10 OR MSVC11 OR MSVC12 OR MSVC14)) OR
|
||||
(CMAKE_COMPILER_IS_GNUCXX AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 4.6) OR
|
||||
(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 3.1) OR
|
||||
(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"))
|
||||
set(${_VAR} 1)
|
||||
message(STATUS "Checking for C++11 compiler - available")
|
||||
else()
|
||||
message(STATUS "Checking for C++11 compiler - unavailable")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# Sets the appropriate flag to enable C++11 support
|
||||
macro(enable_cxx11)
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
set (CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
endmacro()
|
||||
|
||||
# Determines whether or not the compiler supports C++11
|
||||
macro(check_for_cxx14_compiler _VAR)
|
||||
message(STATUS "Checking for C++14 compiler")
|
||||
set(${_VAR})
|
||||
if((MSVC AND (MSVC14)) OR
|
||||
(CMAKE_COMPILER_IS_GNUCXX AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 4.7) OR
|
||||
(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 3.4) OR
|
||||
(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"))
|
||||
set(${_VAR} 1)
|
||||
message(STATUS "Checking for C++14 compiler - available")
|
||||
else()
|
||||
message(STATUS "Checking for C++14 compiler - unavailable")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# Sets the appropriate flag to enable C++14 support
|
||||
macro(enable_cxx14)
|
||||
set (CMAKE_CXX_STANDARD 14)
|
||||
set (CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
endmacro()
|
Loading…
Reference in New Issue
Block a user