2019-03-21 11:05:37 +00:00
|
|
|
include(CheckCXXCompilerFlag)
|
|
|
|
|
2018-08-29 11:57:44 +00:00
|
|
|
if((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
|
2019-05-25 16:17:06 +00:00
|
|
|
check_cxx_compiler_flag(-std=c++17 HAS_CPP17_FLAG)
|
|
|
|
if(!HAS_CPP17_FLAG)
|
|
|
|
MESSAGE(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++17 support.")
|
|
|
|
endif()
|
|
|
|
|
2018-08-29 11:57:44 +00:00
|
|
|
set(CMAKE_VERBOSE_MAKEFILE ON)
|
2019-05-25 16:17:06 +00:00
|
|
|
set(OPTIONS -Wall -Wextra -pedantic-errors -Werror -std=c++17)
|
2018-08-29 11:57:44 +00:00
|
|
|
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
2019-05-25 16:17:06 +00:00
|
|
|
check_cxx_compiler_flag(/std:c++17 HAS_CPP17_FLAG)
|
|
|
|
if(!HAS_CPP17_FLAG)
|
|
|
|
MESSAGE(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++17 support.")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(OPTIONS /W4 /WX /std:c++17)
|
2019-03-21 11:05:37 +00:00
|
|
|
if(HAS_PERMISSIVE_FLAG)
|
2019-03-12 13:55:56 +00:00
|
|
|
set(OPTIONS ${OPTIONS} /permissive-)
|
2018-08-29 11:57:44 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
2019-03-12 13:55:56 +00:00
|
|
|
|
|
|
|
add_executable(example
|
|
|
|
example.cpp
|
2019-04-23 13:18:39 +00:00
|
|
|
${CMAKE_SOURCE_DIR}/include/${CMAKE_PROJECT_NAME}.hpp)
|
2019-03-12 13:55:56 +00:00
|
|
|
target_compile_options(example PRIVATE ${OPTIONS})
|
2019-04-23 13:18:39 +00:00
|
|
|
target_link_libraries(example PRIVATE ${CMAKE_PROJECT_NAME})
|