forked from doxygen/doxygen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
289 lines (247 loc) · 10.9 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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# vim:ts=4:sw=4:expandtab:autoindent:
#
# Copyright (C) 1997-2015 by Dimitri van Heesch.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation under the terms of the GNU General Public License is hereby
# granted. No representations are made about the suitability of this software
# for any purpose. It is provided "as is" without express or implied warranty.
# See the GNU General Public License for more details.
#
# Documents produced by Doxygen are derivative works derived from the
# input used in their production; they are not affected by this license.
cmake_minimum_required(VERSION 3.14)
project(doxygen)
option("ENABLE_CLANG_TIDY" "Enable static analysis with clang-tidy" OFF)
option(build_wizard "Build the GUI frontend for doxygen." OFF)
option(build_app "Example showing how to embed doxygen in an application." OFF)
option(build_parse "Parses source code and dumps the dependencies between the code elements." OFF)
option(build_search "Build external search tools (doxysearch and doxyindexer)" OFF)
option(build_doc "Build user manual (HTML and PDF)" OFF)
option(build_doc_chm "Build user manual (CHM)" OFF)
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
option(use_libc++ "Use libc++ as C++ standard library." ON)
endif()
option(use_libclang "Add support for libclang parsing." OFF)
option(use_sys_spdlog "Use system spdlog library instead of the one bundled." OFF)
option(use_sys_sqlite3 "Use system sqlite3 library instead of the one bundled." OFF)
option(static_libclang "Link to a statically compiled version of LLVM/libclang." OFF)
option(win_static "Link with /MT in stead of /MD on windows" OFF)
option(enable_console "Enable that executables on Windows get the CONSOLE bit set for the doxywizard executable [development]" OFF)
option(enable_coverage "Enable coverage reporting for gcc/clang [development]" OFF)
option(enable_tracing "Enable tracing option in release builds [development]" OFF)
option(enable_lex_debug "Enable debugging info for lexical scanners in release builds [development]" OFF)
set(force_qt CACHE INTERNAL "Forces doxywizard to build using the specified major version, this can be Qt5 or Qt6")
set_property(CACHE force_qt PROPERTY STRINGS OFF Qt6 Qt5)
SET(enlarge_lex_buffers "262144" CACHE INTERNAL "Sets the lex input and read buffers to the specified size")
if(enable_coverage)
if ("${PROJECT_BINARY_DIR}" STREQUAL "${PROJECT_SOURCE_DIR}")
message(FATAL_ERROR "Doxygen cannot be generated in-place, the build directory (${PROJECT_BINARY_DIR}) has to differ from the doxygen main directory (${PROJECT_SOURCE_DIR})\nPlease don't forget to remove the already created file 'CMakeCache.txt' and the directory 'CMakeFiles'!")
endif()
endif()
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/Sanitizers")
set(TOP "${PROJECT_SOURCE_DIR}")
include(version)
message(STATUS "Using Cmake version ${CMAKE_VERSION}")
if (${CMAKE_VERSION} VERSION_LESS "3.21.0")
set(depfile_supported "0" CACHE INTERNAL "DEPFILE is not supported")
else()
set(depfile_supported "1" CACHE INTERNAL "DEPFILE is supported")
endif()
set(clang "0" CACHE INTERNAL "used in settings.h")
set(MACOS_VERSION_MIN 10.14)
if (use_libclang)
set(clang "1" CACHE INTERNAL "used in settings.h")
find_package(LLVM CONFIG REQUIRED)
find_package(Clang CONFIG REQUIRED)
endif()
if (use_sys_spdlog)
find_package(spdlog CONFIG REQUIRED)
endif()
if (use_sys_sqlite3)
find_package(SQLite3 REQUIRED)
endif()
if (build_wizard)
if (force_qt STREQUAL "Qt6")
if (CMAKE_SYSTEM MATCHES "Darwin")
set(MACOS_VERSION_MIN 10.15)
endif()
endif()
endif()
# use C++17 standard for compiling
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
if (ENABLE_CLANG_TIDY)
find_program("CLANGTIDY" "clang-tidy")
if (CLANGTIDY)
set(CMAKE_CXX_CLANG_TIDY clang-tidy;
-header-filter=.;
-checks=-*,cppcoreguidelines-special-member-functions
#-checks=-*,cppcoreguidelines-missing-std-forward
#-checks=-*,cppcoreguidelines-init-variables
#-checks=-*,cppcoreguidelines-misleading-capture-default-by-value
#-checks=-*,modernize-use-nullptr
#-checks=-*,modernize-use-override
#-checks=-*,modernize-use-emplace
)
else()
message(SEND_ERROR "clang-tidy requested but executable not found")
endif()
endif()
# produce compile_commands.json
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if (CMAKE_SYSTEM MATCHES "Darwin")
set(CMAKE_OSX_DEPLOYMENT_TARGET "${MACOS_VERSION_MIN}" CACHE STRING "Minimum OS X deployment version" FORCE)
set(CMAKE_CXX_FLAGS "-Wno-deprecated-register -mmacosx-version-min=${MACOS_VERSION_MIN} ${CMAKE_CXX_FLAGS}")
set(CMAKE_C_FLAGS "-Wno-deprecated-register -mmacosx-version-min=${MACOS_VERSION_MIN} ${CMAKE_C_FLAGS}")
find_library(CORESERVICES_LIB CoreServices)
set(EXTRA_LIBS ${CORESERVICES_LIB})
endif()
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_LIBCPP_ENABLE_ASSERTIONS=1")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_GLIBCXX_ASSERTIONS")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSQLITE_OMIT_LOAD_EXTENSION=1")
if (WIN32)
if (MSVC)
if (NOT ICONV_DIR)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
list(APPEND CMAKE_PREFIX_PATH "${PROJECT_SOURCE_DIR}/deps/iconv_winbuild/include" "${PROJECT_SOURCE_DIR}/deps/iconv_winbuild/x64")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
list(APPEND CMAKE_PREFIX_PATH "${PROJECT_SOURCE_DIR}/deps/iconv_winbuild/include" "${PROJECT_SOURCE_DIR}/deps/iconv_winbuild/x86")
endif()
else()
list(APPEND CMAKE_PREFIX_PATH ${ICONV_DIR})
endif()
set(CMAKE_REQUIRED_DEFINITIONS "-DLIBICONV_STATIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj") # needed for language.cpp on 64bit
add_definitions(-DLIBICONV_STATIC -D_CRT_SECURE_NO_WARNINGS)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE")
endif()
if (CMAKE_GENERATOR MATCHES "NMake Makefiles")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
endif()
endif()
if (CMAKE_SYSTEM_NAME MATCHES "CYGWIN")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og -Wa,-mbig-obj")
if (CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1")
endif()
endif()
if (WIN32 AND MSVC)
# workaround for GitHub runner, see https://github.com/actions/runner-images/issues/10004
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR")
endif()
if (CMAKE_SYSTEM_NAME MATCHES "Windows")
if ((CMAKE_GENERATOR MATCHES "MinGW Makefiles") OR
(CMAKE_GENERATOR MATCHES "MSYS Makefiles") OR
(CMAKE_GENERATOR MATCHES "Unix Makefiles"))
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og")
if (CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1")
endif()
endif()
endif()
# needed for JavaCC
set(JAVA_CC_EXTRA_FLAGS "-DJAVACC_CHAR_TYPE=\"unsigned char\"")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${JAVA_CC_EXTRA_FLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${JAVA_CC_EXTRA_FLAGS}")
if(POLICY CMP0063)
cmake_policy(SET CMP0063 NEW)
endif()
# when using mutrace comment the next 3 lines and uncomment the last 2
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_C_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -rdynamic")
#set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -rdynamic")
if (CMAKE_GENERATOR MATCHES "Ninja")
set(LEX_FLAGS )
set(YACC_FLAGS )
set(JAVACC_FLAGS )
else ()
set(LEX_FLAGS $(LEX_FLAGS))
set(YACC_FLAGS $(YACC_FLAGS))
set(JAVACC_FLAGS $(JAVACC_FLAGS))
endif ()
find_program(DOT NAMES dot)
find_package(Python REQUIRED)
find_package(FLEX REQUIRED)
if (FLEX_VERSION VERSION_LESS 2.5.37)
message(SEND_ERROR "Doxygen requires at least flex version 2.5.37 (installed: ${FLEX_VERSION})")
endif()
find_package(BISON REQUIRED)
if (BISON_VERSION VERSION_LESS 2.7)
message(SEND_ERROR "Doxygen requires at least bison version 2.7 (installed: ${BISON_VERSION})")
endif()
find_package(Threads)
find_package(Sanitizers)
if ((CMAKE_BUILD_TYPE STREQUAL "Debug") OR enable_lex_debug)
set(LEX_FLAGS "${LEX_FLAGS} -d")
endif()
find_package(Iconv REQUIRED)
include_directories(${Iconv_INCLUDE_DIRS})
#set(DOXYDOCS ${PROJECT_SOURCE_DIR}/doc CACHE INTERNAL "Path to doxygen docs")
set(DOXYDOCS ${PROJECT_BINARY_DIR}/doc)
set(ENV{DOXYGEN_DOCDIR} ${DOXYDOCS})
set(GENERATED_SRC "${PROJECT_BINARY_DIR}/generated_src" CACHE INTERNAL "Stores generated files")
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
# place binaries for all build types in the same directory, so we know where to find it
# when running tests or generating docs
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${EXECUTABLE_OUTPUT_PATH})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${EXECUTABLE_OUTPUT_PATH})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${EXECUTABLE_OUTPUT_PATH})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${EXECUTABLE_OUTPUT_PATH})
if (win_static)
set(CompilerFlags
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELWITHDEBINFO)
foreach(CompilerFlag ${CompilerFlags})
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
endforeach()
endif()
include(cmake/CompilerWarnings.cmake)
include(cmake/Coverage.cmake)
include(cmake/WindowsEncoding.cmake)
add_subdirectory(deps)
add_subdirectory(libversion)
add_subdirectory(libxml)
add_subdirectory(vhdlparser)
add_subdirectory(src)
if (build_doc_chm)
if (WIN32)
find_package(HTMLHelp REQUIRED)
set(build_doc ON)
else ()
message(WARNING "CHM documentation generation not supported for this platform, ignoring setting.")
set(build_doc_chm OFF)
endif ()
endif ()
# always parse doc directory to at least install man pages
add_subdirectory(doc)
if (build_doc)
add_subdirectory(examples)
endif ()
add_subdirectory(doc_internal)
find_package(generateDS)
set(update_doxmlparser_dependency "")
if (GENERATEDS_FOUND)
set(update_doxmlparser_dependency "update_doxmlparser_files")
endif()
add_subdirectory(addon)
enable_testing()
add_subdirectory(testing)
include(cmake/packaging.cmake) # set CPACK_xxxx properties
include(CPack)