-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
42 lines (29 loc) · 1.42 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
#
# For basic cmake file structure see: http://doc.qt.io/qt-5/cmake-manual.html
#
cmake_minimum_required(VERSION 2.8.11)
project(myproject)
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
# Find the Qt libraries for Qt Quick/QML
find_package(Qt5 REQUIRED Qml Quick Gui)
# add the qml.qrc file
qt5_add_resources(qml_QRC src/qml.qrc)
# add source files
set(SOURCE
${SOURCE}
src/main.cpp
)
# Tell CMake to create the helloworld executable
add_executable(helloworld ${SOURCE} ${qml_QRC})
# Use the Qml/Quick modules from Qt 5.
target_link_libraries(helloworld Qt5::Qml Qt5::Quick)
# post-build steps
# copy all the Qt support files to the debug/release directories
# You really only need the proper qt redistibution dll's/files, but this copies everything for easier development. Trim files out as needed.
message("Copying required Qt libraries and binaries to output directory....")
add_custom_command(TARGET helloworld POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_PREFIX_PATH}\\bin $<TARGET_FILE_DIR:helloworld>)
add_custom_command(TARGET helloworld POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_PREFIX_PATH}\\plugins $<TARGET_FILE_DIR:helloworld>)
add_custom_command(TARGET helloworld POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_PREFIX_PATH}\\qml $<TARGET_FILE_DIR:helloworld>)