Imported Upstream version 1.9.8
[platform/upstream/doxygen.git] / CMakeLists.txt
index b0def45..4957c34 100644 (file)
 # Documents produced by Doxygen are derivative works derived from the
 # input used in their production; they are not affected by this license.
 
-cmake_minimum_required(VERSION 2.8.12)
+cmake_minimum_required(VERSION 3.12)
 project(doxygen)
 
 option(build_wizard    "Build the GUI frontend for doxygen." OFF)
 option(build_app       "Example showing how to embed doxygen in an application." OFF)
-option(build_xmlparser "Example showing how to parse doxygen's XML output." OFF)
+option(build_parse     "Parses source code and dumps the dependencies between the code elements." OFF)
+option(build_xmlparser "Automatically update the XML parser modules when updating the schema files." OFF)
 option(build_search    "Build external search tools (doxysearch and doxyindexer)" OFF)
-option(build_doc       "Build user manual" OFF)
-option(use_sqlite3     "Add support for sqlite3 output [experimental]." OFF)
+option(build_doc       "Build user manual (HTML and PDF)" OFF)
+option(build_doc_chm   "Build user manual (CHM)" OFF)
+if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+    option(use_libc++  "Use libc++ as C++ standard library." ON)
+endif()
 option(use_libclang    "Add support for libclang parsing." OFF)
+option(use_sys_spdlog  "Use system spdlog instead of bundled." OFF)
+option(static_libclang "Link to a statically compiled version of LLVM/libclang." OFF)
 option(win_static      "Link with /MT in stead of /MD on windows" OFF)
-option(english_only    "Only compile in support for the English language" OFF)
+option(enable_console  "Enable that executables on Windows get the CONSOLE bit set for the doxywizard executable [development]"  OFF)
+option(enable_coverage "Enable coverage reporting for gcc/clang [development]" OFF)
+option(enable_tracing  "Enable tracing option in release builds [development]" OFF)
+option(enable_lex_debug "Enable debugging info for lexical scanners in release builds [development]" OFF)
+
+set(force_qt CACHE INTERNAL "Forces doxywizard to build using the specified major version, this can be Qt5 or Qt6")
+set_property(CACHE force_qt PROPERTY STRINGS OFF Qt6 Qt5)
+
+SET(enlarge_lex_buffers "262144" CACHE INTERNAL "Sets the lex input and read buffers to the specified size")
+
+if(enable_coverage)
+  if ("${PROJECT_BINARY_DIR}" STREQUAL "${PROJECT_SOURCE_DIR}")
+    message(FATAL_ERROR "Doxygen cannot be generated in-place, the build directory (${PROJECT_BINARY_DIR}) has to differ from the doxygen main directory (${PROJECT_SOURCE_DIR})\nPlease don't forget to remove the already created file 'CMakeCache.txt' and the directory 'CMakeFiles'!")
+  endif()
+endif()
 
-list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
-set(SOURCE "${CMAKE_SOURCE_DIR}")
+list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
+list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/Sanitizers")
+set(TOP "${PROJECT_SOURCE_DIR}")
 include(version)
 
-set(sqlite3  "0" CACHE INTERNAL "used in settings.h")
-set(clang    "0" CACHE INTERNAL "used in settings.h")
-if (use_sqlite3)
-       set(sqlite3  "1" CACHE INTERNAL "used in settings.h")
+message(STATUS "Using Cmake version ${CMAKE_VERSION}")
+if (${CMAKE_VERSION} VERSION_LESS "3.21.0")
+    set(depfile_supported  "0" CACHE INTERNAL "DEPFILE is not supported")
+else()
+    set(depfile_supported  "1" CACHE INTERNAL "DEPFILE is supported")
 endif()
+
+set(clang    "0" CACHE INTERNAL "used in settings.h")
+
+set(MACOS_VERSION_MIN 10.14)
 if (use_libclang)
        set(clang    "1" CACHE INTERNAL "used in settings.h")
-        find_package(LibClang REQUIRED)
+        find_package(LLVM CONFIG REQUIRED)
+        find_package(Clang CONFIG REQUIRED)
+endif()
+if (use_sys_spdlog)
+        find_package(spdlog CONFIG REQUIRED)
+endif()
+if (build_wizard)
+    if (force_qt STREQUAL "Qt6")
+        if (CMAKE_SYSTEM MATCHES "Darwin")
+            set(MACOS_VERSION_MIN 10.15)
+        endif()
+    endif()
 endif()
 
