-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
86 lines (71 loc) · 3.94 KB
/
Copy pathCMakeLists.txt
File metadata and controls
86 lines (71 loc) · 3.94 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
cmake_minimum_required(VERSION 3.10)
if(TARGET DSResult)
return()
endif()
project(DSResult)
if(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
option(DS_BUILD_EXAMPLES "Build DSResult Examples" on)
else()
option(DS_BUILD_EXAMPLES "Build DSResult Examples" off)
endif()
set(DS_EXPECTED_BACKEND "TL" CACHE STRING "DSResult Expected Backend (TL,LITE,STD,CUSTOM)")
set_property(CACHE DS_EXPECTED_BACKEND PROPERTY STRINGS "TL"
"LITE"
"STD"
"CUSTOM")
option(DS_NO_PATH "Don't show file path for error trace" off)
option(DS_USE_DEBUG_BREAK "Break when an error with a message is created" off)
add_library(DSResult INTERFACE)
target_include_directories(DSResult INTERFACE "${CMAKE_CURRENT_LIST_DIR}/Include")
if(${DS_EXPECTED_BACKEND} STREQUAL "TL")
target_include_directories( DSResult INTERFACE
"${CMAKE_CURRENT_LIST_DIR}/External/expected/include")
target_compile_definitions(DSResult INTERFACE DS_USE_TL_EXPECTED=1)
elseif(${DS_EXPECTED_BACKEND} STREQUAL "LITE")
target_include_directories( ExpectedLiteExample INTERFACE
"${CMAKE_CURRENT_LIST_DIR}/External/expected-lite/include")
target_compile_definitions(DSResult INTERFACE DS_USE_EXPECTED_LITE=1)
elseif(${DS_EXPECTED_BACKEND} STREQUAL "STD")
target_compile_definitions(DSResult INTERFACE DS_USE_STD_EXPECTED=1)
elseif(${DS_EXPECTED_BACKEND} STREQUAL "CUSTOM")
target_compile_definitions(DSResult INTERFACE DS_USE_CUSTOM_EXPECTED=1)
else()
message(FATAL_ERROR "Invalid DS_EXPECTED_BACKEND option: ${DS_EXPECTED_BACKEND}")
endif()
if(${DS_NO_PATH})
target_compile_definitions(DSResult INTERFACE DS_NO_PATH=1)
else()
target_compile_definitions(DSResult INTERFACE DS_NO_PATH=0)
endif()
if(${DS_USE_DEBUG_BREAK})
target_compile_definitions(DSResult INTERFACE DS_USE_DEBUG_BREAK=1)
else()
target_compile_definitions(DSResult INTERFACE DS_USE_DEBUG_BREAK=0)
endif()
if(${DS_BUILD_EXAMPLES})
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(DS_EXAMPLE_COMPILE_FLAGS "/utf-8" "/WX" "/Wall" "/wd4820")
else()
set(DS_EXAMPLE_COMPILE_FLAGS "-Wall" "-Wextra" "-Wpedantic" "-Werror")
endif()
target_compile_options(DSResult INTERFACE "${DS_EXAMPLE_COMPILE_FLAGS}")
add_executable(TlExpectedExample "${CMAKE_CURRENT_LIST_DIR}/Examples/TlExpectedExample.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Examples/TryExamples.cpp")
set_property(TARGET TlExpectedExample PROPERTY CXX_STANDARD 11)
target_include_directories( TlExpectedExample PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/External/expected/include"
"${CMAKE_CURRENT_LIST_DIR}/Include")
target_compile_definitions(TlExpectedExample PRIVATE DS_USE_TL_EXPECTED=1)
add_executable(ExpectedLiteExample "${CMAKE_CURRENT_LIST_DIR}/Examples/ExpectedLiteExample.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Examples/TryExamples.cpp")
set_property(TARGET ExpectedLiteExample PROPERTY CXX_STANDARD 11)
target_include_directories( ExpectedLiteExample PUBLIC
"${CMAKE_CURRENT_LIST_DIR}/External/expected-lite/include"
"${CMAKE_CURRENT_LIST_DIR}/Include")
target_compile_definitions(ExpectedLiteExample PUBLIC DS_USE_EXPECTED_LITE=1)
add_executable(StdExpectedExample "${CMAKE_CURRENT_LIST_DIR}/Examples/StdExpectedExample.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Examples/TryExamples.cpp")
set_property(TARGET StdExpectedExample PROPERTY CXX_STANDARD 23)
target_include_directories(StdExpectedExample PRIVATE "${CMAKE_CURRENT_LIST_DIR}/Include")
target_compile_definitions(StdExpectedExample PRIVATE DS_USE_STD_EXPECTED=1)
endif()