-
Notifications
You must be signed in to change notification settings - Fork 13
/
CMakeLists.txt
147 lines (126 loc) · 5.53 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
cmake_minimum_required(VERSION 3.10)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.12) # Has to be set before `project()`, and ignored on non-macos
project(lokinet-gui
VERSION 0.3.4
DESCRIPTION "Lokinet graphical control panel"
LANGUAGES CXX)
if(WIN32)
enable_language(RC)
endif()
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
option(BUILD_STATIC_DEPS "build every dep statically (ON/OFF)" OFF)
if(BUILD_STATIC_DEPS)
find_package(Git)
if(GIT_FOUND)
function(check_submodule relative_path)
execute_process(COMMAND git rev-parse "HEAD" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${relative_path} OUTPUT_VARIABLE localHead)
execute_process(COMMAND git rev-parse "HEAD:${relative_path}" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE checkedHead)
string(COMPARE EQUAL "${localHead}" "${checkedHead}" upToDate)
if (upToDate)
message(STATUS "Submodule '${relative_path}' is up-to-date")
else()
message(FATAL_ERROR "Submodule '${relative_path}' is not up-to-date. Please update with\ngit submodule update --init --recursive\nor run cmake with -DSUBMODULE_CHECK=OFF")
endif()
endfunction ()
message(STATUS "Checking submodules")
check_submodule(external/loki-mq)
endif()
include(StaticBuild)
add_subdirectory(external/loki-mq)
else()
add_library(oxenmq INTERFACE)
if(OXENMQ_LIBRARIES) # Private option for the macos bundled gui build
target_link_libraries(oxenmq INTERFACE ${OXENMQ_LIBRARIES})
target_include_directories(oxenmq INTERFACE ${OXENMQ_INCLUDE_DIRS})
else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(oxenmq REQUIRED liboxenmq>=1.2.2 IMPORTED_TARGET)
target_link_libraries(oxenmq INTERFACE PkgConfig::oxenmq)
endif()
add_library(oxenmq::oxenmq ALIAS oxenmq)
endif()
find_package(Qt5 COMPONENTS Qml Quick Widgets Charts Svg REQUIRED)
find_package(Threads)
add_executable(lokinet-gui
src/main.cpp
src/QmlClipboardAdapter.cpp
src/HttpClient.cpp
src/LokinetApiClient.cpp
src/ApiPoller.cpp
src/PlatformDetails.cpp
src/BandwidthChartData.cpp
src/process/LokinetProcessManager.cpp
res/resources.qrc
)
target_link_libraries(lokinet-gui PRIVATE
Qt5::Core Qt5::Qml Qt5::Quick Qt5::Widgets Qt5::Charts Qt5::Svg
Threads::Threads
oxenmq
)
if (WIN32)
set(CMAKE_EXE_LINKER_FLAGS "-mwindows -fstack-protector")
endif()
set_target_properties(lokinet-gui
PROPERTIES
CXX_STANDARD 17
CXX_EXTENSIONS OFF
CXX_STANDARD_REQUIRED ON
AUTORCC ON # Enables processing *.qrc in sources
AUTOMOC ON # Does... whatever automoc is
)
if(APPLE)
option(MACOS_APP "Build a LokinetGUI.app bundle instead of a binary" OFF)
set(MACOS_SIGN ""
CACHE STRING "enable codesigning -- use a 'Apple Distribution' key (or key description) from `security find-identity -v`")
target_sources(lokinet-gui PRIVATE src/process/MacOSLokinetProcessManager.cpp)
if(MACOS_APP)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lokinet-gui.icns
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tools/mk-icns.sh ${CMAKE_CURRENT_SOURCE_DIR}/res/images/icon.svg ${CMAKE_CURRENT_BINARY_DIR}/lokinet-gui.icns
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/res/images/icon.svg ${CMAKE_CURRENT_SOURCE_DIR}/tools/mk-icns.sh)
target_sources(lokinet-gui PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/lokinet-gui.icns)
set_target_properties(lokinet-gui
PROPERTIES
MACOSX_BUNDLE TRUE
OUTPUT_NAME LokinetGUI
RESOURCE "${CMAKE_CURRENT_BINARY_DIR}/lokinet-gui.icns")
set(MACOSX_BUNDLE_BUNDLE_NAME LokinetGUI)
set(MACOSX_BUNDLE_GUI_IDENTIFIER org.lokinet.lokinet-gui)
set(MACOSX_BUNDLE_INFO_STRING "Lokinet control panel")
set(MACOSX_BUNDLE_ICON_FILE lokinet-gui.icns)
set(MACOSX_BUNDLE_LONG_VERSION_STRING ${PROJECT_VERSION})
set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION})
set(MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION})
set(MACOSX_BUNDLE_COPYRIGHT "© 2020, The Loki Project")
get_target_property(uic_location Qt5::uic IMPORTED_LOCATION)
get_filename_component(qt_dir ${uic_location} DIRECTORY)
if(MACOS_SIGN)
add_custom_command(TARGET lokinet-gui
POST_BUILD
COMMAND echo "Running qt magic macos deploy script"
COMMAND "${qt_dir}/macdeployqt" LokinetGUI.app -always-overwrite -qmldir=${PROJECT_SOURCE_DIR}/res
COMMAND echo "Signing LokinetGUI.app and everything inside it"
COMMAND codesign -s "${MACOS_SIGN}" --deep --strict --options runtime --force -vvv LokinetGUI.app
)
else()
add_custom_command(TARGET lokinet-gui
POST_BUILD
COMMAND echo "Running qt magic macos deploy script"
COMMAND "${qt_dir}/macdeployqt" LokinetGUI.app -always-overwrite -qmldir=${PROJECT_SOURCE_DIR}/res
)
endif()
endif()
elseif(WIN32)
target_sources(lokinet-gui PRIVATE src/process/WindowsLokinetProcessManager.cpp src/version.rc)
else()
option(SYSTEMD "Enable systemd support" OFF)
if(SYSTEMD)
target_sources(lokinet-gui PRIVATE src/process/SystemdLokinetProcessManager.cpp)
target_compile_definitions(lokinet-gui PRIVATE SYSTEMD)
else()
target_sources(lokinet-gui PRIVATE src/process/LinuxLokinetProcessManager.cpp)
endif()
endif()
install(TARGETS lokinet-gui
RUNTIME DESTINATION bin
BUNDLE DESTINATION .
RESOURCE DESTINATION .)