mirror of
https://github.com/Neargye/magic_enum.git
synced 2026-01-09 23:34:23 +00:00
update cmake
This commit is contained in:
parent
91b36336cb
commit
a2bb347f05
3 changed files with 11 additions and 20 deletions
|
|
@ -1,27 +1,16 @@
|
|||
include(CheckCXXCompilerFlag)
|
||||
|
||||
if((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
|
||||
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(CMAKE_VERBOSE_MAKEFILE ON)
|
||||
set(OPTIONS -Wall -Wextra -pedantic-errors -Werror -std=c++17)
|
||||
set(OPTIONS -Wall -Wextra -pedantic-errors -Werror)
|
||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
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)
|
||||
set(OPTIONS /W4 /WX)
|
||||
if(HAS_PERMISSIVE_FLAG)
|
||||
set(OPTIONS ${OPTIONS} /permissive-)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_executable(example
|
||||
example.cpp
|
||||
${CMAKE_SOURCE_DIR}/include/${CMAKE_PROJECT_NAME}.hpp)
|
||||
add_executable(example example.cpp)
|
||||
set_target_properties(example PROPERTIES CXX_EXTENSIONS OFF)
|
||||
target_compile_features(example PRIVATE cxx_std_17)
|
||||
target_compile_options(example PRIVATE ${OPTIONS})
|
||||
target_link_libraries(example PRIVATE ${CMAKE_PROJECT_NAME})
|
||||
|
|
|
|||
|
|
@ -9,14 +9,12 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
|||
set(OPTIONS ${OPTIONS} /permissive-)
|
||||
endif()
|
||||
|
||||
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)
|
||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
||||
set(CMAKE_VERBOSE_MAKEFILE ON)
|
||||
set(OPTIONS -Wall -Wextra -pedantic-errors -Werror)
|
||||
|
||||
check_cxx_compiler_flag(-std=c++17 HAS_CPP17_FLAG)
|
||||
check_cxx_compiler_flag(-std=c++20 HAS_CPP20_FLAG)
|
||||
endif()
|
||||
|
||||
|
|
@ -25,6 +23,7 @@ function(make_test target std)
|
|||
target_compile_options(${target} PRIVATE ${OPTIONS})
|
||||
target_include_directories(${target} PRIVATE 3rdparty/Catch2)
|
||||
target_link_libraries(${target} PRIVATE ${CMAKE_PROJECT_NAME})
|
||||
set_target_properties(${target} PROPERTIES CXX_EXTENSIONS OFF)
|
||||
if(std)
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
target_compile_options(${target} PRIVATE /std:${std})
|
||||
|
|
@ -35,8 +34,10 @@ function(make_test target std)
|
|||
add_test(NAME ${target} COMMAND ${target})
|
||||
endfunction()
|
||||
|
||||
if(HAS_CPP17_FLAG)
|
||||
make_test(${CMAKE_PROJECT_NAME}-cpp17.t c++17)
|
||||
make_test(${CMAKE_PROJECT_NAME}-cpp17.t c++17)
|
||||
|
||||
if(HAS_CPP20_FLAG)
|
||||
make_test(${CMAKE_PROJECT_NAME}-cpp20.t c++20)
|
||||
endif()
|
||||
|
||||
if(HAS_CPPLATEST_FLAG)
|
||||
|
|
|
|||
|
|
@ -6,4 +6,5 @@ conan_basic_setup(TARGETS)
|
|||
|
||||
add_executable(test_package test_package.cpp)
|
||||
target_link_libraries(test_package PRIVATE CONAN_PKG::magic_enum)
|
||||
set_target_properties(example PROPERTIES CXX_EXTENSIONS OFF)
|
||||
target_compile_features(test_package PRIVATE cxx_std_17)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue