Fix linking to systemd when elogind is used instead

This is mainly useful for non-glibc systems. Yes, systemd doesn't even run
on non-glibc systems, but elogind does and this way it links to both systemd
and elogind.

However due to switching the way we link to systemd, we now also make
sure systemd is actually installed on the system before we even try to
compile, thus preventing compiler errors when systemd isn't present.
pull/1/head
Bart Ribbers 6 years ago
parent 9970c11190
commit e5707b8f3f
No known key found for this signature in database
GPG Key ID: 699D16185DAFAE61

@ -2,7 +2,12 @@ include(GNUInstallDirs)
set(COMMON ${CMAKE_HOME_DIRECTORY}/src/common) set(COMMON ${CMAKE_HOME_DIRECTORY}/src/common)
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${COMMON}) # Find systemd
find_package(PkgConfig REQUIRED)
pkg_check_modules(SYSTEMD "libsystemd" REQUIRED)
# Set include dirs
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${SYSTEMD_INCLUDE_DIRS} ${COMMON})
# Hide all symbols except the ones explicitly exported in the code (like main()) # Hide all symbols except the ones explicitly exported in the code (like main())
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
@ -16,12 +21,15 @@ set(HEADERS appdata.h booster.h connection.h daemon.h logger.h launcherlib.h
# Set libraries to be linked. Shared libraries to be preloaded are not linked in anymore, # Set libraries to be linked. Shared libraries to be preloaded are not linked in anymore,
# but dlopen():ed and listed in src/launcher/preload.h instead. # but dlopen():ed and listed in src/launcher/preload.h instead.
link_libraries(${LIBDL} "-L/lib -lsystemd -lcap") link_libraries(${LIBDL} "-L/lib -lcap")
# Set executable # Set executable
add_library(applauncherd MODULE ${SRC} ${MOC_SRC}) add_library(applauncherd MODULE ${SRC} ${MOC_SRC})
set_target_properties(applauncherd PROPERTIES VERSION 0.1 SOVERSION 0) set_target_properties(applauncherd PROPERTIES VERSION 0.1 SOVERSION 0)
target_link_libraries(applauncherd ${SYSTEMD_LIBRARIES})
# Add install rule # Add install rule
install(TARGETS applauncherd DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}) install(TARGETS applauncherd DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR})
install(FILES ${HEADERS} DESTINATION /usr/include/applauncherd install(FILES ${HEADERS} DESTINATION /usr/include/applauncherd

Loading…
Cancel
Save