Imported Upstream version 1.9.4
[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 list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
40 list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/Sanitizers")
41 set(TOP "${PROJECT_SOURCE_DIR}")
42 include(version)
43
44 set(sqlite3  "0" CACHE INTERNAL "used in settings.h")
45 set(clang    "0" CACHE INTERNAL "used in settings.h")
46 if (use_sqlite3)
47         set(sqlite3  "1" CACHE INTERNAL "used in settings.h")
48 endif()
49
50 set(MACOS_VERSION_MIN 10.14)
51 if (use_libclang)
52         set(clang    "1" CACHE INTERNAL "used in settings.h")
53         find_package(LLVM CONFIG REQUIRED)
54         find_package(Clang CONFIG REQUIRED)
55 endif()
56 if (build_wizard)
57     if (force_qt STREQUAL "Qt6")
58         if (CMAKE_SYSTEM MATCHES "Darwin")
59             set(MACOS_VERSION_MIN 10.15)
60         endif()
61     endif()
62 endif()
63
64 # use C++17 standard for compiling
65 set(CMAKE_CXX_STANDARD 17)
66 set(CMAKE_CXX_STANDARD_REQUIRED ON)
67 set(CMAKE_CXX_EXTENSIONS ON)
68
69 if (CMAKE_SYSTEM MATCHES "Darwin")
70     set(CMAKE_OSX_DEPLOYMENT_TARGET "${MACOS_VERSION_MIN}" CACHE STRING "Minimum OS X deployment version" FORCE)
71     set(CMAKE_CXX_FLAGS "-Wno-deprecated-register -mmacosx-version-min=${MACOS_VERSION_MIN} ${CMAKE_CXX_FLAGS}")
72     set(CMAKE_C_FLAGS "-Wno-deprecated-register -mmacosx-version-min=${MACOS_VERSION_MIN} ${CMAKE_C_FLAGS}")
73     find_library(CORESERVICES_LIB CoreServices)
74     set(EXTRA_LIBS ${CORESERVICES_LIB})
75 endif()
76
77 if (WIN32)
78     if (MSVC)
79         if (NOT ICONV_DIR)
80           set(ICONV_DIR "${PROJECT_SOURCE_DIR}/winbuild")
81         endif()
82         set(CMAKE_REQUIRED_DEFINITIONS "-DLIBICONV_STATIC")
83         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj") # needed for language.cpp on 64bit
84         add_definitions(-DLIBICONV_STATIC -D_CRT_SECURE_NO_WARNINGS)
85         set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE")
86     endif()
87     if (CMAKE_GENERATOR MATCHES "NMake Makefiles")
88         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
89     endif()
90 endif()
91 if (CMAKE_SYSTEM_NAME MATCHES "CYGWIN")
92    set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og")
93
94    if (CMAKE_BUILD_TYPE STREQUAL  "")
95      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1")
96    endif()
97 endif()
98
99 if (CMAKE_SYSTEM_NAME MATCHES "Windows")
100    if ((CMAKE_GENERATOR MATCHES "MinGW Makefiles") OR
101        (CMAKE_GENERATOR MATCHES "MSYS Makefiles") OR
102        (CMAKE_GENERATOR MATCHES "Unix Makefiles"))
103
104       set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og")
105
106       if (CMAKE_BUILD_TYPE STREQUAL  "")
107         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1")
108       endif()
109    endif()
110 endif()
111
112 if(POLICY CMP0063)
113   cmake_policy(SET CMP0063 NEW)
114 endif()
115 set(CMAKE_CXX_VISIBILITY_PRESET hidden)
116 set(CMAKE_C_VISIBILITY_PRESET hidden)
117 set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
118
119 if (CMAKE_GENERATOR MATCHES "Ninja")
120   set(LEX_FLAGS )
121   set(YACC_FLAGS )
122   set(JAVACC_FLAGS )
123 else ()
124   set(LEX_FLAGS $(LEX_FLAGS))
125   set(YACC_FLAGS $(YACC_FLAGS))
126   set(JAVACC_FLAGS $(JAVACC_FLAGS))
127 endif ()
128
129 find_program(DOT NAMES dot)
130 find_package(PythonInterp REQUIRED)
131 find_package(FLEX REQUIRED)
132 if (FLEX_VERSION VERSION_LESS 2.5.37)
133   message(SEND_ERROR "Doxygen requires at least flex version 2.5.37 (installed: ${FLEX_VERSION})")
134 endif()
135 find_package(BISON REQUIRED)
136 if (BISON_VERSION VERSION_LESS 2.7)
137   message(SEND_ERROR "Doxygen requires at least bison version 2.7 (installed: ${BISON_VERSION})")
138 endif()
139 find_package(Threads)
140 find_package(Sanitizers)
141
142 if (sqlite3)
143   find_package(SQLite3 REQUIRED)
144   if (SQLITE3_VERSION VERSION_LESS 3.9.0)
145     message(SEND_ERROR "Doxygen requires at least sqlite3 version 3.9.0 (installed: ${SQLITE3_VERSION})")
146   endif()
147 endif()
148
149 find_package(Iconv REQUIRED)
150 include_directories(${ICONV_INCLUDE_DIR})
151
152
153 #set(DOXYDOCS ${PROJECT_SOURCE_DIR}/doc CACHE INTERNAL "Path to doxygen docs")
154 set(DOXYDOCS ${PROJECT_BINARY_DIR}/doc)
155 set(ENV{DOXYGEN_DOCDIR} ${DOXYDOCS})
156 set(GENERATED_SRC "${PROJECT_BINARY_DIR}/generated_src" CACHE INTERNAL "Stores generated files")
157 set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
158 set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
159
160 # place binaries for all build types in the same directory, so we know where to find it
161 # when running tests or generating docs
162 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${EXECUTABLE_OUTPUT_PATH})
163 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${EXECUTABLE_OUTPUT_PATH})
164 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${EXECUTABLE_OUTPUT_PATH})
165 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${EXECUTABLE_OUTPUT_PATH})
166
167 if (win_static)
168     set(CompilerFlags
169         CMAKE_CXX_FLAGS
170         CMAKE_CXX_FLAGS_DEBUG
171         CMAKE_CXX_FLAGS_RELEASE
172         CMAKE_CXX_FLAGS_MINSIZEREL
173         CMAKE_CXX_FLAGS_RELWITHDEBINFO
174         CMAKE_C_FLAGS
175         CMAKE_C_FLAGS_DEBUG
176         CMAKE_C_FLAGS_RELEASE
177         CMAKE_C_FLAGS_MINSIZEREL
178         CMAKE_C_FLAGS_RELWITHDEBINFO)
179     foreach(CompilerFlag ${CompilerFlags})
180       string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
181     endforeach()
182 endif()
183
184 include(cmake/CompilerWarnings.cmake)
185 include(cmake/Coverage.cmake)
186
187 add_subdirectory(libmd5)
188 add_subdirectory(liblodepng)
189 add_subdirectory(libmscgen)
190 add_subdirectory(libversion)
191 add_subdirectory(libxml)
192 add_subdirectory(vhdlparser)
193 add_subdirectory(src)
194
195 if (build_doc_chm)
196     if (WIN32)
197           find_package(HTMLHelp REQUIRED)
198           set(build_doc ON)
199     else ()
200           message(WARNING "CHM documentation generation not supported for this platform, ignoring setting.")
201           set(build_doc_chm OFF)
202     endif ()
203 endif ()
204
205 if (build_doc)
206     add_subdirectory(examples)
207     add_subdirectory(doc)
208 endif ()
209
210 add_subdirectory(addon)
211
212 enable_testing()
213 add_subdirectory(testing)
214
215 include(cmake/packaging.cmake) # set CPACK_xxxx properties
216 include(CPack)