-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCMakeLists.txt
55 lines (43 loc) · 1.27 KB
/
CMakeLists.txt
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
cmake_minimum_required(VERSION 3.23)
# First argument will be PROJECT_NAME
project(qml6-singleton LANGUAGES CXX)
# We need to find Qt before we can use
# the new Qt CMake API
find_package(Qt6 REQUIRED COMPONENTS Quick)
# Autoconfigures AUTOMOC, AUTORCC, AUTOUIC etc.
qt_standard_project_setup()
qt_policy(SET QTP0001 NEW)
# Create a target executable
qt_add_executable(${PROJECT_NAME})
target_sources(${PROJECT_NAME}
PRIVATE
"main.cpp"
)
# This automatically creates resources,
# so avoid using qt_add_resources() with it.
# If we had a qrc file, we'd put after the first argument.
# This generates a resource like this:
# qrc: + RESOURCE_PREFIX + URI + / + QML_FILES
# so qrc:/qt/qml/com/example/singleton/Main.qml
qt_add_qml_module(${PROJECT_NAME}
URI "com.example.singleton"
VERSION 1.0
QML_FILES
"Main.qml"
)
# Finish by linking the necessary Qt libraries, including our custom target/module
target_link_libraries(${PROJECT_NAME}
PRIVATE
Qt6::Quick
singleton-singletons
)
install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
qt_generate_deploy_qml_app_script(
TARGET ${PROJECT_NAME}
OUTPUT_SCRIPT deployScript
)
install(SCRIPT ${deployScript})
add_subdirectory(qml)