Skip to content

Commit

Permalink
Merge pull request nghttp2#1377 from Aldrog/cmake_systemd
Browse files Browse the repository at this point in the history
Support building nghttpx with systemd using cmake
  • Loading branch information
tatsuhiro-t authored Aug 1, 2019
2 parents 7a59089 + 4f7aedc commit e575a2a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ if(OPENSSL_FOUND AND LIBEV_FOUND AND ZLIB_FOUND)
else()
set(ENABLE_APP_DEFAULT OFF)
endif()
find_package(Systemd 209)
find_package(Jansson 2.5)
set(ENABLE_HPACK_TOOLS_DEFAULT ${JANSSON_FOUND})
# 2.0.8 is required because we use evconnlistener_set_error_cb()
Expand Down Expand Up @@ -193,6 +194,7 @@ endif()
# libev (for src)
set(HAVE_LIBEV ${LIBEV_FOUND})
set(HAVE_ZLIB ${ZLIB_FOUND})
set(HAVE_SYSTEMD ${SYSTEMD_FOUND})
set(HAVE_LIBEVENT_OPENSSL ${LIBEVENT_FOUND})
if(LIBEVENT_FOUND)
# Must both link the core and openssl libraries.
Expand Down Expand Up @@ -497,6 +499,7 @@ message(STATUS "summary of build options:
Jansson: ${HAVE_JANSSON} (LIBS='${JANSSON_LIBRARIES}')
Jemalloc: ${HAVE_JEMALLOC} (LIBS='${JEMALLOC_LIBRARIES}')
Zlib: ${HAVE_ZLIB} (LIBS='${ZLIB_LIBRARIES}')
Systemd: ${HAVE_SYSTEMD} (LIBS='${SYSTEMD_LIBRARIES}')
Boost::System: ${Boost_SYSTEM_LIBRARY}
Boost::Thread: ${Boost_THREAD_LIBRARY}
Third-party:
Expand Down
19 changes: 19 additions & 0 deletions cmake/FindSystemd.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# - Try to find systemd
# Once done this will define
# SYSTEMD_FOUND - System has systemd
# SYSTEMD_INCLUDE_DIRS - The systemd include directories
# SYSTEMD_LIBRARIES - The libraries needed to use systemd

include(FeatureSummary)
set_package_properties(Systemd PROPERTIES
URL "http://freedesktop.org/wiki/Software/systemd/"
DESCRIPTION "System and Service Manager")

find_package(PkgConfig QUIET)
pkg_check_modules(PC_SYSTEMD QUIET libsystemd)
find_library(SYSTEMD_LIBRARIES NAMES systemd ${PC_SYSTEMD_LIBRARY_DIRS})
find_path(SYSTEMD_INCLUDE_DIRS systemd/sd-login.h HINTS ${PC_SYSTEMD_INCLUDE_DIRS})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SYSTEMD DEFAULT_MSG SYSTEMD_INCLUDE_DIRS SYSTEMD_LIBRARIES)
mark_as_advanced(SYSTEMD_INCLUDE_DIRS SYSTEMD_LIBRARIES)
6 changes: 6 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ if(ENABLE_APP)
shrpx.cc
)

if(HAVE_SYSTEMD)
target_link_libraries(nghttpx_static ${SYSTEMD_LIBRARIES})
target_compile_definitions(nghttpx_static PUBLIC HAVE_LIBSYSTEMD)
target_include_directories(nghttpx_static PUBLIC ${SYSTEMD_INCLUDE_DIRS})
endif()

if(HAVE_MRUBY)
target_link_libraries(nghttpx_static mruby-lib)
endif()
Expand Down

0 comments on commit e575a2a

Please sign in to comment.