-
Notifications
You must be signed in to change notification settings - Fork 561
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
41 lines (38 loc) · 1.55 KB
/
Copy pathCMakeLists.txt
File metadata and controls
41 lines (38 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
include(CheckCXXCompilerFlag)
if((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
set(OPTIONS -Wall -Wextra -Wshadow -pedantic-errors -Werror)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set(OPTIONS /W4 /WX)
check_cxx_compiler_flag(/permissive- HAS_PERMISSIVE_FLAG)
if(HAS_PERMISSIVE_FLAG)
set(OPTIONS ${OPTIONS} /permissive-)
endif()
endif()
function(make_example target)
add_executable(${target} ${target}.cpp)
set_target_properties(${target} PROPERTIES CXX_EXTENSIONS OFF)
target_compile_features(${target} PRIVATE cxx_std_17)
target_compile_options(${target} PRIVATE ${OPTIONS})
target_link_libraries(${target} PRIVATE magic_enum::magic_enum)
endfunction()
make_example(example)
make_example(enum_flag_example)
make_example(example_containers_array)
make_example(example_containers_bitset)
make_example(example_containers_set)
make_example(example_containers_set_lookup)
make_example(example_custom_name)
make_example(example_switch)
if(MAGIC_ENUM_OPT_ENABLE_NONASCII)
make_example(example_nonascii_name)
endif()
if(MAGIC_ENUM_USE_MODULES)
make_example(example_module_usage)
target_compile_features(example_module_usage PRIVATE cxx_std_20)
set_target_properties(example_module_usage PROPERTIES CXX_SCAN_FOR_MODULES ON)
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.30" AND
CMAKE_CXX_STANDARD IN_LIST CMAKE_CXX_COMPILER_IMPORT_STD AND
CMAKE_CXX_MODULE_STD)
target_compile_definitions(example_module_usage PRIVATE MAGIC_ENUM_TEST_IMPORT_STD)
endif()
endif()