-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
56 lines (45 loc) · 1.4 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
56
cmake_minimum_required(VERSION 3.23)
# First argument will be PROJECT_NAME
project(qml5-contextproperty 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()
# This accepts and silences the policy that uses the new RESOURCE_PREFIX
# /qt/qml, which automatically adds all files to the import path.
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/contextproperty/Main.qml
qt_add_qml_module(${PROJECT_NAME}
URI "com.example.contextproperty"
VERSION 0.1
QML_FILES
"Main.qml"
SOURCES
"MyFunctionsFromCppToQml.hpp"
)
# Finish by linking the necessary Qt libraries
target_link_libraries(${PROJECT_NAME}
PRIVATE
Qt::Quick
)
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})