ba105b895a1a9abd06aedec8841400368aaf88a5
[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.5)
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 endif()
91
92 find_package(Iconv REQUIRED)
93 include_directories(${ICONV_INCLUDE_DIR})
94
95
96 #set(DOXYDOCS ${CMAKE_SOURCE_DIR}/doc CACHE INTERNAL "Path to doxygen docs")
97 set(DOXYDOCS ${PROJECT_BINARY_DIR}/doc)
98 set(ENV{DOXYGEN_DOCDIR} ${DOXYDOCS})
99 set(GENERATED_SRC "${CMAKE_BINARY_DIR}/generated_src" CACHE INTERNAL "Stores generated files")
100 set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
101 set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
102
103 # place binaries for all build types in the same directory, so we know where to find it
104 # when running tests or generating docs
105 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${EXECUTABLE_OUTPUT_PATH})
106 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${EXECUTABLE_OUTPUT_PATH})
107 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${EXECUTABLE_OUTPUT_PATH})
108 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${EXECUTABLE_OUTPUT_PATH})
109
110 # gather lang codes for translation
111 file(GLOB lang_files RELATIVE "${CMAKE_SOURCE_DIR}/src" "${CMAKE_SOURCE_DIR}/src/translator_??.h")
112 if (english_only) # user only wants English
113   set(lcodes "ENONLY")
114 else ()
115   set(lcodes "")
116   foreach (_lang ${lang_files})
117     string(REGEX REPLACE "translator_(.*).h" "\\1" _lang_code ${_lang})
118     string(TOUPPER ${_lang_code} lang_code)
119     list(APPEND lcodes "${lang_code}")
120   endforeach()
121 endif()
122 set(LANG_CODES ${lcodes} CACHE STRING "List of language codes for which translations should be compiled in")
123
124 if (win_static)
125     set(CompilerFlags
126         CMAKE_CXX_FLAGS
127         CMAKE_CXX_FLAGS_DEBUG
128         CMAKE_CXX_FLAGS_RELEASE
129         CMAKE_CXX_FLAGS_MINSIZEREL
130         CMAKE_CXX_FLAGS_RELWITHDEBINFO
131         CMAKE_C_FLAGS
132         CMAKE_C_FLAGS_DEBUG
133         CMAKE_C_FLAGS_RELEASE
134         CMAKE_C_FLAGS_MINSIZEREL
135         CMAKE_C_FLAGS_RELWITHDEBINFO)
136     foreach(CompilerFlag ${CompilerFlags})
137       string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
138     endforeach()
139 endif()
140
141
142 add_subdirectory(libmd5)
143 add_subdirectory(qtools)
144 add_subdirectory(vhdlparser)
145 add_subdirectory(src)
146
147 if (build_doc)
148     add_subdirectory(examples)
149     add_subdirectory(doc)
150 endif ()
151
152 add_subdirectory(addon)
153
154 enable_testing()
155 add_subdirectory(testing)
156
157 include(cmake/packaging.cmake) # set CPACK_xxxx properties
158 include(CPack)