Skip to content

Commit

Permalink
Feat: add cmake option to skip installing startup script #1080
Browse files Browse the repository at this point in the history
  • Loading branch information
jcorporation committed Jul 30, 2023
1 parent 37df632 commit ca5bf7b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 22 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ option(MYMPD_ENABLE_LUA "Enables lua support, default ON" "ON")
option(MYMPD_MANPAGES "Creates and installs manpages" "ON")
option(MYMPD_MINIMAL "Enables minimal myMPD build, disables all MYMPD_ENABLE_* flags" "OFF")
option(MYMPD_STRIP_BINARY "Enables stripping the binaries for Release, default ON" "ON")
option(MYMPD_STARTUP_SCRIPT "Installs the startup script, default ON" "ON")

if(MYMPD_MINIMAL)
set(MYMPD_ENABLE_FLAC "OFF")
Expand Down
46 changes: 24 additions & 22 deletions cmake/CopyConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,30 @@
# myMPD (c) 2018-2023 Juergen Mang <mail@jcgames.de>
# https://github.com/jcorporation/mympd

# Install startup script
if(EXISTS "/lib/systemd/system" OR EXISTS "/usr/lib/systemd/system")
#Install systemd unit
file(INSTALL "@CMAKE_CURRENT_BINARY_DIR@/contrib/initscripts/mympd.service"
DESTINATION "/usr/lib/systemd/system"
FILE_PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ)
elseif(EXISTS "/sbin/openrc-run")
#Install openrc script
file(RENAME "@CMAKE_CURRENT_BINARY_DIR@/contrib/initscripts/mympd.openrc"
"@CMAKE_CURRENT_BINARY_DIR@/contrib/initscripts/mympd")
file(INSTALL "@CMAKE_CURRENT_BINARY_DIR@/contrib/initscripts/mympd"
DESTINATION "/etc/init.d"
FILE_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
elseif(EXISTS "/etc/init.d")
#Install sysVinit script
file(RENAME "@CMAKE_CURRENT_BINARY_DIR@/contrib/initscripts/mympd.sysVinit"
"@CMAKE_CURRENT_BINARY_DIR@/contrib/initscripts/mympd")
file(INSTALL "@CMAKE_CURRENT_BINARY_DIR@/contrib/initscripts/mympd"
DESTINATION "/etc/init.d"
FILE_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
else()
message("No supported init system found, no startup script was installed")
if("@MYMPD_STARTUP_SCRIPT@" STREQUAL "ON")
# Install startup script
if(EXISTS "/lib/systemd/system" OR EXISTS "/usr/lib/systemd/system")
#Install systemd unit
file(INSTALL "@CMAKE_CURRENT_BINARY_DIR@/contrib/initscripts/mympd.service"
DESTINATION "/usr/lib/systemd/system"
FILE_PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ)
elseif(EXISTS "/sbin/openrc-run")
#Install openrc script
file(RENAME "@CMAKE_CURRENT_BINARY_DIR@/contrib/initscripts/mympd.openrc"
"@CMAKE_CURRENT_BINARY_DIR@/contrib/initscripts/mympd")
file(INSTALL "@CMAKE_CURRENT_BINARY_DIR@/contrib/initscripts/mympd"
DESTINATION "/etc/init.d"
FILE_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
elseif(EXISTS "/etc/init.d")
#Install sysVinit script
file(RENAME "@CMAKE_CURRENT_BINARY_DIR@/contrib/initscripts/mympd.sysVinit"
"@CMAKE_CURRENT_BINARY_DIR@/contrib/initscripts/mympd")
file(INSTALL "@CMAKE_CURRENT_BINARY_DIR@/contrib/initscripts/mympd"
DESTINATION "/etc/init.d"
FILE_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
else()
message("No supported init system found, no startup script was installed")
endif()
endif()

# Install and compress manpages
Expand Down
1 change: 1 addition & 0 deletions docs/installation/compiling/cmake.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ sudo make -C build install
| MYMPD_MANPAGES | ON | Creates and installs manpages |
| MYMPD_MINIMAL | OFF | Enables minimal myMPD build, disables all MYMPD_ENABLE_* flags |
| MYMPD_STRIP_BINARY | ON | Enables stripping the binaries for Release |
| MYMPD_STARTUP_SCRIPT | ON | Installs the startup script |
{: .table .table-sm}

## cmake build types
Expand Down

0 comments on commit ca5bf7b

Please sign in to comment.