mirror of
https://github.com/UltraCoderRU/telebotxx.git
synced 2026-01-28 04:05:13 +00:00
Added CMake function RequireCXX14().
Fixed double compiler flags.
This commit is contained in:
parent
f635883351
commit
f995e59423
4 changed files with 34 additions and 23 deletions
|
|
@ -1,34 +1,13 @@
|
||||||
cmake_minimum_required(VERSION 2.8)
|
cmake_minimum_required(VERSION 2.8)
|
||||||
|
|
||||||
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} cmake)
|
||||||
|
|
||||||
if (NOT DEFINED CMAKE_BUILD_TYPE)
|
if (NOT DEFINED CMAKE_BUILD_TYPE)
|
||||||
set(CMAKE_BUILD_TYPE Release CACHE STRING "Type of build (Release, Debug, RelWithDebInfo, MinSizeRel)")
|
set(CMAKE_BUILD_TYPE Release CACHE STRING "Type of build (Release, Debug, RelWithDebInfo, MinSizeRel)")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
project(telebotxx CXX)
|
project(telebotxx CXX)
|
||||||
|
|
||||||
message(STATUS "Checking compiler flags for C++14 support.")
|
|
||||||
# Set C++14 support flags for various compilers
|
|
||||||
include(CheckCXXCompilerFlag)
|
|
||||||
check_cxx_compiler_flag("-std=c++14" COMPILER_SUPPORTS_CXX14)
|
|
||||||
check_cxx_compiler_flag("-std=c++1y" COMPILER_SUPPORTS_CXX1Y)
|
|
||||||
if(COMPILER_SUPPORTS_CXX14)
|
|
||||||
message(STATUS "C++14 is supported.")
|
|
||||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -stdlib=libc++")
|
|
||||||
else()
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
|
|
||||||
endif()
|
|
||||||
elseif(COMPILER_SUPPORTS_CXX1Y)
|
|
||||||
message(STATUS "C++1y is supported.")
|
|
||||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -stdlib=libc++")
|
|
||||||
else()
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y")
|
|
||||||
endif()
|
|
||||||
else()
|
|
||||||
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++14 support. Please use a different C++ compiler.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
option (TELEBOTXX_BUILD_TESTS "Build unit tests using Boost.Test" ON)
|
option (TELEBOTXX_BUILD_TESTS "Build unit tests using Boost.Test" ON)
|
||||||
option (TELEBOTXX_GENERATE_DOC "Generate API documentation with Doxygen" ON)
|
option (TELEBOTXX_GENERATE_DOC "Generate API documentation with Doxygen" ON)
|
||||||
|
|
||||||
|
|
|
||||||
26
cmake/RequireCXX14.cmake
Normal file
26
cmake/RequireCXX14.cmake
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
cmake_minimum_required(VERSION 2.8)
|
||||||
|
|
||||||
|
function(RequireCXX14)
|
||||||
|
message(STATUS "Checking compiler flags for C++14 support.")
|
||||||
|
# Set C++14 support flags for various compilers
|
||||||
|
include(CheckCXXCompilerFlag)
|
||||||
|
check_cxx_compiler_flag("-std=c++14" COMPILER_SUPPORTS_CXX14)
|
||||||
|
check_cxx_compiler_flag("-std=c++1y" COMPILER_SUPPORTS_CXX1Y)
|
||||||
|
if(COMPILER_SUPPORTS_CXX14)
|
||||||
|
message(STATUS "C++14 is supported.")
|
||||||
|
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -stdlib=libc++" PARENT_SCOPE)
|
||||||
|
else()
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14" PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
elseif(COMPILER_SUPPORTS_CXX1Y)
|
||||||
|
message(STATUS "C++1y is supported.")
|
||||||
|
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -stdlib=libc++" PARENT_SCOPE)
|
||||||
|
else()
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y" PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
message(ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++14 support. Please use a different C++ compiler.")
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
@ -2,6 +2,9 @@ cmake_minimum_required(VERSION 2.8)
|
||||||
|
|
||||||
message(STATUS "Configuring telebotxx")
|
message(STATUS "Configuring telebotxx")
|
||||||
|
|
||||||
|
include(${CMAKE_SOURCE_DIR}/cmake/RequireCXX14.cmake)
|
||||||
|
RequireCXX14()
|
||||||
|
|
||||||
find_package(Boost REQUIRED)
|
find_package(Boost REQUIRED)
|
||||||
include_directories(${Boost_INCLUDE_DIRS})
|
include_directories(${Boost_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,9 @@ endif()
|
||||||
|
|
||||||
message(STATUS "Configuring telebotxx-test")
|
message(STATUS "Configuring telebotxx-test")
|
||||||
|
|
||||||
|
include(${CMAKE_SOURCE_DIR}/cmake/RequireCXX14.cmake)
|
||||||
|
RequireCXX14()
|
||||||
|
|
||||||
add_definitions(-DBOOST_TEST_DYN_LINK)
|
add_definitions(-DBOOST_TEST_DYN_LINK)
|
||||||
find_package(Boost REQUIRED COMPONENTS unit_test_framework system)
|
find_package(Boost REQUIRED COMPONENTS unit_test_framework system)
|
||||||
include_directories(${Boost_INCLUDE_DIRS})
|
include_directories(${Boost_INCLUDE_DIRS})
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue