Skip to content

Commit e3a1dac

Browse files
committed
Improve directory structure
Make sure that SD_UNITDIR can be passed as parameter if needed when running CMake Try to not change the default behaviour to not break previous packages
1 parent c591050 commit e3a1dac

File tree

5 files changed

+29
-18
lines changed

5 files changed

+29
-18
lines changed

Daemon/CMakeLists.txt

+4-18
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,9 @@ if(SYSTEMD_USER_SERVICE AND SYSTEMD_SYSTEM_SERVICE)
77
endif()
88

99
if(SYSTEMD_USER_SERVICE OR SYSTEMD_SYSTEM_SERVICE)
10-
find_package(PkgConfig)
11-
# Try to get the systemd directory for system/user units from the package
12-
# and fall back on upstream default without the '/usr' prefix
13-
pkg_check_modules(SYSTEMD systemd)
14-
if (SYSTEMD_FOUND)
15-
if(SYSTEMD_USER_SERVICE)
16-
pkg_get_variable(SD_UNITDIR systemd systemduserunitdir)
17-
elseif(SYSTEMD_SYSTEM_SERVICE)
18-
pkg_get_variable(SD_UNITDIR systemd systemdsystemunitdir)
19-
endif()
20-
# else()
21-
# set(SD_UNITDIR "lib/systemd/user")
22-
endif()
10+
add_subdirectory(systemd)
11+
endif()
2312

24-
configure_file(
25-
"${CMAKE_CURRENT_SOURCE_DIR}/ydotoold.service.in"
26-
"${PROJECT_BINARY_DIR}/ydotoold.service"
27-
@ONLY)
28-
install(FILES "${PROJECT_BINARY_DIR}/ydotoold.service" DESTINATION ${SD_UNITDIR})
13+
if(OPENRC)
14+
add_subdirectory(openrc)
2915
endif()

Daemon/openrc/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# TBD
File renamed without changes.

Daemon/systemd/CMakeLists.txt

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
find_package(PkgConfig)
2+
3+
# Try to get the systemd directory for system/user units from the package
4+
# and fall back on upstream default without the '/usr' prefix
5+
pkg_check_modules(SYSTEMD systemd)
6+
if (SYSTEMD_FOUND)
7+
if(SYSTEMD_USER_SERVICE)
8+
pkg_get_variable(SD_UNITDIR systemd systemduserunitdir)
9+
elseif(SYSTEMD_SYSTEM_SERVICE)
10+
pkg_get_variable(SD_UNITDIR systemd systemdsystemunitdir)
11+
endif()
12+
endif()
13+
14+
if(NOT DEFINED SD_UNITDIR)
15+
set(SD_UNITDIR "lib/systemd/user")
16+
endif()
17+
18+
message("Systemd service file is going to be installed at ${SD_UNITDIR}")
19+
20+
configure_file(
21+
"${CMAKE_CURRENT_SOURCE_DIR}/ydotoold.service.in"
22+
"${PROJECT_BINARY_DIR}/ydotoold.service"
23+
@ONLY)
24+
install(FILES "${PROJECT_BINARY_DIR}/ydotoold.service" DESTINATION ${SD_UNITDIR})
File renamed without changes.

0 commit comments

Comments
 (0)