comparison mupdf-source/thirdparty/zint/CMakeLists.txt @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children
comparison
equal deleted inserted replaced
1:1d09e1dec1d9 2:b50eed0cc0ef
1 # Copyright (C) 2008 by BogDan Vatra < bogdan@licentia.eu >
2 # Copyright (C) 2009-2024 Robin Stuart <rstuart114@gmail.com>
3 # vim: set ts=4 sw=4 et :
4
5 cmake_minimum_required(VERSION 3.10)
6 project(zint-package)
7
8 set(CMAKE_INCLUDE_CURRENT_DIR ON)
9
10 set(ZINT_VERSION_MAJOR 2)
11 set(ZINT_VERSION_MINOR 13)
12 set(ZINT_VERSION_RELEASE 0)
13 set(ZINT_VERSION_BUILD 9) # Set to 0 before release, set to 9 after release
14 set(ZINT_VERSION "${ZINT_VERSION_MAJOR}.${ZINT_VERSION_MINOR}.${ZINT_VERSION_RELEASE}.${ZINT_VERSION_BUILD}")
15
16 add_definitions(-DZINT_VERSION=\"${ZINT_VERSION}\")
17
18 option(ZINT_DEBUG "Set debug compile flags" OFF)
19 option(ZINT_NOOPT "Set no optimize compile flags" OFF)
20 option(ZINT_SANITIZE "Set sanitize compile/link flags" OFF)
21 option(ZINT_TEST "Set test compile flag" OFF)
22 option(ZINT_COVERAGE "Set code coverage flags" OFF)
23 option(ZINT_SHARED "Build shared library" ON)
24 option(ZINT_STATIC "Build static library" OFF)
25 option(ZINT_USE_PNG "Build with PNG support" ON)
26 option(ZINT_USE_QT "Build with Qt support" ON)
27 option(ZINT_QT6 "If ZINT_USE_QT, use Qt6" OFF)
28 option(ZINT_UNINSTALL "Add uninstall target" ON)
29 option(ZINT_FRONTEND "Build frontend" ON)
30
31 if(NOT ZINT_SHARED AND NOT ZINT_STATIC)
32 message(SEND_ERROR "Either ZINT_SHARED or ZINT_STATIC or both must be set")
33 endif()
34
35 include(GNUInstallDirs)
36 # Taken from old (2008) KDE "SetPaths.cmake"
37 # Set a default build type for single-configuration CMake generators if no build type is set
38 if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
39 set(CMAKE_BUILD_TYPE RelWithDebInfo)
40 endif()
41
42 include(CheckCCompilerFlag)
43 include(CheckFunctionExists)
44
45 if(NOT MSVC) # Use default warnings if MSVC otherwise inundated
46 check_c_compiler_flag("-Wall" C_COMPILER_FLAG_WALL)
47 if(C_COMPILER_FLAG_WALL)
48 add_compile_options("-Wall")
49 endif()
50
51 check_c_compiler_flag("-Wextra" C_COMPILER_FLAG_WEXTRA)
52 if(C_COMPILER_FLAG_WEXTRA)
53 add_compile_options("-Wextra")
54 endif()
55
56 # gcc complains about "%n$" `errtxtf()` arguments if "-Wpedantic" used, so only use for clang
57 if(CMAKE_C_COMPILER_ID MATCHES "Clang")
58 check_c_compiler_flag("-Wpedantic" C_COMPILER_FLAG_WPEDANTIC)
59 if(C_COMPILER_FLAG_WPEDANTIC)
60 add_compile_options("-Wpedantic")
61 endif()
62 endif()
63
64 check_c_compiler_flag("-Wundef" C_COMPILER_FLAG_WUNDEF)
65 if(C_COMPILER_FLAG_WUNDEF)
66 add_compile_options("-Wundef")
67 endif()
68 endif()
69
70 if(ZINT_DEBUG)
71 check_c_compiler_flag("-g" C_COMPILER_FLAG_G)
72 if(C_COMPILER_FLAG_G)
73 add_compile_options("-g")
74 endif()
75 endif()
76
77 if(ZINT_NOOPT)
78 check_c_compiler_flag("-O0" C_COMPILER_FLAG_O0)
79 if(C_COMPILER_FLAG_O0)
80 add_compile_options("-O0")
81 endif()
82 endif()
83
84 if(ZINT_SANITIZE)
85 if(MSVC)
86 if(MSVC_VERSION GREATER_EQUAL 1920)
87 add_compile_options(-fsanitize=address)
88 message(STATUS "ZINT_SANITIZE: setting -fsanitize=address for MSVC 2019")
89 else()
90 message(STATUS "ZINT_SANITIZE: ignoring for MSVC < 2019")
91 endif()
92 else()
93 set(SANITIZERS address undefined)
94 foreach(sanitizer IN ITEMS ${SANITIZERS})
95 set(CMAKE_REQUIRED_LIBRARIES -fsanitize=${sanitizer})
96 check_c_compiler_flag(-fsanitize=${sanitizer} C_COMPILER_FLAG_FSANITIZE_${sanitizer})
97 if(C_COMPILER_FLAG_FSANITIZE_${sanitizer})
98 add_compile_options(-fsanitize=${sanitizer})
99 link_libraries(-fsanitize=${sanitizer})
100 endif()
101 unset(CMAKE_REQUIRED_LIBRARIES)
102 endforeach()
103
104 if(NOT ZINT_DEBUG AND CMAKE_C_COMPILER_ID MATCHES "GNU")
105 # Gives warning on MainWindow::setupUI() and retries (& takes forever) if var-tracking-assignments enabled
106 add_compile_options(-fno-var-tracking-assignments)
107 endif()
108 if(CMAKE_C_COMPILER_ID MATCHES "Clang")
109 # Recent clangs added deprecation warnings for `sprintf()` that are only triggered on sanitize - suppress
110 add_compile_options(-Wno-deprecated-declarations)
111 endif()
112 endif()
113 endif()
114
115 if(ZINT_TEST)
116 enable_testing()
117 endif()
118
119 if(ZINT_COVERAGE)
120 set(CMAKE_REQUIRED_LIBRARIES -fprofile-arcs)
121 check_c_compiler_flag(--coverage C_COMPILER_FLAG_COVERAGE)
122 unset(CMAKE_REQUIRED_LIBRARIES)
123 if(C_COMPILER_FLAG_COVERAGE)
124 add_compile_options(--coverage)
125 link_libraries(-fprofile-arcs)
126
127 check_c_compiler_flag(-O0 C_COMPILER_FLAG_O0)
128 if(C_COMPILER_FLAG_O0)
129 add_compile_options(-O0)
130 endif()
131 endif()
132 endif()
133
134 check_function_exists(getopt_long_only HAVE_GETOPT_LONG_ONLY)
135 if(NOT HAVE_GETOPT_LONG_ONLY)
136 add_subdirectory(getopt)
137 endif()
138
139 add_subdirectory(backend)
140 if(ZINT_FRONTEND)
141 add_subdirectory(frontend)
142 endif()
143
144 if(NOT ZINT_USE_QT)
145 message(STATUS "Qt support was disabled for this build")
146 elseif(ZINT_QT6 OR ($ENV{CMAKE_PREFIX_PATH} MATCHES "6[.][0-9][.][0-9]"))
147 set(USE_QT6 TRUE)
148 message(STATUS "Using Qt6")
149 cmake_policy(SET CMP0012 NEW) # Recognize constants in if()
150 cmake_policy(SET CMP0072 NEW) # Choose OpenGL over legacy GL
151 find_package(Qt6Widgets)
152 find_package(Qt6Gui)
153 find_package(Qt6UiTools)
154 find_package(Qt6Svg)
155
156 if(Qt6Widgets_FOUND AND Qt6Gui_FOUND AND Qt6UiTools_FOUND AND Qt6Svg_FOUND)
157 message(STATUS "Qt version: " ${Qt6Core_VERSION_MAJOR}.${Qt6Core_VERSION_MINOR}.${Qt6Core_VERSION_PATCH})
158 add_subdirectory(backend_qt)
159 add_subdirectory(frontend_qt)
160 else()
161 message(STATUS "Could NOT find Qt6")
162 endif()
163 else()
164 message(STATUS "Using Qt5")
165 find_package(Qt5Widgets)
166 find_package(Qt5Gui)
167 find_package(Qt5UiTools)
168 find_package(Qt5Svg)
169
170 if(Qt5Widgets_FOUND AND Qt5Gui_FOUND AND Qt5UiTools_FOUND AND Qt5Svg_FOUND)
171 message(STATUS "Qt version: " ${Qt5Core_VERSION_STRING})
172 # Old Qt does not provide QT_VERSION_MAJOR
173 if (NOT QT_VERSION_MAJOR)
174 string(SUBSTRING ${Qt5Core_VERSION_STRING} 0 1 QT_VERSION_MAJOR)
175 endif()
176 add_subdirectory(backend_qt)
177 add_subdirectory(frontend_qt)
178 else()
179 message(STATUS "Could NOT find Qt5")
180 endif()
181 endif()
182
183 if(ZINT_UNINSTALL)
184 configure_file(
185 "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
186 "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
187 IMMEDIATE @ONLY)
188
189 add_custom_target(uninstall
190 "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
191 endif()
192
193 configure_file("zint-config.cmake.in" "zint-config.cmake" @ONLY)
194 install(FILES "${CMAKE_CURRENT_BINARY_DIR}/zint-config.cmake" DESTINATION "${CMAKE_INSTALL_DATADIR}/zint")