-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
153 lines (126 loc) · 4.12 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
148
149
150
151
152
cmake_minimum_required(VERSION 3.9)
project(sailify VERSION 0.1.0 LANGUAGES C CXX)
set(PACKAGE_NAME harbour-sailify)
set(CMAKE_CXX_STANDARD 17)
set(SAILFISHOS ON)
set(BUILD_SHARED_LIBS OFF)
include(FindPkgConfig)
# Sailfish App
pkg_search_module(SAILFISHAPP sailfishapp REQUIRED)
# PulseAudio
pkg_search_module(PULSE libpulse REQUIRED)
pkg_search_module(PULSE_SIMPLE libpulse-simple REQUIRED)
## Set RPATH
set(CMAKE_BUILD_WITH_INSTALL_RPATH OFF)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH OFF)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/share/${PACKAGE_NAME}/lib") # "${LIB_INSTALL_DIR}")
# booster support
set(CMAKE_ENABLE_EXPORTS ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN hidden)
# Qt
find_package(Qt5 REQUIRED COMPONENTS Core DBus Network Gui Quick)
add_definitions(-DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x050600 -DQT_USE_QSTRINGBUILDER)
if(NOT ${CMAKE_BUILD_TYPE} STREQUAL "Debug")
add_definitions(-DQT_NO_DEBUG_OUTPUT -DQT_NO_DEBUG)
endif()
add_definitions(-DSAILFISHOS)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# cbindgen
set(sailifyplayer_HEADER "${CMAKE_CURRENT_BINARY_DIR}/sailifyplayer.h")
file(GLOB sailifyplayer_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.rs")
add_custom_target(
sailifyplayer_header
COMMENT cbindgen sailifyplayer
COMMAND cbindgen --crate sailifyplayer --output "${sailifyplayer_HEADER}"
BYPRODUCTS ${sailifyplayer_HEADER}
DEPENDS ${sailifyplayer_SOURCES}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
)
set_property(SOURCE "${sailifyplayer_HEADER}" PROPERTY SKIP_AUTOMOC ON)
# sailifyplayer
set(CARGO_ARGS)
# TODO: other profiles exist
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(TARGET_DIR "debug")
else()
list(APPEND CARGO_ARGS --release)
set(TARGET_DIR "release")
endif()
if (NOT DEFINED RUST_TARGET_DIR)
set(RUST_TARGET_DIR "${CMAKE_CURRENT_BINARY_DIR}")
endif()
add_library(sailifyplayer STATIC IMPORTED)
set_property(TARGET sailifyplayer PROPERTY IMPORTED_LOCATION "${RUST_TARGET_DIR}/libsailifyplayer.a")
target_link_libraries(sailifyplayer INTERFACE
-lpthread -ldl -lm
${PULSE_LDFLAGS} ${PULSE_SIMPLE_LDFLAGS})
#add_custom_target(
# sailifyplayer
# COMMENT Cargo sailifyplayer
# COMMAND CARGO_TARGET_DIR=${CMAKE_CURRENT_BINARY_DIR}/sailifyplayer cargo build ${CARGO_ARGS}
# BYPRODUCTS ${SAILIFYPLAYER_LIB}
# DEPENDS ${sailifyplayer_SOURCES}
# WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
# )
# include(ExternalProject)
# set_directory_properties(PROPERTIES EP_PREFIX ${CMAKE_BINARY_DIR}/sailifyplayer2)
# ExternalProject_Add(
# sailifyplayer2
# DOWNLOAD_COMMAND ""
# CONFIGURE_COMMAND ""
# BUILD_COMMAND CARGO_TARGET_DIR=${CMAKE_CURRENT_BINARY_DIR} cargo build ${CARGO_ARGS}
# BINARY_DIR "${CMAKE_SOURCE_DIR}/common-rust"
# INSTALL_COMMAND ""
# LOG_BUILD ON)
# App
set(CONFIG_SOURCE src/sailify-config.cpp)
file(GLOB_RECURSE sailify_QML_SOURCES "qml/*.qml")
set(SAILIFY_SOURCES
src/sailify.cpp
src/sailify-player.cpp
${sailify_QML_SOURCES}
${sailifyplayer_HEADER}
${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_SOURCE}
)
configure_file(
${CONFIG_SOURCE}.in ${CONFIG_SOURCE}
@ONLY
)
add_executable(sailify ${SAILIFY_SOURCES})
set_target_properties(sailify
PROPERTIES
OUTPUT_NAME ${PACKAGE_NAME}
)
add_dependencies(sailify sailifyplayer_header)
target_include_directories(sailify
PRIVATE
${SAILFISHAPP_INCLUDE_DIRS}
)
target_link_libraries(sailify
Qt5::Core Qt5::DBus Qt5::Network Qt5::Gui Qt5::Quick
${SAILFISHAPP_LDFLAGS}
sailifyplayer
)
install(TARGETS sailify
RUNTIME DESTINATION bin
)
install(DIRECTORY qml
DESTINATION share/${PACKAGE_NAME}
)
# install(DIRECTORY translations
# DESTINATION share/${PACKAGE_NAME}
# FILES_MATCHING PATTERN "*.qm"
# )
install(FILES ${PACKAGE_NAME}.desktop
DESTINATION share/applications
)
foreach(size 86 108 128 172)
install(FILES res/${size}x${size}/${PACKAGE_NAME}.png
DESTINATION share/icons/hicolor/${size}x${size}/apps
)
endforeach()
file(WRITE "${CMAKE_BINARY_DIR}/QtCreatorDeployment.txt"
"${CMAKE_INSTALL_PREFIX}\n${CMAKE_BINARY_DIR}/sailify:bin\n")