-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
129 lines (96 loc) · 4.05 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
cmake_minimum_required(VERSION 3.0.2)
project( rauc-disk-updater )
option(BUILD_DOC "Build documentation" OFF)
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBGUDEV REQUIRED gudev-1.0>=233)
include_directories(${LIBGUDEV_INCLUDE_DIRS})
pkg_check_modules(GIO REQUIRED gio-2.0>=2.26.0)
include_directories(${GIO_INCLUDE_DIRS})
pkg_check_modules(GIOUNIX REQUIRED gio-unix-2.0>=2.26.0)
include_directories(${GIOUNIX_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
include(GNUInstallDirs)
if (NOT DBUS_POLICY_DIR)
set(DBUS_POLICY_DIR ${CMAKE_INSTALL_DATADIR}/dbus-1/system.d)
endif (NOT DBUS_POLICY_DIR)
if (NOT DBUS_SYSTEM_UNITDIR)
set(DBUS_SYSTEM_UNITDIR ${CMAKE_INSTALL_DATADIR}/dbus-1/system-service)
endif (NOT DBUS_SYSTEM_UNITDIR)
if (NOT SYSTEMD_SYSTEM_UNITDIR)
set(SYSTEMD_SYSTEM_UNITDIR ${CMAKE_INSTALL_LIBDIR}/systemd/system)
endif (NOT SYSTEMD_SYSTEM_UNITDIR)
if (BUILD_DOC)
# check if Doxygen is installed
find_package(Doxygen)
if (DOXYGEN_FOUND)
# set input and output files
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
# request to configure the file
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
message("Doxygen build started")
# note the option ALL which allows to build the docs together with the application
add_custom_target( doc_doxygen ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating documentation with Doxygen"
VERBATIM )
else (DOXYGEN_FOUND)
message("Doxygen need to be installed to generate the doxygen documentation")
endif (DOXYGEN_FOUND)
endif (BUILD_DOC)
set(DISK_SRCS
src/rauc-disk-updater.c
src/udev.c
)
set(DBUS_RAUC_PREFIX de-pengutronix-rauc-gen)
set(DBUS_RAUC_COMMAND
gdbus-codegen
--generate-c-code ${DBUS_RAUC_PREFIX}
--interface-prefix de.pengutronix.rauc.
--c-namespace Rauc
${CMAKE_CURRENT_SOURCE_DIR}/src/de.pengutronix.rauc.xml
)
set(DBUS_DISK_PREFIX de-helbling-disk-updater-gen)
set(DBUS_DISK_COMMAND
gdbus-codegen
--generate-c-code ${DBUS_DISK_PREFIX}
--interface-prefix de.helbling.
${CMAKE_CURRENT_SOURCE_DIR}/src/de.helbling.DiskUpdater.xml
)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/src/${DBUS_RAUC_PREFIX}.c
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/include/${DBUS_RAUC_PREFIX}.h
COMMAND ${DBUS_RAUC_COMMAND}
COMMAND mv ${DBUS_RAUC_PREFIX}.c ${CMAKE_CURRENT_SOURCE_DIR}/src/
COMMAND mv ${DBUS_RAUC_PREFIX}.h ${CMAKE_CURRENT_SOURCE_DIR}/include/
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/src/${DBUS_DISK_PREFIX}.c
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/include/${DBUS_DISK_PREFIX}.h
COMMAND ${DBUS_DISK_COMMAND}
COMMAND mv ${DBUS_DISK_PREFIX}.c ${CMAKE_CURRENT_SOURCE_DIR}/src/
COMMAND mv ${DBUS_DISK_PREFIX}.h ${CMAKE_CURRENT_SOURCE_DIR}/include/
)
set(DISK_SRCS
${DISK_SRCS}
${CMAKE_CURRENT_SOURCE_DIR}/src/${DBUS_RAUC_PREFIX}.c
${CMAKE_CURRENT_SOURCE_DIR}/src/${DBUS_DISK_PREFIX}.c
)
add_executable( rauc-disk-updater ${DISK_SRCS} )
set_target_properties(rauc-disk-updater PROPERTIES COMPILE_FLAGS "")
target_link_libraries(rauc-disk-updater
LINK_PUBLIC
${GIO_LIBRARIES}
${LIBGUDEV_LIBRARIES}
)
# install binary
install (TARGETS rauc-disk-updater DESTINATION ${CMAKE_INSTALL_BINDIR})
# install hook script
install (FILES ${CMAKE_SOURCE_DIR}/data/hook.sh DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/rauc-disk-updater/)
# install systemd service file
set(BINDIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR})
set(SYSCONFDIR ${CMAKE_INSTALL_SYSCONFDIR})
configure_file("data/rauc-disk-updater.service.in" "rauc-disk-updater.service" NEWLINE_STYLE UNIX)
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/rauc-disk-updater.service DESTINATION ${SYSTEMD_SYSTEM_UNITDIR}/)
# install dbus policy and service files
install (FILES ${CMAKE_SOURCE_DIR}/data/de.helbling.DiskUpdater.conf DESTINATION ${DBUS_POLICY_DIR}/)
install (FILES ${CMAKE_SOURCE_DIR}/data/de.helbling.DiskUpdater.service DESTINATION ${DBUS_SYSTEM_UNITDIR}/)