summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt54
-rw-r--r--cmake/FindProtobufC.cmake2
-rw-r--r--ouroboros-dev.pc.in4
-rw-r--r--ouroboros-irm.pc.in4
-rw-r--r--src/irmd/CMakeLists.txt5
5 files changed, 50 insertions, 19 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index cfb0c0fa..22196e64 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -131,18 +131,40 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ouroboros-irm.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
# modified from https://github.com/ximion/limba
-pkg_check_modules(SYSTEMD "systemd")
-if (SYSTEMD_FOUND)
- if ("${SYSTEMD_UNITDIR}" STREQUAL "")
- execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE}
- --variable=systemdsystemunitdir systemd
- OUTPUT_VARIABLE SYSTEMD_UNITDIR)
- string(REGEX REPLACE "[ \t\n]+" "" SYSTEMD_UNITDIR
- "${SYSTEMD_UNITDIR}"
- )
- endif ()
- if (NOT ${SYSTEMD_UNITDIR} STREQUAL "")
- message(STATUS "Installing systemd service in: ${SYSTEMD_UNITDIR}")
+set(SYSTEMD_INSTALL_FILES "DETECT" CACHE STRING
+ "Install systemd .service files (NO (never), DETECT (use pkg-config - default),\
+ FORCE (always - see SYSTEMD_UNITDIR_OVERRIDE))")
+set(SYSTEMD_UNITDIR_OVERRIDE "" CACHE PATH
+ "Path to install systemd files. When SYSTEMD_INSTALL_FILES == DETECT, this\
+ can be empty to automatically determine the path. Cannot be empty when FORCE.")
+
+if (SYSTEMD_INSTALL_FILES STREQUAL "DETECT" OR SYSTEMD_INSTALL_FILES STREQUAL "FORCE")
+ if (SYSTEMD_INSTALL_FILES STREQUAL "DETECT")
+ pkg_check_modules(SYSTEMD "systemd")
+ if (SYSTEMD_FOUND)
+ if ("${SYSTEMD_UNITDIR_OVERRIDE}" STREQUAL "")
+ execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE}
+ --variable=systemdsystemunitdir systemd
+ OUTPUT_VARIABLE SYSTEMD_UNITDIR_INTERNAL)
+ string(REGEX REPLACE "[ \t\n]+" "" SYSTEMD_UNITDIR_INTERNAL
+ "${SYSTEMD_UNITDIR_INTERNAL}"
+ )
+ else ()
+ set(SYSTEMD_UNITDIR_INTERNAL "${SYSTEMD_UNITDIR_OVERRIDE}")
+ endif ()
+ else ()
+ set(SYSTEMD_UNITDIR_INTERNAL "")
+ endif ()
+ elseif (SYSTEMD_INSTALL_FILES STREQUAL "FORCE")
+ if ("${SYSTEMD_UNITDIR_OVERRIDE}" STREQUAL "")
+ message(FATAL_ERROR "Systemd installation required by user, but no path\
+ provided with SYSTEMD_UNITDIR_OVERRIDE.")
+ else ()
+ set(SYSTEMD_UNITDIR_INTERNAL "${SYSTEMD_UNITDIR_OVERRIDE}")
+ endif ()
+ endif()
+ if (NOT ${SYSTEMD_UNITDIR_INTERNAL} STREQUAL "")
+ message(STATUS "Systemd service installation enabled to: ${SYSTEMD_UNITDIR_INTERNAL}")
if (LIBTOML_LIBRARIES AND NOT DISABLE_CONFIGFILE)
set (CONFIGURE_STRING "--config ${OUROBOROS_CONFIG_DIR}${OUROBOROS_CONFIG_FILE}")
else ()
@@ -151,9 +173,11 @@ if (SYSTEMD_FOUND)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/ouroboros.service.in"
"${CMAKE_CURRENT_BINARY_DIR}/ouroboros.service" @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ouroboros.service"
- DESTINATION "${SYSTEMD_UNITDIR}")
+ DESTINATION "${SYSTEMD_UNITDIR_INTERNAL}")
endif ()
-endif ()
+else ()
+ message(STATUS "Systemd service installation disabled by user")
+endif()
enable_testing()
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
@@ -163,6 +187,8 @@ if (NOT (PROTOBUF_C_INCLUDE_DIRS AND PROTOBUF_C_LIBRARY
AND PROTOBUF_PROTOC_C_EXECUTABLE))
message(FATAL_ERROR "Protobuf C compiler required but not found. "
"Please install Google Protocol Buffers.")
+else ()
+ message(STATUS "Found protobuf C compiler in ${PROTOBUF_PROTOC_C_EXECUTABLE}")
endif ()
include_directories(${PROTOBUF_C_INCLUDE_DIRS})
diff --git a/cmake/FindProtobufC.cmake b/cmake/FindProtobufC.cmake
index ff532a46..ff892b5b 100644
--- a/cmake/FindProtobufC.cmake
+++ b/cmake/FindProtobufC.cmake
@@ -62,7 +62,7 @@ mark_as_advanced(PROTOBUF_C_INCLUDE_DIR)
# Find the protoc-c Executable
find_program(PROTOBUF_PROTOC_C_EXECUTABLE
- NAMES protoc-c
+ NAMES protoc protoc-c
DOC "The Google Protocol Buffers C Compiler"
)
mark_as_advanced(PROTOBUF_PROTOC_C_EXECUTABLE)
diff --git a/ouroboros-dev.pc.in b/ouroboros-dev.pc.in
index 8895a76b..b92c2741 100644
--- a/ouroboros-dev.pc.in
+++ b/ouroboros-dev.pc.in
@@ -1,7 +1,7 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
-libdir=${exec_prefix}/usr/lib
-includedir=${prefix}/usr/include
+libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
+includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
Name: ouroboros-dev
Description: Development library for Ouroboros
diff --git a/ouroboros-irm.pc.in b/ouroboros-irm.pc.in
index 5e5841c2..6acfe6d6 100644
--- a/ouroboros-irm.pc.in
+++ b/ouroboros-irm.pc.in
@@ -1,7 +1,7 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
-libdir=${exec_prefix}/usr/lib
-includedir=${prefix}/usr/include
+libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
+includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
Name: ouroboros-irm
Description: Management library for Ouroboros
diff --git a/src/irmd/CMakeLists.txt b/src/irmd/CMakeLists.txt
index c9c2e553..c7e4cbd9 100644
--- a/src/irmd/CMakeLists.txt
+++ b/src/irmd/CMakeLists.txt
@@ -24,6 +24,7 @@ if (LIBTOML_LIBRARIES)
DESTINATION "${OUROBOROS_CONFIG_DIR}")
unset(INSTALL_DIR)
mark_as_advanced(LIBTOML_LIBRARIES)
+ find_path(LIBTOML_INCLUDE toml.h)
else ()
message(STATUS "Configuration file support disabled by user")
unset(OUROBOROS_CONFIG_FILE CACHE)
@@ -83,6 +84,10 @@ add_executable (irmd ${SOURCE_FILES})
target_link_libraries (irmd LINK_PUBLIC ouroboros-common
${LIBTOML_LIBRARIES})
+if (HAVE_TOML)
+ target_include_directories(irmd PUBLIC ${LIBTOML_INCLUDE})
+endif ()
+
include(AddCompileFlags)
if (CMAKE_BUILD_TYPE MATCHES "Debug*")
add_compile_flags(irmd -DCONFIG_OUROBOROS_DEBUG)