forked from raspberrypi/piserver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
106 lines (87 loc) · 3.36 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
project(piserver)
cmake_minimum_required(VERSION 3.1)
set (CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wno-psabi")
find_package(Gettext)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
find_package(CURL REQUIRED)
find_package(LibArchive REQUIRED)
find_package(PkgConfig)
pkg_check_modules(GTKMM REQUIRED gtkmm-3.0)
link_directories(${GTKMM_LIBRARY_DIRS})
include_directories(${GTKMM_INCLUDE_DIRS})
include(CheckIncludeFile)
check_include_file(ldap.h HAVE_LDAP_H)
find_library(LDAP_LIBRARY ldap)
if(NOT HAVE_LDAP_H OR NOT LDAP_LIBRARY)
message( FATAL_ERROR "Missing libldap. Try 'sudo apt install libldap2-dev'" )
endif()
find_library(CAP_LIBRARY cap)
check_include_file(sys/capability.h HAVE_CAPABILITY_H)
if(NOT HAVE_CAPABILITY_H OR NOT CAP_LIBRARY)
message( FATAL_ERROR "Missing libcap. Try 'sudo apt install libcap-dev'" )
endif()
# for crypt_r()
find_library(CRYPT_LIBRARY crypt)
# for resolving SRV DNS records
find_library(RESOLV_LIBRARY resolv)
# test if we need libatomic
include(CheckCXXSourceCompiles)
check_cxx_source_compiles("
#include <atomic>
#include <stdint.h>
int main() {
std::atomic<int64_t> x;
x = 1;
return (int) x;
}"
atomicbuiltin)
if (NOT atomicbuiltin)
find_library(ATOMIC_LIBRARY NAMES atomic libatomic.so.1)
if (NOT ATOMIC_LIBRARY)
message( FATAL_ERROR "Missing libatomic while architecture does need it" )
endif()
endif()
aux_source_directory(src SRC_LIST)
add_executable(${PROJECT_NAME} ${SRC_LIST} resources.c)
target_link_libraries(${PROJECT_NAME} ${GTKMM_LIBRARIES} ${LDAP_LIBRARY}
${CRYPT_LIBRARY} ${RESOLV_LIBRARY} ${CURL_LIBRARY} ${LibArchive_LIBRARIES} ${CAP_LIBRARY} ${ATOMIC_LIBRARY} Threads::Threads -lstdc++fs)
# Languages
if (GETTEXT_FOUND)
file(GLOB LANGUAGES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} po/*.po)
GETTEXT_CREATE_TRANSLATIONS(po/piserver.pot ALL ${LANGUAGES})
add_definitions(-DLOCALEDIR="/usr/share/locale")
endif()
# Resources
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/macros)
include(GlibCompileResourcesSupport)
set(RESOURCE_LIST
data/firstuse.glade
data/piserver.glade
data/addhostdialog.glade
data/edithostdialog.glade
data/adduserdialog.glade
data/edituserdialog.glade
data/adddistrodialog.glade
data/addfolderdialog.glade
data/clonedistrodialog.glade
data/ldapsettingsdialog.glade
)
compile_gresources(RESOURCE_FILE
XML_OUT
TYPE EMBED_C
RESOURCES ${RESOURCE_LIST})
add_custom_target(resource ALL DEPENDS ${RESOURCE_FILE})
# Installation
install(TARGETS piserver DESTINATION bin)
install(FILES data/piserver.desktop DESTINATION share/applications)
install(FILES data/org.raspberrypi.piserver.policy DESTINATION share/polkit-1/actions)
install(DIRECTORY DESTINATION /var/lib/piserver)
install(DIRECTORY DESTINATION /var/lib/piserver/os)
install(DIRECTORY DESTINATION /var/lib/piserver/os/shared)
install(DIRECTORY DESTINATION /var/lib/piserver/tftproot)
install(DIRECTORY DESTINATION /var/lib/piserver/scripts)
install(PROGRAMS scripts/postinstall.sh scripts/convert.sh scripts/convert_folder.sh scripts/chroot_image.sh DESTINATION /var/lib/piserver/scripts)
install(FILES scripts/convert_chrooted_cmds scripts/mkhomedir-piserver DESTINATION /var/lib/piserver/scripts)
install(FILES scripts/50-piserver-dhcpcd-hook DESTINATION /lib/dhcpcd/dhcpcd-hooks)