Imported Upstream version 1.9.5
[platform/upstream/doxygen.git] / CMakeLists.txt
1 # vim:ts=4:sw=4:expandtab:autoindent:
2 #
3 # Copyright (C) 1997-2015 by Dimitri van Heesch.
4 #
5 # Permission to use, copy, modify, and distribute this software and its
6 # documentation under the terms of the GNU General Public License is hereby
7 # granted. No representations are made about the suitability of this software
8 # for any purpose. It is provided "as is" without express or implied warranty.
9 # See the GNU General Public License for more details.
10 #
11 # Documents produced by Doxygen are derivative works derived from the
12 # input used in their production; they are not affected by this license.
13
14 cmake_minimum_required(VERSION 3.3)
15 project(doxygen)
16
17 option(build_wizard    "Build the GUI frontend for doxygen." OFF)
18 option(build_app       "Example showing how to embed doxygen in an application." OFF)
19 option(build_parse     "Parses source code and dumps the dependencies between the code elements." OFF)
20 option(build_xmlparser "Automatically update the XML parser modules when updating the schema files." OFF)
21 option(build_search    "Build external search tools (doxysearch and doxyindexer)" OFF)
22 option(build_doc       "Build user manual (HTML and PDF)" OFF)
23 option(build_doc_chm   "Build user manual (CHM)" OFF)
24 option(use_sqlite3     "Add support for sqlite3 output [experimental]." OFF)
25 if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
26     option(use_libc++  "Use libc++ as C++ standard library." ON)
27 endif()
28 option(use_libclang    "Add support for libclang parsing." OFF)
29 option(static_libclang "Link to a statically compiled version of LLVM/libclang." OFF)
30 option(win_static      "Link with /MT in stead of /MD on windows" OFF)
31 option(enable_console  "Enable that executables on Windows get the CONSOLE bit set for the doxywizard executable [development]"  OFF)
32 option(enable_coverage "Enable coverage reporting for gcc/clang [development]" OFF)
33
34 set(force_qt CACHE INTERNAL "Forces doxywizard to build using the specified major version, this can be Qt5 or Qt6")
35 set_property(CACHE force_qt PROPERTY STRINGS OFF Qt6 Qt5)
36
37 SET(enlarge_lex_buffers "262144" CACHE INTERNAL "Sets the lex input and read buffers to the specified size")
38
39 if(enable_coverage)
40   if ("${PROJECT_BINARY_DIR}" STREQUAL "${PROJECT_SOURCE_DIR}")
41     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 file created file 'CMakeCache.txt' and the directory 'CMakeFiles'!")
42   endif()
43 endif()
44
45 list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
46 list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/Sanitizers")
47 set(TOP "${PROJECT_SOURCE_DIR}")
48 include(version)
49
50 message(STATUS "Using Cmake version ${CMAKE_VERSION}")
51 if (${CMAKE_VERSION} VERSION_LESS "3.21.0")
52     set(depfile_supported  "0" CACHE INTERNAL "DEPFILE is not supported")
53 else()
54     set(depfile_supported  "1" CACHE INTERNAL "DEPFILE is supported")
55 endif()
56
57 set(sqlite3  "0" CACHE INTERNAL "used in settings.h")
58 set(clang    "0" CACHE INTERNAL "used in settings.h")
59 if (use_sqlite3)
60         set(sqlite3  "1" CACHE INTERNAL "used in settings.h")
61 endif()
62
63 set(MACOS_VERSION_MIN 10.14)
64 if (use_libclang)
65         set(clang    "1" CACHE INTERNAL "used in settings.h")
66         find_package(LLVM CONFIG REQUIRED)
67         find_package(Clang CONFIG REQUIRED)
68 endif()
69 if (build_wizard)
70     if (force_qt STREQUAL "Qt6")
71         if (CMAKE_SYSTEM MATCHES "Darwin")
72             set(MACOS_VERSION_MIN 10.15)
73         endif()
74     endif()
75 endif()
76
77 # use C++17 standard for compiling
78 set(CMAKE_CXX_STANDARD 17)
79 set(CMAKE_CXX_STANDARD_REQUIRED ON)
80 set(CMAKE_CXX_EXTENSIONS ON)
81
82 if (CMAKE_SYSTEM MATCHES "Darwin")
83     set(CMAKE_OSX_DEPLOYMENT_TARGET "${MACOS_VERSION_MIN}" CACHE STRING "Minimum OS X deployment version" FORCE)
84     set(CMAKE_CXX_FLAGS "-Wno-deprecated-register -mmacosx-version-min=${MACOS_VERSION_MIN} ${CMAKE_CXX_FLAGS}")
85     set(CMAKE_C_FLAGS "-Wno-deprecated-register -mmacosx-version-min=${MACOS_VERSION_MIN} ${CMAKE_C_FLAGS}")
86     find_library(CORESERVICES_LIB CoreServices)
87     set(EXTRA_LIBS ${CORESERVICES_LIB})
88 endif()
89
90 if (WIN32)
91     if (MSVC)
92         if (NOT ICONV_DIR)
93           set(ICONV_DIR "${PROJECT_SOURCE_DIR}/winbuild")
94         endif()
95         set(CMAKE_REQUIRED_DEFINITIONS "-DLIBICONV_STATIC")
96         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj") # needed for language.cpp on 64bit
97         add_definitions(-DLIBICONV_STATIC -D_CRT_SECURE_NO_WARNINGS)
98         set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE")
99     endif()
100     if (CMAKE_GENERATOR MATCHES "NMake Makefiles")
101         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
102     endif()
103 endif()
104 if (CMAKE_SYSTEM_NAME MATCHES "CYGWIN")
105    set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og")
106
107    if (CMAKE_BUILD_TYPE STREQUAL  "")
108      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1")
109    endif()
110 endif()
111
112 if (CMAKE_SYSTEM_NAME MATCHES "Windows")
113    if ((CMAKE_GENERATOR MATCHES "MinGW Makefiles") OR
114        (CMAKE_GENERATOR MATCHES "MSYS Makefiles") OR
115        (CMAKE_GENERATOR MATCHES "Unix Makefiles"))
116
117       set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og")
118
119       if (CMAKE_BUILD_TYPE STREQUAL  "")
120         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1")
121       endif()
122    endif()
123 endif()
124
125 if(POLICY CMP0063)
126   cmake_policy(SET CMP0063 NEW)
127 endif()
128 set(CMAKE_CXX_VISIBILITY_PRESET hidden)
129 set(CMAKE_C_VISIBILITY_PRESET hidden)
130 set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
131
132 if (CMAKE_GENERATOR MATCHES "Ninja")
133   set(LEX_FLAGS )
134   set(YACC_FLAGS )
135   set(JAVACC_FLAGS )
136 else ()
137   set(LEX_FLAGS $(LEX_FLAGS))
138   set(YACC_FLAGS $(YACC_FLAGS))
139   set(JAVACC_FLAGS $(JAVACC_FLAGS))
140 endif ()
141
142 find_program(DOT NAMES dot)
143 find_package(PythonInterp REQUIRED)
144 find_package(FLEX REQUIRED)
145 if (FLEX_VERSION VERSION_LESS 2.5.37)
146   message(SEND_ERROR "Doxygen requires at least flex version 2.5.37 (installed: ${FLEX_VERSION})")
147 endif()
148 find_package(BISON REQUIRED)
149 if (BISON_VERSION VERSION_LESS 2.7)
150   message(SEND_ERROR "Doxygen requires at least bison version 2.7 (installed: ${BISON_VERSION})")
151 endif()
152 find_package(Threads)
153 find_package(Sanitizers)
154
155 if (sqlite3)
156   find_package(SQLite3 REQUIRED)
157   if (SQLITE3_VERSION VERSION_LESS 3.9.0)
158     message(SEND_ERROR "Doxygen requires at least sqlite3 version 3.9.0 (installed: ${SQLITE3_VERSION})")
159   endif()
160 endif()
161
162 find_package(Iconv REQUIRED)
163 include_directories(${ICONV_INCLUDE_DIR})
164
165
166 #set(DOXYDOCS ${PROJECT_SOURCE_DIR}/doc CACHE INTERNAL "Path to doxygen docs")
167 set(DOXYDOCS ${PROJECT_BINARY_DIR}/doc)
168 set(ENV{DOXYGEN_DOCDIR} ${DOXYDOCS})
169 set(GENERATED_SRC "${PROJECT_BINARY_DIR}/generated_src" CACHE INTERNAL "Stores generated files")
170 set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
171 set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
172
173 # place binaries for all build types in the same directory, so we know where to find it
174 # when running tests or generating docs
175 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${EXECUTABLE_OUTPUT_PATH})
176 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${EXECUTABLE_OUTPUT_PATH})
177 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${EXECUTABLE_OUTPUT_PATH})
178 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${EXECUTABLE_OUTPUT_PATH})
179
180 if (win_static)
181     set(CompilerFlags
182         CMAKE_CXX_FLAGS
183         CMAKE_CXX_FLAGS_DEBUG
184         CMAKE_CXX_FLAGS_RELEASE
185         CMAKE_CXX_FLAGS_MINSIZEREL
186         CMAKE_CXX_FLAGS_RELWITHDEBINFO
187         CMAKE_C_FLAGS
188         CMAKE_C_FLAGS_DEBUG
189         CMAKE_C_FLAGS_RELEASE
190         CMAKE_C_FLAGS_MINSIZEREL
191         CMAKE_C_FLAGS_RELWITHDEBINFO)
192     foreach(CompilerFlag ${CompilerFlags})
193       string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
194     endforeach()
195 endif()
196
197 include(cmake/CompilerWarnings.cmake)
198 include(cmake/Coverage.cmake)
199
200 add_subdirectory(libmd5)
201 add_subdirectory(liblodepng)
202 add_subdirectory(libmscgen)
203 add_subdirectory(libversion)
204 add_subdirectory(libxml)
205 add_subdirectory(vhdlparser)
206 add_subdirectory(src)
207
208 if (build_doc_chm)
209     if (WIN32)
210           find_package(HTMLHelp REQUIRED)
211           set(build_doc ON)
212     else ()
213           message(WARNING "CHM documentation generation not supported for this platform, ignoring setting.")
214           set(build_doc_chm OFF)
215     endif ()
216 endif ()
217
218 if (build_doc)
219     add_subdirectory(examples)
220     add_subdirectory(doc)
221 endif ()
222
223 add_subdirectory(addon)
224
225 enable_testing()
226 add_subdirectory(testing)
227
228 include(cmake/packaging.cmake) # set CPACK_xxxx properties
229 include(CPack)