-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathCMakeLists.txt
130 lines (109 loc) · 3.22 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
cmake_minimum_required(VERSION 3.9)
project(Robocut
VERSION 1.0.11
DESCRIPTION "A program to control Graphtec vinyl cutters."
LANGUAGES C CXX)
# Set the CMAKE_PREFIX_PATH environment variable to (e.g) ~/Qt/5.8/clang_64 so it can find Qt.
find_package(Qt5 COMPONENTS Core Widgets Svg REQUIRED)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
add_subdirectory(libusb)
set(src_files
"main.cpp"
"MainWindow.cpp"
"Plotter.cpp"
"Common.cpp"
"PathPaintEngine.cpp"
"CutDialog.cpp"
"CuttingDialog.cpp"
"CuttingThread.cpp"
"PathPaintPage.cpp"
"PathSorter.cpp"
"ProgramOptions.cpp"
"MainWindow.h"
"Plotter.h"
"NoCopy.h"
"Common.h"
"PathPaintEngine.h"
"CutDialog.h"
"CuttingDialog.h"
"CuttingThread.h"
"PathPaintPage.h"
"PathSorter.h"
"ProgramOptions.h"
"MainWindow.ui"
"CutDialog.ui"
"CuttingDialog.ui"
"Resources.qrc"
)
if (WIN32)
# Windows icon.
list(APPEND src_files "WindowsResources.rc")
elseif (APPLE)
# OSX Icon
# This is the property added to Info.plist
set(MACOSX_BUNDLE_ICON_FILE "Robocut.icns")
# Add the file to the source.
set(osx_icon_file "${CMAKE_SOURCE_DIR}/icon/Robocut.icns")
set_source_files_properties("${osx_icon_file}" PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
list(APPEND src_files "${osx_icon_file}")
endif ()
# Automatically generate moc, UI & Resource Files
set(CMAKE_AUTOMOC TRUE)
set(CMAKE_AUTOUIC TRUE)
set(CMAKE_AUTORCC TRUE)
add_executable(Robocut MACOSX_BUNDLE WIN32
${src_files}
)
target_link_libraries(Robocut
Qt5::Widgets
Qt5::Svg
libusb
)
target_compile_definitions(Robocut PRIVATE "-DROBOCUT_VERSION=\"${PROJECT_VERSION}\"")
# Packaging
if (WIN32)
add_custom_target(pack
# Make a temporary directory for the zip.
COMMAND "${CMAKE_COMMAND}" "-E" "make_directory" "${CMAKE_BINARY_DIR}/Zip/Robocut"
# Copy the EXE there.
COMMAND "${CMAKE_COMMAND}" "-E" "copy" "$<TARGET_FILE:Robocut>"
"${CMAKE_BINARY_DIR}/Zip/Robocut/Robocut.exe"
# Deploy Qt to that directory. All the options are to save space.
COMMAND "${_qt5Core_install_prefix}/bin/windeployqt.exe" "--release" "--compiler-runtime"
"--no-angle" "--no-opengl-sw" "--no-translations" "--no-system-d3d-compiler"
"${CMAKE_BINARY_DIR}/Zip/Robocut/Robocut.exe"
DEPENDS Robocut
COMMENT "Deploying Qt"
VERBATIM
)
# Zip the result
add_custom_target(artefact
COMMAND 7z a "${CMAKE_BINARY_DIR}/Robocut-${PROJECT_VERSION}.zip"
"${CMAKE_BINARY_DIR}/Zip/Robocut"
DEPENDS pack
COMMENT "Creating Zip"
VERBATIM
)
elseif (APPLE)
# Note there is a slight bug (https://bugreports.qt.io/browse/QTBUG-60324) in macdeployqt
# which means we really want the working directory to be the place where the dmg is generated.
add_custom_target(artefact
COMMAND "${_qt5Core_install_prefix}/bin/macdeployqt" "Robocut.app" "-dmg"
COMMAND "${CMAKE_COMMAND}" "-E" "rename" "${CMAKE_BINARY_DIR}/Robocut.dmg"
"${CMAKE_BINARY_DIR}/Robocut-${PROJECT_VERSION}.dmg"
DEPENDS Robocut
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
COMMENT "Creating DMG"
VERBATIM
)
else ()
# This is just here for consistency with platforms that don't produce zip or dmg.
add_custom_Target(artefact
DEPENDS Robocut
COMMENT "Not generating build artefact"
VERBATIM
)
install(TARGETS Robocut
RUNTIME DESTINATION bin)
endif ()