-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathlinux-static-configure.cmake
More file actions
75 lines (66 loc) · 2.52 KB
/
linux-static-configure.cmake
File metadata and controls
75 lines (66 loc) · 2.52 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
#
# Configure the AppLauncher project using a statically built Qt and a Linux-based environment.
#
# This script sets up the Linux build environment, generates an initial CMake cache,
# and runs `cmake` to configure the project in a given build directory.
#
# Usage:
#
# cmake \
# -DQt5_DIR:PATH=/path/to/qt/lib/cmake/Qt5 \
# -DCTKAppLauncher_BUILD_DIR:PATH=/path/to/build \
# -DCTKAppLauncher_SOURCE_DIR:PATH=/path/to/src \
# -P /path/to/linux-static-configure.cmake
#
# Required variables:
# - Qt5_DIR: Path to the static Qt installation's CMake config
# - CTKAppLauncher_BUILD_DIR: Destination directory for the CMake build
#
# Optional:
# - CTKAppLauncher_SOURCE_DIR: If not set, defaults to ${CMAKE_CURRENT_SOURCE_DIR}
#
# Prebuilt static Qt archives can be found at:
# https://github.com/jcfr/qt-static-build
#
if(NOT EXISTS "${Qt5_DIR}")
message(FATAL_ERROR "Qt5_DIR is set to a non-existent directory [${Qt5_DIR}]")
endif()
if(NOT DEFINED CTKAppLauncher_SOURCE_DIR)
set(CTKAppLauncher_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}")
endif()
if(NOT EXISTS "${CTKAppLauncher_SOURCE_DIR}")
message(FATAL_ERROR "CTKAppLauncher_SOURCE_DIR is set to a non-existent directory [${CTKAppLauncher_SOURCE_DIR}]")
endif()
message(STATUS "Setting CTKAppLauncher_SOURCE_DIR: ${CTKAppLauncher_SOURCE_DIR}")
if(NOT DEFINED CTKAppLauncher_BUILD_DIR)
message(FATAL_ERROR "CTKAppLauncher_BUILD_DIR is not set")
endif()
if(NOT EXISTS "${CTKAppLauncher_BUILD_DIR}")
message(FATAL_ERROR "CTKAppLauncher_BUILD_DIR is set to a non-existent directory [${CTKAppLauncher_BUILD_DIR}]")
endif()
message(STATUS "Setting CTKAppLauncher_BUILD_DIR: ${CTKAppLauncher_BUILD_DIR}")
# Set QT_PREFIX_DIR assuming standard static Qt layout
set(QT_PREFIX_DIR "${Qt5_DIR}/../../../")
get_filename_component(QT_PREFIX_DIR ${QT_PREFIX_DIR} ABSOLUTE)
message(STATUS "Setting QT_PREFIX_DIR: ${QT_PREFIX_DIR}")
# Dependencies of QPA plugin needed for running GUI based application
# and avoid runtime error: qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""
set(qt_qpa_plugin_static_libraries
${QT_PREFIX_DIR}/plugins/platforms/libqxcb.a
)
set(qt_static_libraries
${qt_qpa_plugin_static_libraries}
)
set(INITIAL_CACHE "
CMAKE_BUILD_TYPE:STRING=Release
BUILD_TESTING:BOOL=1
CTKAppLauncher_QT_STATIC_LIBRARIES:STRING=${qt_static_libraries}
Qt5_DIR:PATH=${Qt5_DIR}"
)
file(WRITE ${CTKAppLauncher_BUILD_DIR}/CMakeCache.txt "${INITIAL_CACHE}")
execute_process(COMMAND
${CMAKE_COMMAND}
-G Ninja
-S ${CTKAppLauncher_SOURCE_DIR}
-B ${CTKAppLauncher_BUILD_DIR}
)