2018-08-29 11:57:44 +00:00
|
|
|
set(SOURCES test.cpp)
|
|
|
|
|
|
|
|
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
|
|
|
|
2018-08-29 11:57:44 +00:00
|
|
|
set(OPTIONS "")
|
|
|
|
|
|
|
|
set(HAS_CPP11_FLAG FALSE)
|
|
|
|
set(HAS_CPP14_FLAG FALSE)
|
|
|
|
set(HAS_CPP17_FLAG FALSE)
|
|
|
|
set(HAS_CPP20_FLAG FALSE)
|
|
|
|
set(HAS_CPPLATEST_FLAG FALSE)
|
|
|
|
|
|
|
|
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
|
|
|
set(OPTIONS /W4)
|
|
|
|
|
|
|
|
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.00)
|
|
|
|
set(HAS_CPP14_FLAG TRUE)
|
|
|
|
set(HAS_CPPLATEST_FLAG TRUE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.11)
|
|
|
|
set(HAS_CPP17_FLAG TRUE)
|
|
|
|
set(OPTIONS ${OPTIONS} /permissive-)
|
|
|
|
endif()
|
|
|
|
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
|
|
|
set(CMAKE_VERBOSE_MAKEFILE ON)
|
|
|
|
set(OPTIONS -Wall -Wextra -pedantic-errors)
|
|
|
|
|
|
|
|
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
|
|
|
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8.0)
|
|
|
|
set(HAS_CPP11_FLAG TRUE)
|
|
|
|
endif()
|
|
|
|
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9.2)
|
|
|
|
set(HAS_CPP14_FLAG TRUE)
|
|
|
|
endif()
|
|
|
|
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.1.0)
|
|
|
|
set(HAS_CPP17_FLAG TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|
|
|
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.3.0)
|
|
|
|
set(HAS_CPP11_FLAG TRUE)
|
|
|
|
endif()
|
|
|
|
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4.0)
|
|
|
|
set(HAS_CPP14_FLAG TRUE)
|
|
|
|
endif()
|
|
|
|
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0.0)
|
|
|
|
set(HAS_CPP17_FLAG TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
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_CPP11_FLAG)
|
|
|
|
make_target(nameof-cpp11.t c++11)
|
|
|
|
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
|
|
|
make_target(nameof-cpp11.t "")
|
|
|
|
endif()
|
2018-09-03 14:42:16 +00:00
|
|
|
add_test(NAME nameof-cpp11.t COMMAND nameof-cpp11.t)
|
2018-08-29 11:57:44 +00:00
|
|
|
|
|
|
|
if(HAS_CPP14_FLAG)
|
|
|
|
make_target(nameof-cpp14.t c++14)
|
2018-09-03 14:42:16 +00:00
|
|
|
add_test(NAME nameof-cpp14.t COMMAND nameof-cpp14.t)
|
2018-08-29 11:57:44 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(HAS_CPP17_FLAG)
|
|
|
|
set(std17 c++17)
|
|
|
|
if(CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
|
|
|
|
set(std17 c++1z)
|
|
|
|
endif()
|
|
|
|
make_target(nameof-cpp17.t ${std17})
|
2018-09-03 14:42:16 +00:00
|
|
|
add_test(NAME nameof-cpp17.t COMMAND nameof-cpp17.t)
|
2018-08-29 11:57:44 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(HAS_CPPLATEST_FLAG)
|
|
|
|
make_target(nameof-cpplatest.t c++latest)
|
2018-09-03 14:42:16 +00:00
|
|
|
add_test(NAME nameof-cpplatest.t COMMAND nameof-cpplatest.t)
|
2018-08-29 11:57:44 +00:00
|
|
|
endif()
|