-if (${CMAKE_SYSTEM} MATCHES "Darwin")
-    set(CMAKE_CXX_FLAGS "-Wno-deprecated-register -mmacosx-version-min=10.5 ${CMAKE_CXX_FLAGS}")
+# use C++17 standard for compiling
+set(CMAKE_CXX_STANDARD 17)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+set(CMAKE_CXX_EXTENSIONS ON)
+
+if (CMAKE_SYSTEM MATCHES "Darwin")
+    set(CMAKE_OSX_DEPLOYMENT_TARGET "${MACOS_VERSION_MIN}" CACHE STRING "Minimum OS X deployment version" FORCE)
+    set(CMAKE_CXX_FLAGS "-Wno-deprecated-register -mmacosx-version-min=${MACOS_VERSION_MIN} ${CMAKE_CXX_FLAGS}")
+    set(CMAKE_C_FLAGS "-Wno-deprecated-register -mmacosx-version-min=${MACOS_VERSION_MIN} ${CMAKE_C_FLAGS}")
     find_library(CORESERVICES_LIB CoreServices)
     set(EXTRA_LIBS ${CORESERVICES_LIB})
 endif()
 
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSQLITE_OMIT_LOAD_EXTENSION=1")
+
 if (WIN32)
-    set(ICONV_DIR "${CMAKE_SOURCE_DIR}/winbuild")
-    set(CMAKE_REQUIRED_DEFINITIONS "-DLIBICONV_STATIC")
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj") # needed for language.cpp on 64bit
-    add_definitions(-DLIBICONV_STATIC -D_CRT_SECURE_NO_WARNINGS)
+    if (MSVC)
+        if (NOT ICONV_DIR)
+          set(ICONV_DIR "${PROJECT_SOURCE_DIR}/winbuild")
+        endif()
+        set(CMAKE_REQUIRED_DEFINITIONS "-DLIBICONV_STATIC")
+        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj") # needed for language.cpp on 64bit
+        add_definitions(-DLIBICONV_STATIC -D_CRT_SECURE_NO_WARNINGS)
+        set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE")
+    endif()
+    if (CMAKE_GENERATOR MATCHES "NMake Makefiles")
+        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
+    endif()
 endif()
+if (CMAKE_SYSTEM_NAME MATCHES "CYGWIN")
+   set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og")
+
+   if (CMAKE_BUILD_TYPE STREQUAL  "")
+     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1")
+   endif()
+endif()
+
+if (CMAKE_SYSTEM_NAME MATCHES "Windows")
+   if ((CMAKE_GENERATOR MATCHES "MinGW Makefiles") OR
+       (CMAKE_GENERATOR MATCHES "MSYS Makefiles") OR
+       (CMAKE_GENERATOR MATCHES "Unix Makefiles"))
+
+      set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og")
+
+      if (CMAKE_BUILD_TYPE STREQUAL  "")
+        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1")
+      endif()
+   endif()
+endif()
+
+# needed for JavaCC
+set(JAVA_CC_EXTRA_FLAGS "-DJAVACC_CHAR_TYPE=\"unsigned char\"")
+set(CMAKE_CXX_FLAGS       "${CMAKE_CXX_FLAGS}       ${JAVA_CC_EXTRA_FLAGS}")
+set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${JAVA_CC_EXTRA_FLAGS}")
+
+if(POLICY CMP0063)
+  cmake_policy(SET CMP0063 NEW)
+endif()
+set(CMAKE_CXX_VISIBILITY_PRESET hidden)
+set(CMAKE_C_VISIBILITY_PRESET hidden)
+set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
+
+if (CMAKE_GENERATOR MATCHES "Ninja")
+  set(LEX_FLAGS )
+  set(YACC_FLAGS )
+  set(JAVACC_FLAGS )
+else ()
+  set(LEX_FLAGS $(LEX_FLAGS))
+  set(YACC_FLAGS $(YACC_FLAGS))
+  set(JAVACC_FLAGS $(JAVACC_FLAGS))
+endif ()
 
 find_program(DOT NAMES dot)
-find_package(PythonInterp REQUIRED)
+find_package(Python REQUIRED)
 find_package(FLEX REQUIRED)
+if (FLEX_VERSION VERSION_LESS 2.5.37)
+  message(SEND_ERROR "Doxygen requires at least flex version 2.5.37 (installed: ${FLEX_VERSION})")
+endif()
 find_package(BISON REQUIRED)
