-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
60 lines (46 loc) · 1.31 KB
/
Copy pathCMakeLists.txt
File metadata and controls
60 lines (46 loc) · 1.31 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
cmake_minimum_required(VERSION 3.15)
project(HelloQt VERSION 1.0.0 LANGUAGES CXX)
option(USE_QT6 "use qt6 instead of qt5" OFF)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
# ---
# find either Qt5 or Qt6
# ---
if (USE_QT6)
set(_qt_package_name "Qt6")
else()
set(_qt_package_name "Qt5")
endif()
find_package(${_qt_package_name}
REQUIRED
COMPONENTS Core
HINTS "$ENV{QTDIR}" "$ENV{QT}"
)
message(STATUS "Found ${_qt_package_name}")
# ---
# declare main target
# ---
add_executable(${PROJECT_NAME} main.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE ${_qt_package_name}::Core)
# ---
# include & call the WinDeployQt module
# ---
include(${PROJECT_SOURCE_DIR}/../WinDeployQt.cmake)
# basic versionless invokation (should work for both Qt5 and Qt6)
windeployqt(
TARGET ${PROJECT_NAME} # <-- deploy qt dependencies for this target
DIRECTORY bin # <-- install qt .dlls into a 'bin' subdirectory
DEPLOY_TO_BUILD_DIR # <-- also install qt .dlls in the target's build dir
VERBOSE # <-- pass the '--verbose 1' flag to windeployqt.exe
COMPONENT QtLibraries # <-- sets the 'install(COMPONENT)'
ARGS
"--no-translations" # <-- pass these args directly to windeployqt.exe
)
# ---
# setup install rules
# ---
install(
TARGETS ${PROJECT_NAME}
DESTINATION bin
)