From d3a8baf9e79e98b3a33bd7f0e7e1f908aa34d48a Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Mon, 27 Apr 2020 20:17:24 -0300 Subject: [PATCH] Back out systemd linking to top-level CMakeLists systemd notifies on startup really belong in daemon, not core, so this paves the way for easily moving the calls there. --- CMakeLists.txt | 14 ++++++++++++++ src/cryptonote_core/CMakeLists.txt | 11 +---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d44e0147..3e3bd5dd9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -422,6 +422,7 @@ ExternalProject_Add(generate_translations_header add_library(libunbound INTERFACE) add_library(miniupnpc INTERFACE) +add_library(systemd INTERFACE) # Will do nothing unless we find and enable systemd support # Allow -D DOWNLOAD_SODIUM=FORCE to download without even checking for a local libsodium option(DOWNLOAD_SODIUM "Allow libsodium to be downloaded and built locally if not found on the system" OFF) @@ -445,6 +446,19 @@ endif() export(TARGETS sodium NAMESPACE sodium:: FILE sodium-exports.cmake) install(TARGETS sodium EXPORT sodiumConfig DESTINATION ${CMAKE_INSTALL_LIBDIR}) +option(WITH_SYSTEMD "Attempts to link against and enable systemd daemon notification support" ON) +if (WITH_SYSTEMD) + pkg_check_modules(SYSTEMD libsystemd IMPORTED_TARGET) + + if(SYSTEMD_FOUND) + target_compile_definitions(systemd INTERFACE ENABLE_SYSTEMD) + target_link_libraries(systemd INTERFACE PkgConfig::SYSTEMD) + else() + message(WARNING "systemd not found; building without systemd support (use -DWITH_SYSTEMD=OFF to suppress this warning)") + endif() +endif() + + add_subdirectory(external) target_compile_definitions(easylogging PRIVATE AUTO_INITIALIZE_EASYLOGGINGPP) diff --git a/src/cryptonote_core/CMakeLists.txt b/src/cryptonote_core/CMakeLists.txt index b3097cb87..67ef2803e 100644 --- a/src/cryptonote_core/CMakeLists.txt +++ b/src/cryptonote_core/CMakeLists.txt @@ -55,18 +55,9 @@ target_link_libraries(cryptonote_core PRIVATE Boost::program_options Boost::chrono + systemd extra) -option(WITH_SYSTEMD "Attempts to link against and enable systemd daemon notification support" ON) -if (WITH_SYSTEMD) - pkg_check_modules(SYSTEMD libsystemd) - - if(SYSTEMD_FOUND) - target_compile_definitions(cryptonote_core PRIVATE ENABLE_SYSTEMD) - target_link_libraries(cryptonote_core PRIVATE ${SYSTEMD_LIBRARIES}) - endif() -endif() - if(PER_BLOCK_CHECKPOINT) target_compile_definitions(cryptonote_core PUBLIC PER_BLOCK_CHECKPOINT) target_link_libraries(cryptonote_core PUBLIC blocks)