-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
109 lines (88 loc) · 2.51 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
cmake_minimum_required(VERSION 3.1)
project(qalarm VERSION 1.0 LANGUAGES CXX)
# enable debug via cmd
# cmake -DDEFINE_DEBUG=ON -DCMAKE_INSTALL_PREFIX=/usr ..
option(DEFINE_DEBUG
"Build using debug"
OFF)
if(DEFINE_DEBUG)
message("Adding Debug flag...")
add_definitions(-DDEBUG)
set(CMAKE_BUILD_TYPE Debug)
message("Build type is " ${CMAKE_BUILD_TYPE})
endif(DEFINE_DEBUG)
# debug, enable debugging
# https://doc.qt.io/qt-5/qtquick-debugging.html#qml-debugging-infrastructure
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DQT_QML_DEBUG ")
message(STATUS "debug enabled")
endif (CMAKE_BUILD_TYPE STREQUAL "Debug")
# set output directories
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/$<CONFIG>) # /lib
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/$<CONFIG>) # /lib
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/$<CONFIG>) # /bin
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON) # for compiling qrc file to rcc
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# widgets for systray qapplication
find_package(Qt5 COMPONENTS REQUIRED Core Quick Widgets QuickWidgets)
set(SOURCES
src/main.cpp
)
set(HEADERS
)
set(RESOURCES
src/qml.qrc
res/qml.qrc
)
# for future use
if(ANDROID)
message(STATUS "Build: Android")
# as library
add_library(
${PROJECT_NAME} SHARED
${SOURCES}
${HEADERS}
${RESOURCES}
)
else()
message(STATUS "Build: Desktop")
# as executable
add_executable(
${PROJECT_NAME}
${SOURCES}
${HEADERS}
${RESOURCES} # App resources file
)
endif()
target_compile_definitions(
${PROJECT_NAME}
PRIVATE
$<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>
)
target_link_libraries(
${PROJECT_NAME}
PRIVATE
Qt5::Core
Qt5::Quick
Qt5::Widgets
Qt5::QuickWidgets
)
# plugins dir (external to binary)
add_subdirectory(plugin)
# more android specifics
# https://github.com/LaurentGomila/qt-android-cmake
if(ANDROID)
include(android/AddQtAndroidApk.cmake)
add_qt_android_apk(
"apk_name" ${PROJECT_NAME}
NAME "My App"
VERSION_CODE 1 # incremented everytime your app is updated on the play store
PACKAGE_NAME "io.bitshift.qalarm"
PACKAGE_SOURCES ${CMAKE_CURRENT_LIST_DIR}/android
KEYSTORE ${CMAKE_CURRENT_LIST_DIR}/mykey.keystore myalias
INSTALL # install to default adb device
)
endif()