Imported Upstream version 1.9.0
[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 "Example showing how to parse doxygen's XML output." 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(english_only    "Only compile in support for the English language" OFF)
32 option(force_qt4       "Forces doxywizard to build using Qt4 even if Qt5 is installed" OFF)
33 option(enable_coverage "Enable coverage reporting for gcc/clang [development]" OFF)
34
35 SET(enlarge_lex_buffers "262144" CACHE INTERNAL "Sets the lex input and read buffers to the specified size")
36
37 list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
38 list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/Sanitizers")
39 set(TOP "${PROJECT_SOURCE_DIR}")
40 include(version)
41
42 set(sqlite3  "0" CACHE INTERNAL "used in settings.h")
43 set(clang    "0" CACHE INTERNAL "used in settings.h")
44 if (use_sqlite3)
45         set(sqlite3  "1" CACHE INTERNAL "used in settings.h")
46 endif()
47
48 set(MACOS_VERSION_MIN 10.9)
49 if (use_libclang)
50         set(clang    "1" CACHE INTERNAL "used in settings.h")
51         find_package(LLVM CONFIG REQUIRED)
52         find_package(Clang CONFIG REQUIRED)
53     if (CMAKE_SYSTEM MATCHES "Darwin")
54         set(MACOS_VERSION_MIN 10.14)
55     endif()
56 endif()
57
58 # use C++14 standard for compiling (libclang option requires it)
59 set(CMAKE_CXX_STANDARD 14)
60 set(CMAKE_CXX_STANDARD_REQUIRED ON)
61 set(CMAKE_CXX_EXTENSIONS ON)
62
63 if (CMAKE_SYSTEM MATCHES "Darwin")
64     set(CMAKE_CXX_FLAGS "-Wno-deprecated-register -mmacosx-version-min=${MACOS_VERSION_MIN} ${CMAKE_CXX_FLAGS}")
65     set(CMAKE_C_FLAGS "-Wno-deprecated-register -mmacosx-version-min=${MACOS_VERSION_MIN} ${CMAKE_C_FLAGS}")
66     find_library(CORESERVICES_LIB CoreServices)
67     set(EXTRA_LIBS ${CORESERVICES_LIB})
68 endif()
69
70 if (WIN32)
71     if ((NOT CMAKE_GENERATOR MATCHES "MinGW Makefiles") AND 
72         (NOT CMAKE_GENERATOR MATCHES "MSYS Makefiles") AND
73         (NOT CMAKE_GENERATOR MATCHES "Unix Makefiles"))
74         if (NOT ICONV_DIR)
75           set(ICONV_DIR "${PROJECT_SOURCE_DIR}/winbuild")
76         endif()
77         set(CMAKE_REQUIRED_DEFINITIONS "-DLIBICONV_STATIC")
78         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj") # needed for language.cpp on 64bit
79         add_definitions(-DLIBICONV_STATIC -D_CRT_SECURE_NO_WARNINGS)
80     endif()
81     if (CMAKE_GENERATOR MATCHES "NMake Makefiles")
82         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
83     endif()
84 endif()
85
86 if(POLICY CMP0063)
87   cmake_policy(SET CMP0063 NEW)
88 endif()
89 set(CMAKE_CXX_VISIBILITY_PRESET hidden)
90 set(CMAKE_C_VISIBILITY_PRESET hidden)
91 set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
92
93 if (CMAKE_GENERATOR MATCHES "Ninja")
94   set(LEX_FLAGS )
95   set(YACC_FLAGS )
96   set(JAVACC_FLAGS )
97 else ()
98   set(LEX_FLAGS $(LEX_FLAGS))
99   set(YACC_FLAGS $(YACC_FLAGS))
100   set(JAVACC_FLAGS $(JAVACC_FLAGS))
101 endif ()
102
103 find_program(DOT NAMES dot)
104 find_package(PythonInterp REQUIRED)
105 find_package(FLEX REQUIRED)
106 find_package(BISON REQUIRED)
107 if (BISON_VERSION VERSION_LESS 2.7)
108   message(SEND_ERROR "Doxygen requires at least bison version 2.7 (installed: ${BISON_VERSION})")
109 endif()
110 find_package(Threads)
111 find_package(Sanitizers)
112
113 if (sqlite3)
114   find_package(SQLite3 REQUIRED)
115   if (SQLITE3_VERSION VERSION_LESS 3.9.0)
116     message(SEND_ERROR "Doxygen requires at least sqlite3 version 3.9.0 (installed: ${SQLITE3_VERSION})")
117   endif()
118 endif()
119
120 find_package(Iconv REQUIRED)
121 include_directories(${ICONV_INCLUDE_DIR})
122
123
124 #set(DOXYDOCS ${PROJECT_SOURCE_DIR}/doc CACHE INTERNAL "Path to doxygen docs")
125 set(DOXYDOCS ${PROJECT_BINARY_DIR}/doc)
126 set(ENV{DOXYGEN_DOCDIR} ${DOXYDOCS})
127 set(GENERATED_SRC "${PROJECT_BINARY_DIR}/generated_src" CACHE INTERNAL "Stores generated files")
128 set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
129 set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
130
131 # place binaries for all build types in the same directory, so we know where to find it
132 # when running tests or generating docs
133 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${EXECUTABLE_OUTPUT_PATH})
134 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${EXECUTABLE_OUTPUT_PATH})
135 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${EXECUTABLE_OUTPUT_PATH})
136 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${EXECUTABLE_OUTPUT_PATH})
137
138 # gather lang codes for translation
139 file(GLOB lang_files RELATIVE "${PROJECT_SOURCE_DIR}/src" "${PROJECT_SOURCE_DIR}/src/translator_??.h")
140 if (english_only) # user only wants English
141   set(lcodes "ENONLY")
142 else ()
143   set(lcodes "")
144   foreach (_lang ${lang_files})
145     string(REGEX REPLACE "translator_(.*).h" "\\1" _lang_code ${_lang})
146     string(TOUPPER ${_lang_code} lang_code)
147     list(APPEND lcodes "${lang_code}")
148   endforeach()
149 endif()
150 set(LANG_CODES ${lcodes} CACHE STRING "List of language codes for which translations should be compiled in")
151
152 if (win_static)
153     set(CompilerFlags
154         CMAKE_CXX_FLAGS
155         CMAKE_CXX_FLAGS_DEBUG
156         CMAKE_CXX_FLAGS_RELEASE
157         CMAKE_CXX_FLAGS_MINSIZEREL
158         CMAKE_CXX_FLAGS_RELWITHDEBINFO
159         CMAKE_C_FLAGS
160         CMAKE_C_FLAGS_DEBUG
161         CMAKE_C_FLAGS_RELEASE
162         CMAKE_C_FLAGS_MINSIZEREL
163         CMAKE_C_FLAGS_RELWITHDEBINFO)
164     foreach(CompilerFlag ${CompilerFlags})
165       string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
166     endforeach()
167 endif()
168
169 include(cmake/CompilerWarnings.cmake)
170 include(cmake/Coverage.cmake)
171
172 add_subdirectory(libmd5)
173 add_subdirectory(liblodepng)
174 add_subdirectory(libmscgen)
175 add_subdirectory(libversion)
176 add_subdirectory(qtools)
177 add_subdirectory(vhdlparser)
178 add_subdirectory(src)
179
180 if (build_doc_chm)
181     if (WIN32)
182           find_package(HTMLHelp REQUIRED)
183           set(build_doc ON)
184     else ()
185           message(WARNING "CHM documentation generation not supported for this platform, ignoring setting.")
186           set(build_doc_chm OFF)
187     endif ()
188 endif ()
189
190 if (build_doc)
191     add_subdirectory(examples)
192     add_subdirectory(doc)
193 endif ()
194
195 add_subdirectory(addon)
196
197 enable_testing()
198 add_subdirectory(testing)
199
200 include(cmake/packaging.cmake) # set CPACK_xxxx properties
201 include(CPack)