2019-03-21 06:25:17 +00:00
|
|
|
include(CheckCXXCompilerFlag)
|
|
|
|
|
|
|
|
include_directories(3rdparty/Catch2)
|
2018-04-04 16:36:18 +00:00
|
|
|
include_directories(${CMAKE_SOURCE_DIR}/include)
|
2018-03-26 12:02:43 +00:00
|
|
|
|
2019-03-12 13:55:56 +00:00
|
|
|
set(SOURCES test.cpp)
|
|
|
|
|
2018-08-29 11:57:44 +00:00
|
|
|
set(OPTIONS "")
|
|
|
|
|
|
|
|
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
|
|
|
set(OPTIONS /W4)
|
|
|
|
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.11)
|
|
|
|
set(OPTIONS ${OPTIONS} /permissive-)
|
|
|
|
endif()
|
2019-03-12 13:55:56 +00:00
|
|
|
set(OPTIONS ${OPTIONS} /wd4702) # Disable warning C4702: unreachable code
|
2019-03-21 06:25:17 +00:00
|
|
|
|
|
|
|
set(HAS_CPP11_FLAG TRUE)
|
|
|
|
check_cxx_compiler_flag(/std:c++14 HAS_CPP14_FLAG)
|
|
|
|
check_cxx_compiler_flag(/std:c++17 HAS_CPP17_FLAG)
|
|
|
|
check_cxx_compiler_flag(/std:c++20 HAS_CPP20_FLAG)
|
|
|
|
check_cxx_compiler_flag(/std:c++latest HAS_CPPLATEST_FLAG)
|
2018-08-29 11:57:44 +00:00
|
|
|
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
|
|
|
set(CMAKE_VERBOSE_MAKEFILE ON)
|
|
|
|
set(OPTIONS -Wall -Wextra -pedantic-errors)
|
|
|
|
|
2019-03-21 06:25:17 +00:00
|
|
|
check_cxx_compiler_flag(-std=c++11 HAS_CPP11_FLAG)
|
|
|
|
check_cxx_compiler_flag(-std=c++14 HAS_CPP14_FLAG)
|
|
|
|
check_cxx_compiler_flag(-std=c++17 HAS_CPP17_FLAG)
|
|
|
|
check_cxx_compiler_flag(-std=c++20 HAS_CPP20_FLAG)
|
2018-08-29 11:57:44 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
function(make_target target std)
|
|
|
|
add_executable(${target} ${SOURCES})
|
|
|
|
target_compile_options(${target} PRIVATE ${OPTIONS})
|
|
|
|
if(std)
|
|
|
|
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
|
|
|
target_compile_options(${target} PRIVATE /std:${std})
|
|
|
|
else()
|
|
|
|
target_compile_options(${target} PRIVATE -std=${std})
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
if(HAS_CPP17_FLAG)
|
2019-03-21 06:25:17 +00:00
|
|
|
make_target(${CMAKE_PROJECT_NAME}-cpp17.t c++17)
|
2019-03-12 13:55:56 +00:00
|
|
|
add_test(NAME ${CMAKE_PROJECT_NAME}-cpp17.t COMMAND ${CMAKE_PROJECT_NAME}-cpp17.t)
|
2018-08-29 11:57:44 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(HAS_CPPLATEST_FLAG)
|
2019-03-12 13:55:56 +00:00
|
|
|
make_target(${CMAKE_PROJECT_NAME}-cpplatest.t c++latest)
|
|
|
|
add_test(NAME ${CMAKE_PROJECT_NAME}-cpplatest.t COMMAND ${CMAKE_PROJECT_NAME}-cpplatest.t)
|
2018-08-29 11:57:44 +00:00
|
|
|
endif()
|