-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
207 lines (178 loc) · 5.2 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
cmake_minimum_required(VERSION 3.15)
project(tangle VERSION 0.2.2 LANGUAGES CXX)
if (NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
message(STATUS "Building for C++${CMAKE_CXX_STANDARD}")
else()
message(STATUS "Building for C++${CMAKE_CXX_STANDARD} (set externally)")
endif()
set(TANGLE_SINGLE_LIB OFF CACHE BOOL "Create only one library")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(tangle_library)
if (NOT TARGET CURL::libcurl)
find_package(CURL REQUIRED CONFIG)
endif()
find_package(Python3 COMPONENTS Interpreter REQUIRED)
set(TANGLE_WALL_FLAGS ON CACHE BOOL "Compile with -Wall/-W4 warning levels")
if (TANGLE_WALL_FLAGS)
if (MSVC)
set(ADDITIONAL_WALL_FLAGS
/permissive-
/Zc:__cplusplus
/W4
/w14242
/w14254
/w14263
/w14265
/w14287
/we4289
/w14296
/w14311
/w14545
/w14546
/w14547
/w14549
/w14555
/w14619
/w14640
/w14826
/w14905
/w14906
/w14928
/w14946)
else()
set(ADDITIONAL_WALL_FLAGS
-Wall -Wextra
-Wnon-virtual-dtor
-Wold-style-cast
-Wcast-align
-Wunused
-Woverloaded-virtual
-Wpedantic
-Wconversion
-Wsign-conversion
-Wnull-dereference
-Wdouble-promotion
-Wformat=2
)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
list(APPEND ADDITIONAL_WALL_FLAGS -fcolor-diagnostics) # -Wlifetime
else()
list(APPEND ADDITIONAL_WALL_FLAGS
-fdiagnostics-color
-Wmisleading-indentation
-Wduplicated-cond
-Wduplicated-branches
-Wlogical-op
-Wuseless-cast
)
endif()
endif()
endif()
set(TANGLE_TESTING ON CACHE BOOL "Compile and/or run self-tests")
set(TANGLE_INSTALL ON CACHE BOOL "Create install target(s)")
set(TANGLE_DOCS OFF CACHE BOOL "Create doxygen documentation")
set(MODULES
str
cookie
uri
msg
nav
browser
)
set(EXTRAS
nav/extra/proto-curl
)
if (TANGLE_TESTING)
set(COVERALLS_PREFIX TANGLE_)
foreach(MODULE ${MODULES})
list(APPEND TANGLE_COVERALLS_DIRS ${MODULE}/include ${MODULE}/src)
endforeach()
foreach(MODULE ${EXTRAS})
list(APPEND TANGLE_COVERALLS_DIRS ${MODULE}/include ${MODULE}/src)
endforeach()
set(TANGLE_COVERALLS_IGNORE_FILES
# The file introduces almost 7000 lines, which more than quadruples
# number of total lines; this clouds the reports a little. To double
# check the coverage, comment next line.
browser/src/entities.cpp
# Another auto-generated file, this one adds 360 lines total.
browser/src/html_dtd.cpp
)
include(tools/coveralls/Coveralls.cmake)
endif()
##################################################################
## SOURCES
##################################################################
macro(WRAP_SOURCELIST)
foreach (_file ${ARGN})
get_filename_component(_basename ${_file} NAME_WE)
get_filename_component(_path ${_file} PATH)
string(REGEX REPLACE "/" "\\\\\\\\" _sourcegroup "${_path}")
source_group("${_sourcegroup}" FILES ${_file})
endforeach ()
endmacro()
if (MSVC)
add_definitions(/EHsc)
endif()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
if (TANGLE_TESTING)
enable_testing()
if (NOT TARGET GTest::gtest)
find_package(GTest REQUIRED CONFIG HINTS ${PROJECT_BINARY_DIR})
endif()
endif()
add_subdirectory(tools/lookup)
##################################################################
## DOCUMENTATION
##################################################################
if (TANGLE_DOCS)
find_package( Doxygen )
if (DOXYGEN_FOUND)
add_custom_target(doc)
set_target_properties(doc PROPERTIES FOLDER Doxygen)
if (MSVC)
set(CMAKE_DOXYGEN_WARN_FORMAT "$file($line): $text")
else()
set(CMAKE_DOXYGEN_WARN_FORMAT "$file:$line: $text")
endif()
else()
message(STATUS "Doxy not found...")
endif()
endif()
##################################################################
## SUBPROJECTS
##################################################################
foreach(MODULE ${MODULES})
add_subdirectory( ${MODULE} )
endforeach()
foreach(MODULE ${EXTRAS})
add_subdirectory( ${MODULE} )
endforeach()
if (TANGLE_INSTALL)
if (TARGET tangle)
install(TARGETS tangle
EXPORT tangle
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
get_target_property(TANGLE_INCLUDE_DIRS tangle INTERFACE_INCLUDE_DIRECTORIES)
foreach(DIR ${TANGLE_INCLUDE_DIRS})
if (DIR MATCHES "^[$]<BUILD_INTERFACE:(.*)>$")
string(REGEX REPLACE "^[$]<BUILD_INTERFACE:(.*)>$" "\\1/" DIR ${DIR})
install(DIRECTORY ${DIR} DESTINATION include)
endif()
endforeach()
endif()
install(EXPORT tangle NAMESPACE "tangle::" DESTINATION lib/cmake)
if (MSVC)
install(DIRECTORY natvis/ DESTINATION include/tangle/natvis)
endif()
endif()
##################################################################
## PACKER
##################################################################
set(CPACK_PACKAGE_VENDOR "mbits-libs")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
include( CPack )