-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
165 lines (150 loc) · 4.61 KB
/
CMakeLists.txt
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
cmake_minimum_required(VERSION 3.11.4) # for RHEL 8
# Let's place extra cmake scripts in /cmake directory
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# Use this command to update PFL.cmake from GitHub release page:
#[[
wget -O cmake/PFL.cmake https://github.com/black-desk/PFL.cmake/releases/latest/download/PFL.cmake
]]
include(PFL)
set(ENABLE_CPM YES)
if(CMAKE_VERSION VERSION_LESS "3.14")
set(ENABLE_CPM NO)
endif()
if(CPM_LOCAL_PACKAGES_ONLY)
set(ENABLE_CPM NO)
endif()
project(
errors
VERSION 0.6.4
DESCRIPTION ""
HOMEPAGE_URL "https://github.com/black-desk/errors"
LANGUAGES CXX)
# Use this command to update GitSemver.cmake from GitHub release page:
#[[
wget -O cmake/GitSemver.cmake https://github.com/black-desk/GitSemver.cmake/releases/latest/download/GitSemver.cmake
]]
include(GitSemver)
gitsemver(PROJECT_VERSION)
pfl_init()
option(errors_WITH_NLOHMANN_JSON "Build examples and tests with nlohmann_json"
${PROJECT_IS_TOP_LEVEL})
option(errors_WITH_TL_EXPECTED
"Build examples and tests with TartanLlama/expected"
${PROJECT_IS_TOP_LEVEL})
option(errors_GENERATE_DOCUMENTATION "Generate documentation"
${PROJECT_IS_TOP_LEVEL})
option(errors_COVERAGE "Link library with --coverage" OFF)
macro(cpm_add_dependencies)
if(errors_WITH_NLOHMANN_JSON)
CPMFindPackage(
NAME nlohmann_json
VERSION 3.5.0
URL "https://github.com/nlohmann/json/archive/refs/tags/v3.5.0.tar.gz"
EXCLUDE_FROM_ALL ON
OPTIONS "JSON_BuildTests OFF")
endif()
if(errors_WITH_TL_EXPECTED)
CPMFindPackage(
NAME tl-expected
VERSION 1.0.0
GITHUB_REPOSITORY TartanLlama/expected
GIT_TAG v1.1.0
EXCLUDE_FROM_ALL ON
OPTIONS "EXPECTED_BUILD_TESTS OFF")
if(NOT TARGET tl::expected)
add_library(tl::expected ALIAS tl-expected)
endif()
endif()
if(errors_ENABLE_TESTING)
CPMAddPackage(
NAME Catch2
GITHUB_REPOSITORY catchorg/Catch2
GIT_TAG v3.4.0
VERSION 3.4.0)
list(APPEND CMAKE_MODULE_PATH ${Catch2_SOURCE_DIR}/extras)
include(Catch)
endif()
endmacro()
# Use this command to update CPM.cmake from GitHub release page: wget -O
# cmake/CPM.cmake
# https://github.com/cpm-cmake/CPM.cmake/releases/latest/download/CPM.cmake
if(NOT ENABLE_CPM)
message(STATUS "CPM.cmake disabled.")
else()
include(CPM)
cpm_add_dependencies()
endif()
if(errors_COVERAGE)
set(COMPILE_OPTIONS INTERFACE --coverage)
set(LINK_OPTIONS INTERFACE --coverage)
endif()
pfl_add_library(
LIBRARY_TYPE
HEADER_ONLY
SOURCES
include/errors/config.hpp.in
include/errors/detail/interface.hpp
include/errors/error.hpp
include/errors/error_ptr.hpp
include/errors/errors.hpp
include/errors/impl/base_error.hpp
include/errors/impl/code_error.hpp
include/errors/impl/error_with_cause.hpp
include/errors/impl/error_without_cause.hpp
include/errors/impl/exception_error.hpp
include/errors/impl/runtime_error.hpp
include/errors/impl/system_error.hpp
include/errors/impl/wrap_error.hpp
include/errors/json.hpp
include/errors/make.hpp
include/errors/source_location.hpp
include/errors/utils.hpp
include/errors/version.hpp
include/errors/wrap.hpp
src/errors/config.cpp
src/errors/detail/interface.cpp
src/errors/error.cpp
src/errors/error_ptr.cpp
src/errors/errors.cpp
src/errors/impl/base_error.cpp
src/errors/impl/code_error.cpp
src/errors/impl/error_with_cause.cpp
src/errors/impl/error_without_cause.cpp
src/errors/impl/exception_error.cpp
src/errors/impl/runtime_error.cpp
src/errors/impl/system_error.cpp
src/errors/impl/wrap_error.cpp
src/errors/json.cpp
src/errors/make.cpp
src/errors/source_location.cpp
src/errors/utils.cpp
src/errors/version.cpp
src/errors/wrap.cpp
EXAMPLES
advanced-usage
basic-usage
customize-format-global
customize-format-local
use-with-expected
TESTS
errors-unit-tests
COMPILE_OPTIONS
${COMPILE_OPTIONS}
LINK_OPTIONS
${LINK_OPTIONS}
COMPILE_FEATURES
INTERFACE
cxx_std_17)
if(errors_GENERATE_DOCUMENTATION)
find_package(Doxygen REQUIRED COMPONENTS dot OPTIONAL_COMPONENTS mscgen dia)
set(DOXYGEN_STRIP_FROM_INC_PATH
"${PROJECT_SOURCE_DIR}/include;${PROJECT_BINARY_DIR}/include")
set(DOXYGEN_EXAMPLE_PATH "${PROJECT_SOURCE_DIR};${PROJECT_BINARY_DIR}")
doxygen_add_docs(
doxygen ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/src
${PROJECT_BINARY_DIR}/include ${PROJECT_BINARY_DIR}/src ALL
COMMENT "Generate documentation with doxygen")
set_target_properties(doxygen PROPERTIES DEPENDS errors::errors)
install(DIRECTORY ${PROJECT_BINARY_DIR}/html
DESTINATION share/doc/${PROJECT_NAME})
endif()