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