1 # SPDX-License-Identifier: GPL-2.0-or-later
2 cmake_minimum_required(VERSION 3.12.0)
5 cmake_policy(SET CMP0167 NEW) # use FindBoost from boost 1.70+ (cmake 3.30+)
8 message("------------------------------")
9 message("Building Makefile for Inkscape")
10 message("------------------------------")
11 message("Source Dir: ${CMAKE_CURRENT_SOURCE_DIR}")
12 message("Binary Dir: ${CMAKE_CURRENT_BINARY_DIR}")
14 # -----------------------------------------------------------------------------
16 # -----------------------------------------------------------------------------
17 set(CMAKE_CXX_STANDARD 20)
18 set(CMAKE_CXX_STANDARD_REQUIRED ON)
19 # set(CMAKE_CXX_EXTENSIONS OFF) # enforces -std=c++20 instead of -std=gnu++20
20 # TODO: build currently fails with it as we actually depend on GNU compiler extensions...
21 # mostly use of the non-Standard M_PI et al. TODO: C++20: Use the <numbers> header.
23 list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeScripts/Modules")
25 # avoid having empty buildtype
26 set(CMAKE_BUILD_TYPE_INIT "Release")
28 include(CMakeScripts/HelperFunctions.cmake)
29 include(CMakeScripts/ConfigEnv.cmake)
32 set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME inkscape) # needs to be before any install() commands
34 include(GNUInstallDirs) # for the CMAKE_INSTALL_LIBDIR variable
35 include(CMakeScripts/ConfigPaths.cmake)
36 include(CMakeDependentOption)
38 set(PROJECT_NAME inkscape)
40 # see https://gitlab.com/inkscape/inkscape/-/issues/551 for versioning suffixes
41 set(INKSCAPE_VERSION_MAJOR 1)
42 set(INKSCAPE_VERSION_MINOR 5)
43 set(INKSCAPE_VERSION_PATCH 0)
44 set(INKSCAPE_VERSION_SUFFIX "-dev")
46 set(INKSCAPE_VERSION ${INKSCAPE_VERSION_MAJOR}.${INKSCAPE_VERSION_MINOR})
47 if(INKSCAPE_VERSION_PATCH)
48 set(INKSCAPE_VERSION ${INKSCAPE_VERSION}.${INKSCAPE_VERSION_PATCH})
50 if(INKSCAPE_VERSION_SUFFIX)
51 set(INKSCAPE_VERSION ${INKSCAPE_VERSION}${INKSCAPE_VERSION_SUFFIX})
54 set(CMAKE_INCLUDE_CURRENT_DIR TRUE)
57 INKSCAPE_INSTALL_LIBDIR_RELATIVE_TO_BINDIR
58 "${CMAKE_INSTALL_FULL_BINDIR}"
59 "${CMAKE_INSTALL_FULL_LIBDIR}/inkscape")
62 SET(CMAKE_MACOSX_RPATH TRUE)
63 SET(CMAKE_INSTALL_RPATH "@loader_path/${INKSCAPE_INSTALL_LIBDIR_RELATIVE_TO_BINDIR}")
65 SET(CMAKE_INSTALL_RPATH "$ORIGIN/${INKSCAPE_INSTALL_LIBDIR_RELATIVE_TO_BINDIR}")
68 # this can be removed if/when cmake 3.1 is made the minimum required version
69 set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH ON)
71 # console output is slow as hell on Windows and as a result status messages of the "install" target slow down
72 # the whole build process considerably (especially since we also copy a lot of files from the devlibs)
73 # TODO: Is this worth to be configurable / also applicable to other platforms?
74 if(WIN32 AND NOT CMAKE_INSTALL_MESSAGE)
75 set(CMAKE_INSTALL_MESSAGE "LAZY")
78 # Define a very strict set of build flags that will prevent any use of deprecated symbols.
79 # This will almost certainly cause compilation failure and is intended only for developer use.
80 set(CMAKE_CXX_FLAGS_STRICT "${CMAKE_CXX_FLAGS_DEBUG} -Werror=deprecated-declarations -DGTK_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -DGTKMM_DISABLE_DEPRECATED -DGDKMM_DISABLE_DEPRECATED -DGLIBMM_DISABLE_DEPRECATED"
82 "Flags used by C++ compiler during Strict builds"
84 set(CMAKE_C_FLAGS_STRICT "${CMAKE_C_FLAGS_DEBUG} -Werror=deprecated-declarations -DGTK_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -DGTKMM_DISABLE_DEPRECATED -DGDKMM_DISABLE_DEPRECATED"
86 "Flags used by C compiler during Strict builds"
89 CMAKE_CXX_FLAGS_STRICT
92 set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING
93 "Choose the type of build, options are: None(CMAKE_CXXFLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel Strict."
96 # -----------------------------------------------------------------------------
97 # Redirect output files
98 # -----------------------------------------------------------------------------
99 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR} CACHE PATH "Output directory for runtime binaries")
100 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR} CACHE PATH "Output directory for shared libraries")
101 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR} CACHE PATH "Output directory for static libraries")
103 # -----------------------------------------------------------------------------
105 # -----------------------------------------------------------------------------
106 option(WITH_GNU_READLINE "Compile with GNU Readline support (shell mode)" ON)
107 option(ENABLE_LCMS "Compile with LCMS support" ON)
108 option(WITH_SVG2 "Compile with support for new SVG2 features" ON)
109 option(WITH_LPETOOL "Compile with LPE Tool" OFF)
110 option(LPE_ENABLE_TEST_EFFECTS "Compile with test experimental LPEs enabled" OFF)
111 option(WITH_PROFILING "Turn on profiling" OFF) # Set to true if compiler/linker should enable profiling
112 option(BUILD_SHARED_LIBS "Compile libraries as shared and not static" ON)
114 option(WITH_POPPLER "Compile with support of libpoppler" ON)
115 option(ENABLE_POPPLER_CAIRO "Compile with support of libpoppler-cairo for rendering PDF preview (depends on WITH_POPPLER)" ON)
116 option(WITH_IMAGE_MAGICK "Compile with support of ImageMagick for raster extensions and image import resolution (requires ImageMagick 6; set to OFF if you prefer GraphicsMagick)" ON)
117 option(WITH_GRAPHICS_MAGICK "Compile with support of GraphicsMagick for raster extensions and image import resolution" ON)
118 option(WITH_LIBCDR "Compile with support of libcdr for CorelDRAW Diagrams" ON)
119 option(WITH_LIBVISIO "Compile with support of libvisio for Microsoft Visio Diagrams" ON)
120 option(WITH_LIBWPG "Compile with support of libwpg for WordPerfect Graphics" ON)
121 option(WITH_LIBSPELLING "Compile with support of libspelling" ON)
122 option(WITH_GSOURCEVIEW "Compile with support of gsourceview (text syntax coloring)" ON)
123 option(WITH_NLS "Compile with Native Language Support (using gettext)" ON)
124 option(WITH_JEMALLOC "Compile with JEMALLOC support" OFF)
125 option(WITH_ASAN "Compile with Clang's AddressSanitizer (for debugging purposes)" OFF)
126 option(WITH_INTERNAL_2GEOM "Prefer internal copy of lib2geom" OFF)
127 option(WITH_CROSSINK "Cross-compiling with Crossroads" OFF)
128 cmake_dependent_option(WITH_X11 "Compile with X11 support" ON "UNIX; NOT APPLE" OFF)
130 option(WITH_FUZZ "Compile for fuzzing purpose (use 'make fuzz' only)" OFF)
131 mark_as_advanced(WITH_FUZZ)
132 option(WITH_MANPAGE_COMPRESSION "gzips manpages if gzip is available" ON)
133 mark_as_advanced(WITH_MANPAGE_COMPRESSION)
135 option(ENABLE_BINRELOC "Enable relocatable binaries" OFF)
138 include(CMakeScripts/DefineDependsandFlags.cmake) # Includes, Compiler Flags, and Link Libraries
139 include(CMakeScripts/HelperMacros.cmake) # Misc Utility Macros
141 # -----------------------------------------------------------------------------
142 # BAD HACKS, NEED TO INVESTIGATE MAKING THESE LESS BAD
143 if(BUILD_SHARED_LIBS AND NOT WIN32)
144 add_definitions(-fPIC)
148 # -----------------------------------------------------------------------------
152 # -----------------------------------------------------------------------------
154 # -----------------------------------------------------------------------------
155 add_subdirectory(src)
162 include(CMakeScripts/Pod2man.cmake)
163 add_subdirectory(man)
168 # -----------------------------------------------------------------------------
169 # Check License Headers
170 # -----------------------------------------------------------------------------
171 add_custom_target(check-license-headers WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND ./buildtools/check_license_headers.py)
174 # -----------------------------------------------------------------------------
176 # -----------------------------------------------------------------------------
178 if(BUILD_TESTING OR NOT DEFINED BUILD_TESTING)
181 set(DART_TESTING_TIMEOUT 180 CACHE STRING "Test timeout") # if running for > 180 s something must be wrong)
183 add_subdirectory(testfiles EXCLUDE_FROM_ALL)
185 set(BUILD_TESTING OFF)
186 message(WARNING "No gtest found! Disabling testing...\n"
187 "Consider installing it via package manager (install 'libgtest-dev' or equivalent).")
192 # -----------------------------------------------------------------------------
194 # -----------------------------------------------------------------------------
195 add_custom_target(clean-cmake-files
196 COMMAND "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_SOURCE_DIR}/CMakeScripts/CleanAll.cmake"
199 add_custom_target(clean-all
200 COMMAND ${CMAKE_BUILD_TOOL} clean
201 COMMAND "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_SOURCE_DIR}/CMakeScripts/CleanAll.cmake"
204 # -----------------------------------------------------------------------------
206 # -----------------------------------------------------------------------------
207 add_subdirectory(share)
210 include(CMakeScripts/InstallMSYS2.cmake)
213 # -----------------------------------------------------------------------------
215 # -----------------------------------------------------------------------------
217 add_custom_target(uninstall
218 "${CMAKE_COMMAND}" -E remove_directory "${CMAKE_INSTALL_PREFIX}")
221 "${CMAKE_SOURCE_DIR}/CMakeScripts/cmake_uninstall.cmake.in"
222 "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake"
224 add_custom_target(uninstall
225 "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
228 # -----------------------------------------------------------------------------
230 # -----------------------------------------------------------------------------
231 include(CMakeScripts/Dist.cmake)
233 # -----------------------------------------------------------------------------
235 # -----------------------------------------------------------------------------
236 include(CMakeScripts/ConfigCPack.cmake)
240 # ----------------------------------------------------------------------
241 # Information Summary
242 # ----------------------------------------------------------------------
243 message("------------------------------------------------------------------------")
244 message("Configuration Summary")
245 message("------------------------------------------------------------------------")
247 message("PROJECT_NAME: ${PROJECT_NAME}")
248 message("INKSCAPE_VERSION: ${INKSCAPE_VERSION}")
249 message("INKSCAPE_DIST_PREFIX: ${INKSCAPE_DIST_PREFIX}")
253 message("CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}")
254 message("CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
255 message("CMAKE_INSTALL_LIBDIR: ${CMAKE_INSTALL_LIBDIR}")
256 message("PACKAGE_LOCALE_DIR ${PACKAGE_LOCALE_DIR}")
257 message("CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
258 message("CMAKE_SYSTEM_VERSION: ${CMAKE_SYSTEM_VERSION}")
259 message("CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
260 message("CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}")
261 message("CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}")
262 message("CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
266 message("CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}")
267 message("CMAKE_FIND_LIBRARY_PREFIXES: ${CMAKE_FIND_LIBRARY_PREFIXES}")
268 message("CMAKE_FIND_LIBRARY_SUFFIXES: ${CMAKE_FIND_LIBRARY_SUFFIXES}")
273 message("ENABLE_LCMS: ${ENABLE_LCMS}")
274 message("WITH_POPPLER: ${WITH_POPPLER}")
275 message("ENABLE_POPPLER_CAIRO: ${ENABLE_POPPLER_CAIRO}")
276 message("WITH_GNU_READLINE: ${WITH_GNU_READLINE}")
277 message("WITH_LIBSPELLING: ${WITH_LIBSPELLING}")
278 message("WITH_GSOURCEVIEW: ${WITH_GSOURCEVIEW}")
279 message("WITH_IMAGE_MAGICK: ${WITH_IMAGE_MAGICK}")
280 message("WITH_GRAPHICS_MAGICK: ${WITH_GRAPHICS_MAGICK}")
281 message("WITH_LIBCDR: ${WITH_LIBCDR}")
282 message("WITH_LIBVISIO: ${WITH_LIBVISIO}")
283 message("WITH_LIBWPG: ${WITH_LIBWPG}")
284 message("WITH_NLS: ${WITH_NLS}")
285 message("WITH_JEMALLOC: ${WITH_JEMALLOC}")
286 message("WITH_ASAN: ${WITH_ASAN}")
287 message("WITH_INTERNAL_2GEOM: ${WITH_INTERNAL_2GEOM}")
288 message("WITH_X11: ${WITH_X11}")
290 message("WITH_PROFILING: ${WITH_PROFILING}")
291 message("BUILD_TESTING: ${BUILD_TESTING}")
295 message("HAVE_MINGW64: ${HAVE_MINGW64}")
296 message("MINGW_PATH: ${MINGW_PATH}")
297 message("MINGW_ARCH: ${MINGW_ARCH}")
300 message("------------------------------------------------------------------------")