Repository navigation
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
306 lines (271 loc) · 14.2 KB
/
Copy pathCMakeLists.txt
File metadata and controls
306 lines (271 loc) · 14.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
# Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
# SPDX-License-Identifier: BSD-3-Clause
#
# --------------------------------------------------------------------------
# $Maintainer: Timo Sachsenberg $
# $Authors: Timo Sachsenberg $
# --------------------------------------------------------------------------
#------------------------------------------------------------------------------
# OpenMS-TOPP-GUI: the Qt GUI layer of OpenMS (the OpenMS_GUI library, TOPPView,
# TOPPAS, INIFileEditor and the Qt-based TOPP tools ExecutePipeline and
# ImageCreator), built against an installed OpenMS core of the same version.
#
# cmake -S . -B build -DCMAKE_PREFIX_PATH="<OpenMS prefix or SDK>;<Qt prefix>"
#
# The OpenMS installation must provide the core and CLI layers (OpenMS::OpenMS,
# OpenMS::OpenMS_CLI), e.g. the OpenMS SDK of the matching release or nightly.
#------------------------------------------------------------------------------
cmake_minimum_required(VERSION 3.24 FATAL_ERROR)
## The version of this repository is the version of the OpenMS core it is built
## against (find_package(OpenMS ... EXACT) below). tools/update_version_numbers.sh
## bumps it together with the test data.
set(OPENMS_GUI_VERSION 3.7.0)
# Handle default build type
get_property(_openms_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(NOT _openms_multi_config AND NOT DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build.")
endif()
project("OpenMS_TOPP_GUI" VERSION ${OPENMS_GUI_VERSION} LANGUAGES CXX)
## AutoMoc does not need the compiler's predefined macros (and collecting them is slow)
set(CMAKE_AUTOMOC_COMPILER_PREDEFINES OFF)
#------------------------------------------------------------------------------
# Module path
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/Modules")
## CMake looks for the NSIS script template in the module path.
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/Windows")
if (MINGW OR MSYS)
message(FATAL_ERROR "MSYS and/or MinGW are not supported! Please use a Visual Studio environment!")
endif()
#------------------------------------------------------------------------------
# Options
#------------------------------------------------------------------------------
option(ENABLE_CLASS_TESTING "Build the class tests of the GUI library." ON)
option(ENABLE_TOPP_TESTING "Add the tests of the GUI TOPP tools (ExecutePipeline, ImageCreator)." ON)
option(ENABLE_PIPELINE_TESTING "Add the TOPPAS pipeline tests (ExecutePipeline on the example workflows)." ON)
option(HAS_XSERVER "Indicates if a display is available (or QT_QPA_PLATFORM=offscreen is used). If OFF, the tests that open windows are disabled." ON)
option(ENABLE_DOCS "Add the documentation targets (doc, doc_class_only, ...)." ON)
option(ENABLE_TUTORIALS "Build the GUI code examples of the tutorials." ON)
option(NO_WEBENGINE_WIDGETS "Do not use QtWebEngineWidgets. Disables the JavaScript views in TOPPView." OFF)
## The packages do not deploy QtWebEngine (its helper process and resources), so they are
## always built without it. A normal variable for this configure only: the cache entry is
## kept, so a later configure with PACKAGE_TYPE none uses QtWebEngineWidgets again.
if(DEFINED PACKAGE_TYPE AND NOT "${PACKAGE_TYPE}" STREQUAL "none" AND NOT NO_WEBENGINE_WIDGETS)
message(STATUS "Packaging: QtWebEngineWidgets is not deployed, building with NO_WEBENGINE_WIDGETS=ON")
set(NO_WEBENGINE_WIDGETS ON)
endif()
option(OPENMS_TEST_INSTALLED_CONSUMER "Add a test that installs the GUI layer next to the OpenMS core and builds an external project against it." OFF)
#------------------------------------------------------------------------------
# Version information
#------------------------------------------------------------------------------
set(OPENMS_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
set(OPENMS_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
set(OPENMS_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
set(OPENMS_PACKAGE_VERSION "${PROJECT_VERSION}")
message(STATUS "Building OpenMS-TOPP-GUI ${OPENMS_PACKAGE_VERSION}")
#------------------------------------------------------------------------------
# Host directories (the names of the OpenMS build system, used by the moved code)
set(OPENMS_HOST_DIRECTORY "${PROJECT_SOURCE_DIR}")
set(OPENMS_HOST_BINARY_DIRECTORY "${PROJECT_BINARY_DIR}")
#------------------------------------------------------------------------------
# Compiler checks and flags
#------------------------------------------------------------------------------
include(cmake/min_compiler_versions.cmake)
include(cmake/compiler_flags.cmake)
if (NOT CMAKE_CXX_VISIBILITY_PRESET)
set(CMAKE_CXX_VISIBILITY_PRESET "hidden")
endif()
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
option(ENABLE_IPO "Enable interprocedural optimizations (LTO)" OFF)
if(ENABLE_IPO)
include(CheckIPOSupported)
check_ipo_supported(RESULT _ipo_supported OUTPUT _ipo_output)
if(_ipo_supported)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
else()
message(SEND_ERROR "IPO/LTO is not supported: ${_ipo_output}")
endif()
endif()
option(ADDRESS_SANITIZER "Enable AddressSanitizer mode (quite slow)." OFF)
include(${PROJECT_SOURCE_DIR}/cmake/AddressSanitizer.cmake)
# we build shared libraries
set(BUILD_SHARED_LIBS true)
#------------------------------------------------------------------------------
# CMake utilities
#------------------------------------------------------------------------------
include(${PROJECT_SOURCE_DIR}/cmake/build_system_macros.cmake)
include(${PROJECT_SOURCE_DIR}/cmake/install_macros.cmake)
include(${PROJECT_SOURCE_DIR}/cmake/doc_macros.cmake)
include(${PROJECT_SOURCE_DIR}/cmake/add_library_macros.cmake)
include(${PROJECT_SOURCE_DIR}/cmake/export_macros.cmake)
include(${PROJECT_SOURCE_DIR}/cmake/topp_tool_macros.cmake)
#------------------------------------------------------------------------------
# Package type
set(VALID_PACKAGE_TYPES "none" # make/make install
"deb" # Debian package, installed on top of the openms package
"rpm" # RPM package, installed on top of the openms package
"pkg" # macOS productbuild installer, installed into the OpenMS folder
"nsis") # Windows installer, installed into the OpenMS installation
set(PACKAGE_TYPE "none" CACHE STRING "Package type: ${VALID_PACKAGE_TYPES}")
message(STATUS "Package type is '${PACKAGE_TYPE}'")
is_valid_package(${PACKAGE_TYPE})
## The install component of the GUI applications (and everything else that
## belongs to them at run time: the tool registry entry, the style sheet, ...).
set(OPENMS_GUI_APPLICATIONS_COMPONENT GUIApplications)
## macOS code signing and notarization configuration
## SIGNING_IDENTITY - Developer ID Application certificate identity
## SIGNING_EMAIL - Apple ID email for notarization
## CPACK_PRODUCTBUILD_IDENTITY_NAME - Developer ID Installer certificate identity (for .pkg)
## APPLE_APP_SPECIFIC_NOTARIZATION_PASSWORD environment variable - app-specific password
if("${PACKAGE_TYPE}" STREQUAL "pkg")
if (NOT DEFINED SIGNING_IDENTITY OR "${SIGNING_IDENTITY}" STREQUAL "" OR "${SIGNING_IDENTITY}" STREQUAL "-")
message(WARNING "Trying to create a macOS package without SIGNING_IDENTITY being set. "
"Using the ad hoc identity. The package will NOT be notarized.")
set(CPACK_BUNDLE_APPLE_CERT_APP "-")
else()
set(CPACK_BUNDLE_APPLE_CERT_APP "${SIGNING_IDENTITY}")
message(STATUS "Code signing identity: ${SIGNING_IDENTITY}")
endif()
if (NOT DEFINED SIGNING_EMAIL OR "${SIGNING_EMAIL}" STREQUAL "")
message(STATUS "SIGNING_EMAIL not set. Notarization will be skipped.")
endif()
endif()
#------------------------------------------------------------------------------
# Output directories. Everything that runs goes to bin/ (GUI applications, GUI
# TOPP tools, tests, documenters), so on Windows the DLLs only need to be
# copied there once.
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
set(OPENMS_BINARY_DIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
set(OPENMS_SHARE_DIR "${PROJECT_SOURCE_DIR}/share/OpenMS")
## The registry of the GUI TOPP tools, OpenMS-GUI.tsv. ToolHandler reads every *.tsv
## of share/OpenMS/TOOLS, so installed next to the core's OpenMS.tsv it adds these tools.
set(OPENMS_TOOL_REGISTRY_BUILD_DIR "${PROJECT_BINARY_DIR}/share/OpenMS/TOOLS")
set(OPENMS_TOOL_REGISTRY_BUILD_FILE "${OPENMS_TOOL_REGISTRY_BUILD_DIR}/OpenMS-GUI.tsv")
#------------------------------------------------------------------------------
# Installation directories. They must equal those of the OpenMS core: the GUI
# layer is installed into the core's prefix (libOpenMS resolves the share
# directory, the tool registry and the TOPP executables relative to the
# executable).
set(INSTALL_BIN_DIR bin CACHE PATH "Installation directory for executables")
set(INSTALL_SHARE_DIR share/OpenMS CACHE PATH "Installation directory for shared data")
set(INSTALL_DOC_DIR share/doc CACHE PATH "Installation directory for documentation")
set(INSTALL_INCLUDE_DIR include CACHE PATH "Installation directory for header files")
if(WIN32)
set(DEF_INSTALL_CMAKE_DIR CMake)
set(DEF_INSTALL_LIB_DIR bin)
else()
set(DEF_INSTALL_CMAKE_DIR lib/cmake/OpenMSGUI)
set(DEF_INSTALL_LIB_DIR lib)
endif()
set(INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH "Installation directory for the CMake package of the GUI library")
set(INSTALL_LIB_DIR ${DEF_INSTALL_LIB_DIR} CACHE PATH "Installation directory for libraries")
set(INSTALL_PLUGIN_SUBDIR plugins CACHE PATH "Installation subdirectory under the lib dir for Qt plugins")
set(INSTALL_PLUGIN_DIR ${INSTALL_LIB_DIR}/${INSTALL_PLUGIN_SUBDIR})
file(RELATIVE_PATH INSTALL_LIB_PATH_REL_TO_BIN /${INSTALL_BIN_DIR} /${INSTALL_LIB_DIR})
if(INSTALL_LIB_PATH_REL_TO_BIN STREQUAL "")
## lib == bin (Windows): the plugins are next to the executables
set(QT_PLUGIN_PATH_REL_TO_BIN ${INSTALL_PLUGIN_SUBDIR})
else()
set(QT_PLUGIN_PATH_REL_TO_BIN ${INSTALL_LIB_PATH_REL_TO_BIN}/${INSTALL_PLUGIN_SUBDIR})
endif()
#------------------------------------------------------------------------------
# RPATH (as in the OpenMS core)
if(UNIX)
if(NOT DEFINED CMAKE_SKIP_BUILD_RPATH)
set(CMAKE_SKIP_BUILD_RPATH FALSE)
endif()
if(NOT DEFINED CMAKE_MACOSX_RPATH)
set(CMAKE_MACOSX_RPATH TRUE)
endif()
if(NOT DEFINED CMAKE_BUILD_WITH_INSTALL_RPATH)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR FALSE)
endif()
# A plain installation finds the libraries it was linked against (the OpenMS
# core, Qt) through their directories in the install RPATH. Packages are
# installed into the core's prefix and use the relative RPATH below instead.
if (NOT DEFINED CMAKE_INSTALL_RPATH_USE_LINK_PATH)
if (APPLE)
if (NOT "${PACKAGE_TYPE}" STREQUAL "pkg")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
endif()
elseif ("${PACKAGE_TYPE}" STREQUAL "none")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
endif()
endif()
if(NOT DEFINED CMAKE_INSTALL_RPATH)
if (APPLE)
if(NOT "${PACKAGE_TYPE}" STREQUAL "pkg")
set(CMAKE_INSTALL_RPATH "@executable_path/${INSTALL_LIB_PATH_REL_TO_BIN}/;@loader_path/;${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
else()
set(CMAKE_INSTALL_RPATH "@executable_path/${INSTALL_LIB_PATH_REL_TO_BIN}/")
endif()
else()
set(CMAKE_INSTALL_RPATH "$ORIGIN/${INSTALL_LIB_PATH_REL_TO_BIN}/")
endif()
endif()
endif()
if (MSVC)
## OpenMS_GUId.dll etc. in debug mode, like the core
if(NOT DEFINED CMAKE_DEBUG_POSTFIX)
set(CMAKE_DEBUG_POSTFIX "d")
endif()
endif()
#------------------------------------------------------------------------------
# Dependencies: the installed OpenMS core and Qt
#------------------------------------------------------------------------------
include(cmake/third_party_notices.cmake)
include(cmake/find_openms.cmake)
if(ENABLE_DOCS)
find_package(Doxygen)
endif()
#------------------------------------------------------------------------------
# The code
#------------------------------------------------------------------------------
## here, not in src/, so that ctest finds the tests from the top of the build tree
enable_testing()
add_subdirectory(src)
#------------------------------------------------------------------------------
# Documentation
#------------------------------------------------------------------------------
if(ENABLE_DOCS OR ENABLE_TUTORIALS)
add_subdirectory(doc)
endif()
#------------------------------------------------------------------------------
# CMake package of the GUI library (OpenMSGUIConfig.cmake)
#------------------------------------------------------------------------------
openms_export_targets()
install_export_targets()
#------------------------------------------------------------------------------
# Installation and packaging
#------------------------------------------------------------------------------
## The packages install the GUI layer into the installation of the OpenMS core of the same
## version (cmake/package_general.cmake). A plain 'cmake --install' (PACKAGE_TYPE none)
## installs it into CMAKE_INSTALL_PREFIX, which should be the core's prefix too.
include(cmake/third_party_licenses.cmake)
if(NOT "${PACKAGE_TYPE}" STREQUAL "none")
include(cmake/package_general.cmake)
if("${PACKAGE_TYPE}" STREQUAL "pkg")
set(CPACK_GENERATOR "productbuild")
include(cmake/package_mac_productbuild.cmake)
elseif("${PACKAGE_TYPE}" STREQUAL "rpm")
set(CPACK_GENERATOR "RPM")
include(cmake/package_rpm.cmake)
elseif("${PACKAGE_TYPE}" STREQUAL "deb")
set(CPACK_GENERATOR "DEB")
include(cmake/package_deb.cmake)
elseif("${PACKAGE_TYPE}" STREQUAL "nsis")
set(CPACK_GENERATOR "NSIS")
include(cmake/package_nsis.cmake)
endif()
include(CPack)
include(cmake/package_components.cmake)
endif()
## share/OpenMS/THIRD-PARTY-NOTICES-GUI.txt from the license files recorded above (and the
## copyright file of the Debian package)
openms_install_third_party_notices()
#------------------------------------------------------------------------------
# Final messages
#------------------------------------------------------------------------------
include(cmake/messages.cmake)