|
| 1 | +# Copyright (c) 2018, Intel Corporation |
| 2 | +# |
| 3 | +# Permission is hereby granted, free of charge, to any person obtaining a |
| 4 | +# copy of this software and associated documentation files (the "Software"), |
| 5 | +# to deal in the Software without restriction, including without limitation |
| 6 | +# the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 7 | +# and/or sell copies of the Software, and to permit persons to whom the |
| 8 | +# Software is furnished to do so, subject to the following conditions: |
| 9 | +# |
| 10 | +# The above copyright notice and this permission notice shall be included |
| 11 | +# in all copies or substantial portions of the Software. |
| 12 | +# |
| 13 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 14 | +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 15 | +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 16 | +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 17 | +# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 18 | +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 19 | +# OTHER DEALINGS IN THE SOFTWARE. |
| 20 | + |
| 21 | +include(FindPkgConfig) |
| 22 | +include(GNUInstallDirs) |
| 23 | + |
| 24 | +pkg_check_modules(SYSTEMD "systemd") |
| 25 | + |
| 26 | +if (SYSTEMD_FOUND AND "${SYSTEMD_SERVICES_INSTALL_DIR}" STREQUAL "") |
| 27 | + execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} |
| 28 | + --variable=systemdsystemunitdir systemd |
| 29 | + OUTPUT_VARIABLE SYSTEMD_SERVICES_INSTALL_DIR) |
| 30 | + string(REGEX REPLACE "[ \t\n]+" "" SYSTEMD_SERVICES_INSTALL_DIR |
| 31 | + "${SYSTEMD_SERVICES_INSTALL_DIR}") |
| 32 | + configure_file(polycubed.service.in |
| 33 | + ${CMAKE_BINARY_DIR}/polycubed.service |
| 34 | + @ONLY) |
| 35 | + install(FILES ${CMAKE_BINARY_DIR}/polycubed.service DESTINATION |
| 36 | + ${SYSTEMD_SERVICES_INSTALL_DIR} COMPONENT cp) |
| 37 | + |
| 38 | +elseif (NOT SYSTEMD_FOUND AND SYSTEMD_SERVICES_INSTALL_DIR) |
| 39 | + message (FATAL_ERROR "Variable SYSTEMD_SERVICES_INSTALL_DIR is\ |
| 40 | + defined, but we can't find systemd using pkg-config") |
| 41 | +endif() |
| 42 | + |
| 43 | +if (SYSTEMD_FOUND) |
| 44 | + set(WITH_SYSTEMD "ON") |
| 45 | + message(STATUS "systemd services install dir: ${SYSTEMD_SERVICES_INSTALL_DIR}") |
| 46 | +else() |
| 47 | + set(WITH_SYSTEMD "OFF") |
| 48 | +endif (SYSTEMD_FOUND) |
0 commit comments