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