-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
62 lines (46 loc) · 1.88 KB
/
CMakeLists.txt
File metadata and controls
62 lines (46 loc) · 1.88 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
cmake_minimum_required(VERSION 3.7...3.23)
if(${CMAKE_VERSION} VERSION_LESS 3.12)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
endif()
# ---- Project ----
project(magic_enum_example LANGUAGES CXX)
option(MAGIC_ENUM_EXAMPLES "whether or not to build the examples" ON)
# ---- Fetch CPM ----
set(CPM_DOWNLOAD_VERSION 0.27.2)
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
message(STATUS "Downloading CPM.cmake v${CPM_DOWNLOAD_VERSION}")
file(DOWNLOAD https://github.com/TheLartians/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake ${CPM_DOWNLOAD_LOCATION})
endif()
include(${CPM_DOWNLOAD_LOCATION})
# ---- Add dependencies via CPM ----
# See https://github.com/TheLartians/CPM.cmake for details and examples
CPMAddPackage(
NAME magic_enum
GITHUB_REPOSITORY sthagen/magic_enum
GIT_TAG v0.7.3
)
CPMAddPackage(
NAME doctest
GITHUB_REPOSITORY sthagen/doctest
GIT_TAG 2020.12
)
# ---- Create binary ----
add_executable(magic_enum_test main.cpp)
target_link_libraries(magic_enum_test doctest magic_enum)
set_target_properties(magic_enum_test PROPERTIES CXX_STANDARD 17)
# ---- Enable testing ----
enable_testing()
add_test(magic_enum_example magic_enum_test)
# ---- Create the examples ----
message(STATUS "Note the fetched includes are taken from below: ${FETCHCONTENT_BASE_DIR}")
if (MAGIC_ENUM_EXAMPLES)
macro(magic_enum_examples EXAMPLENAME)
add_executable(${EXAMPLENAME} ${ARGN})
set_target_properties(${EXAMPLENAME} PROPERTIES FOLDER examples)
set_target_properties(${EXAMPLENAME} PROPERTIES CXX_STANDARD 17)
target_include_directories(${EXAMPLENAME} PUBLIC "${FETCHCONTENT_BASE_DIR}/magic_enum-src/include/")
add_test(NAME ${EXAMPLENAME} COMMAND ${EXAMPLENAME})
endmacro()
add_subdirectory(examples)
endif()