+if (BISON_VERSION VERSION_LESS 2.7)
+  message(SEND_ERROR "Doxygen requires at least bison version 2.7 (installed: ${BISON_VERSION})")
+endif()
 find_package(Threads)
+find_package(Sanitizers)
 
-if (sqlite3)
-    find_package(SQLite3 REQUIRED)
+if ((CMAKE_BUILD_TYPE STREQUAL "Debug") OR enable_lex_debug)
+  set(LEX_FLAGS "${LEX_FLAGS} -d")
 endif()
 
 find_package(Iconv REQUIRED)
 include_directories(${ICONV_INCLUDE_DIR})
 
 
-#set(DOXYDOCS ${CMAKE_SOURCE_DIR}/doc CACHE INTERNAL "Path to doxygen docs")
-set(DOC_INSTALL_DIR "share/doc/packages/doxygen" CACHE STRING "Relative path where to install the documentation")
-set(EXAMPLE_DIR ${CMAKE_SOURCE_DIR}/examples)
+#set(DOXYDOCS ${PROJECT_SOURCE_DIR}/doc CACHE INTERNAL "Path to doxygen docs")
 set(DOXYDOCS ${PROJECT_BINARY_DIR}/doc)
 set(ENV{DOXYGEN_DOCDIR} ${DOXYDOCS})
-set(GENERATED_SRC "${CMAKE_BINARY_DIR}/generated_src" CACHE INTERNAL "Stores generated files")
+set(GENERATED_SRC "${PROJECT_BINARY_DIR}/generated_src" CACHE INTERNAL "Stores generated files")
 set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
 set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
-set(CUSTOM_INCLUDE_DIR "" CACHE FILEPATH "Extra include path")
-set(CUSTOM_LINK_DIR "" CACHE FILEPATH "Extra library path")
 
 # place binaries for all build types in the same directory, so we know where to find it
 # when running tests or generating docs
@@ -83,27 +182,6 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${EXECUTABLE_OUTPUT_PATH})
 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${EXECUTABLE_OUTPUT_PATH})
 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${EXECUTABLE_OUTPUT_PATH})
 
-# gather lang codes for translation
-file(GLOB lang_files RELATIVE "${CMAKE_SOURCE_DIR}/src" "${CMAKE_SOURCE_DIR}/src/translator_??.h")
-set(lcodes "")
-foreach (_lang ${lang_files})
-  string(REGEX REPLACE "translator_(.*).h" "\\1" _lang_code ${_lang})
-  string(TOUPPER ${_lang_code} lang_code)
-  list(APPEND lcodes "${lang_code}")
-endforeach()
-if (english_only) # user only wants English
-  set(lcodes "ENONLY")
-endif()
-set(LANG_CODES ${lcodes} CACHE STRING "List of language codes for which translations should be compiled in")
-
-if (${CUSTOM_INCLUDE_DIR})
-   include_directories(${CUSTOM_INCLUDE_DIR})
-endif()
-
-if (${CUSTOM_LINK_DIR})
-   link_directories(${CUSTOM_LINK_DIR})
-endif()
-
 if (win_static)
     set(CompilerFlags
         CMAKE_CXX_FLAGS
@@ -121,18 +199,36 @@ if (win_static)
     endforeach()
 endif()
 
+include(cmake/CompilerWarnings.cmake)
+include(cmake/Coverage.cmake)
+include(cmake/WindowsEncoding.cmake)
 
-add_subdirectory(libmd5)
-add_subdirectory(qtools)
+add_subdirectory(deps)
+add_subdirectory(libversion)
+add_subdirectory(libxml)
 add_subdirectory(vhdlparser)
 add_subdirectory(src)
-add_subdirectory(examples)
-add_subdirectory(doc)
 
-add_subdirectory(addon/doxmlparser)
-add_subdirectory(addon/doxyapp)
-add_subdirectory(addon/doxysearch)
-add_subdirectory(addon/doxywizard)
+if (build_doc_chm)
+    if (WIN32)
+          find_package(HTMLHelp REQUIRED)
+          set(build_doc ON)
+    else ()
+          message(WARNING "CHM documentation generation not supported for this platform, ignoring setting.")
+          set(build_doc_chm OFF)
+    endif ()
+endif ()
+
+if (build_doc)
+    add_subdirectory(examples)
+    add_subdirectory(doc)
+endif ()
+
+add_subdirectory(doc_internal)
+add_subdirectory(addon)
 
 enable_testing()
 add_subdirectory(testing)
+
+include(cmake/packaging.cmake) # set CPACK_xxxx properties
+include(CPack)