繁体   English   中英

找不到 package libsystemd

[英]Unable to find package libsystemd

尝试添加以下依赖libsystemd以便我可以使用以下内容包括#include <systemd/sd-daemon.h> 不知道为什么会失败。

-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake (found version "1.71.0") found components: system thread filesystem 
-- Checking for module 'libsystemd'
--   No package 'libsystemd' found
-- Configuring incomplete, errors occurred!
See also "/home/src/build-tiles-Desktop_Qt_5_15_2_GCC_64bit-Debug/CMakeFiles/CMakeOutput.log".
See also "/home/src/build-tiles-Desktop_Qt_5_15_2_GCC_64bit-Debug/CMakeFiles/CMakeError.log".
SIMPLE_WEB_SERVER include dir =/home/src/polaris-tiles/style-server/Simple-Web-Server
SIMPLE_WEB_SERVER include dir =/home/src/polaris-tiles/tile-server/Simple-Web-Server
CMake Error at /home/Qt/Tools/CMake/share/cmake-3.21/Modules/FindPkgConfig.cmake:554 (message):
  A required package was not found
Call Stack (most recent call first):
  /home/Qt/Tools/CMake/share/cmake-3.21/Modules/FindPkgConfig.cmake:776 (_pkg_check_modules_internal)
  Simple-Web-Server/CMakeLists.txt:22 (pkg_check_modules)

cmake_minimum_required(VERSION 3.0)

project(Simple-Web-Server)

include(GNUInstallDirs)


option(USE_STANDALONE_ASIO "set ON to use standalone Asio instead of Boost.Asio" OFF)
if(CMAKE_SOURCE_DIR STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
   option(BUILD_TESTING "set ON to build library tests" ON)
else()
   option(BUILD_TESTING "set ON to build library tests" OFF)
endif()
option(BUILD_FUZZING "set ON to build library fuzzers" OFF)
option(USE_OPENSSL "set OFF to build without OpenSSL" ON)

add_library(simple-web-server INTERFACE)

target_include_directories(simple-web-server INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})

find_package(PkgConfig REQUIRED)
pkg_check_modules(SYSTEMD REQUIRED IMPORTED_TARGET libsystemd)

find_package(Threads REQUIRED)

target_link_libraries(simple-web-server INTERFACE PkgConfig::SYSTEMD)
target_link_libraries(simple-web-server INTERFACE ${CMAKE_THREAD_LIBS_INIT})

# TODO 2020 when Debian Jessie LTS ends:
# Remove Boost system, thread, regex components; use Boost::<component> aliases; remove Boost target_include_directories
if(USE_STANDALONE_ASIO)
   message("USING STANDALONE")
   target_compile_definitions(simple-web-server INTERFACE ASIO_STANDALONE)
   find_path(ASIO_PATH asio.hpp)
   if(NOT ASIO_PATH)
       message(FATAL_ERROR "Standalone Asio not found")
   else()
       target_include_directories(simple-web-server INTERFACE ${ASIO_PATH})
   endif()
else()
   message("NOT USING STANDALONE")
   find_package(Boost 1.53.0 COMPONENTS system thread REQUIRED)
   target_link_libraries(simple-web-server INTERFACE ${Boost_LIBRARIES})
   target_include_directories(simple-web-server INTERFACE ${Boost_INCLUDE_DIR})
   if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
       target_compile_definitions(simple-web-server INTERFACE USE_BOOST_REGEX)
       find_package(Boost 1.53.0 COMPONENTS regex REQUIRED)
       target_link_libraries(simple-web-server INTERFACE ${Boost_LIBRARIES})
       target_include_directories(simple-web-server INTERFACE ${Boost_INCLUDE_DIR})
   endif()
endif()
if(WIN32)
   target_link_libraries(simple-web-server INTERFACE ws2_32 wsock32)
endif()

if(APPLE)
   set(OPENSSL_ROOT_DIR "/usr/local/opt/openssl")
endif()
if(USE_OPENSSL)
   find_package(OpenSSL)
endif()
if(OPENSSL_FOUND)
   target_compile_definitions(simple-web-server INTERFACE HAVE_OPENSSL)
   target_link_libraries(simple-web-server INTERFACE ${OPENSSL_LIBRARIES})
   target_include_directories(simple-web-server INTERFACE ${OPENSSL_INCLUDE_DIR})
endif()

# If Simple-Web-Server is not a sub-project:
if(CMAKE_SOURCE_DIR STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
   message("NOT A SUB-PROJECT")
   if(NOT MSVC)
       add_compile_options(-std=c++11 -Wall -Wextra)
       if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
           add_compile_options(-Wthread-safety)
       endif()
   else()
       add_compile_options(/W1)
   endif()

   find_package(Boost 1.53.0 COMPONENTS system thread filesystem)
   if(Boost_FOUND)
       add_executable(http_examples http_examples.cpp)
       target_link_libraries(http_examples simple-web-server)
       target_link_libraries(http_examples ${Boost_LIBRARIES})
       target_include_directories(http_examples PRIVATE ${Boost_INCLUDE_DIR})
       if(OPENSSL_FOUND)
           add_executable(https_examples https_examples.cpp)
           target_link_libraries(https_examples simple-web-server)
           target_link_libraries(https_examples ${Boost_LIBRARIES})
           target_include_directories(https_examples PRIVATE ${Boost_INCLUDE_DIR})
       endif()
    endif()

   install(FILES asio_compatibility.hpp server_http.hpp client_http.hpp server_https.hpp client_https.hpp crypto.hpp utility.hpp status_code.hpp mutex.hpp DESTINATION include/simple-web-server)
endif()

if(BUILD_TESTING OR BUILD_FUZZING)
   if(BUILD_TESTING)
       enable_testing()
   endif()
   add_subdirectory(tests)
endif()

libsystemd package 必须安装在您的系统上。 在 Ubuntu 分布上,可以这样检查:

$ sudo apt list | grep libsystemd
libsystemd-dev/bionic-pilot,now 237-3ubuntu10.53 amd64  [installed]
libsystemd0/bionic-pilot,now 237-3ubuntu10.53 amd64  [installed]

如果没有出现,请使用sudo apt install libsystemd-dev 然后,以下CMakeLists.txt

cmake_minimum_required(VERSION 3.0)

project(Simple-Web-Server)

include(GNUInstallDirs)

find_package(PkgConfig REQUIRED)
pkg_check_modules(SYSTEMD REQUIRED IMPORTED_TARGET libsystemd)

作品:

$ cmake .
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") 
-- Checking for module 'libsystemd'
--   Found libsystemd, version 237
-- Configuring done
-- Generating done
-- Build files have been written to: /home/uif08622/TMP/project

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM