Fix C++14 requirement in CMakeLists.txt

This commit is contained in:
Stephen Seo 2018-05-21 19:23:25 +09:00
parent 08433bcb4e
commit 2411125003

View file

@ -24,24 +24,11 @@ target_include_directories(EntityComponentSystem INTERFACE ${CMAKE_CURRENT_SOURC
include_directories(${CMAKE_CURRENT_SOURCE_DIR}) include_directories(${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -Wextra -Wpedantic") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -D NDEBUG") set(CMAKE_CXX_FLAGS_RELEASE "-O3 -D NDEBUG")
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") target_compile_features(EntityComponentSystem INTERFACE cxx_std_14)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT (GCC_VERSION VERSION_GREATER 5.0 OR GCC_VERSION VERSION_EQUAL 5.0))
message(FATAL_ERROR "${PROJECT_NAME} requires g++ 5.0 or greater.")
endif ()
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE CLANG_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT (CLANG_VERSION VERSION_GREATER 3.4 OR CLANG_VERSION VERSION_EQUAL 3.4))
message(FATAL_ERROR "${PROJECT_NAME} requires clang 3.4 or greater.")
endif()
elseif(MSVC)
else()
message(FATAL_ERROR "Your C++ compiler does not support C++14.")
endif()
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Debug', none was specified.") message(STATUS "Setting build type to 'Debug', none was specified.")
@ -63,6 +50,7 @@ if(GTEST_FOUND)
add_executable(UnitTests ${UnitTests_SOURCES}) add_executable(UnitTests ${UnitTests_SOURCES})
target_link_libraries(UnitTests EntityComponentSystem ${GTEST_LIBRARIES}) target_link_libraries(UnitTests EntityComponentSystem ${GTEST_LIBRARIES})
target_include_directories(UnitTests PUBLIC ${GTEST_INCLUDE_DIR}) target_include_directories(UnitTests PUBLIC ${GTEST_INCLUDE_DIR})
target_compile_features(UnitTests PUBLIC cxx_std_14)
enable_testing() enable_testing()
add_test(NAME UnitTests COMMAND UnitTests) add_test(NAME UnitTests COMMAND UnitTests)