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