| 1 |
find_package(PkgConfig REQUIRED) |
| 2 |
|
| 3 |
find_package(Botan QUIET) |
| 4 |
if(NOT Botan_FOUND) |
| 5 |
message(FATAL_ERROR "Botan library not found") |
| 6 |
endif() |
| 7 |
|
| 8 |
|
| 9 |
set(DBUS_DATADIR_PREFIX_DIR ${CMAKE_INSTALL_FULL_DATADIR}) |
| 10 |
option(INSTALL_DBUS_FILES_IN_PREFIX "Use installation prefix for D-Bus files" OFF) |
| 11 |
|
| 12 |
# Find dbus |
| 13 |
if(NOT INSTALL_DBUS_FILES_IN_PREFIX) |
| 14 |
pkg_check_modules(DBUS REQUIRED dbus-1) |
| 15 |
execute_process( |
| 16 |
COMMAND pkg-config --variable=datadir dbus-1 |
| 17 |
RESULT_VARIABLE DBUS_DATADIR_PREFIX_DIR_RESULT |
| 18 |
OUTPUT_VARIABLE DBUS_DATADIR_PREFIX_DIR |
| 19 |
OUTPUT_STRIP_TRAILING_WHITESPACE |
| 20 |
) |
| 21 |
if(NOT DBUS_DATADIR_PREFIX_DIR_RESULT EQUAL "0") |
| 22 |
message(FATAL_ERROR "Failed to retrieve D-Bus `datadir` variable using pkg-config") |
| 23 |
endif() |
| 24 |
endif() |
| 25 |
message("D-Bus files will be installed into ${DBUS_DATADIR_PREFIX_DIR}/dbus-1") |
| 26 |
|
| 27 |
# Find polkit |
| 28 |
pkg_check_modules(POLKIT REQUIRED polkit-gobject-1) |
| 29 |
|
| 30 |
option(POLKIT_POLICY_INSTALL_DIR "Polkit policy files installation directory" OFF) |
| 31 |
if(NOT POLKIT_POLICY_INSTALL_DIR) |
| 32 |
execute_process( |
| 33 |
COMMAND pkg-config --variable=policydir polkit-gobject-1 |
| 34 |
RESULT_VARIABLE POLKIT_POLICY_INSTALL_DIR_RESULT |
| 35 |
OUTPUT_VARIABLE POLKIT_POLICY_INSTALL_DIR |
| 36 |
OUTPUT_STRIP_TRAILING_WHITESPACE |
| 37 |
) |
| 38 |
if(NOT POLKIT_POLICY_INSTALL_DIR_RESULT EQUAL "0") |
| 39 |
message(FATAL_ERROR "Failed to retrieve Polkit `policydir` variable using pkg-config") |
| 40 |
endif() |
| 41 |
endif() |
| 42 |
message("Polkit policy files will be installed into ${POLKIT_POLICY_INSTALL_DIR}") |
| 43 |
|
| 44 |
list(APPEND HELPER_COMPILE_DEFINITIONS |
| 45 |
SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE |
| 46 |
) |
| 47 |
|
| 48 |
list(APPEND PROCESS_MONITOR_SRC |
| 49 |
pmon/processmonitor.cpp |
| 50 |
pmon/procpidsolver.cpp |
| 51 |
pmon/nlprocexecsocket.cpp |
| 52 |
pmon/nlprocexecmonitor.cpp |
| 53 |
pmon/processregistry.cpp |
| 54 |
pmon/appregistry.cpp |
| 55 |
pmon/msgdispatcher.cpp |
| 56 |
pmon/processeventconnector.c |
| 57 |
) |
| 58 |
|
| 59 |
list(APPEND SYSTEM_CONTROL_SRC |
| 60 |
sysctl/sysfswriter.cpp |
| 61 |
sysctl/msgreceiver.cpp |
| 62 |
) |
| 63 |
|
| 64 |
set(CMAKE_AUTOMOC ON) |
| 65 |
add_executable(corectrl_helperkiller |
| 66 |
helperkiller.cpp |
| 67 |
polkit.cpp |
| 68 |
) |
| 69 |
set(CMAKE_AUTOMOC OFF) |
| 70 |
|
| 71 |
target_include_directories(corectrl_helperkiller PRIVATE |
| 72 |
${POLKIT_INCLUDE_DIRS} |
| 73 |
) |
| 74 |
target_compile_definitions(corectrl_helperkiller PRIVATE ${HELPER_COMPILE_DEFINITIONS}) |
| 75 |
target_link_libraries(corectrl_helperkiller PRIVATE |
| 76 |
Qt6::Core |
| 77 |
Qt6::DBus |
| 78 |
spdlog::spdlog |
| 79 |
${POLKIT_LIBRARIES} |
| 80 |
${ATOMIC_LIB} |
| 81 |
) |
| 82 |
|
| 83 |
configure_file(org.corectrl.helperkiller.service.in org.corectrl.helperkiller.service) |
| 84 |
install(TARGETS corectrl_helperkiller DESTINATION "${CMAKE_INSTALL_FULL_LIBEXECDIR}/corectrl") |
| 85 |
install(FILES org.corectrl.helperkiller.conf DESTINATION "${DBUS_DATADIR_PREFIX_DIR}/dbus-1/system.d") |
| 86 |
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/org.corectrl.helperkiller.service" DESTINATION "${DBUS_DATADIR_PREFIX_DIR}/dbus-1/system-services") |
| 87 |
install(FILES org.corectrl.helperkiller.policy DESTINATION "${POLKIT_POLICY_INSTALL_DIR}") |
| 88 |
|
| 89 |
set(CMAKE_AUTOMOC ON) |
| 90 |
add_executable(corectrl_helper |
| 91 |
helper.cpp |
| 92 |
polkit.cpp |
| 93 |
${COMMON_SRC} |
| 94 |
${CRYPTO_SRC} |
| 95 |
${PROCESS_MONITOR_SRC} |
| 96 |
${SYSTEM_CONTROL_SRC} |
| 97 |
) |
| 98 |
set(CMAKE_AUTOMOC OFF) |
| 99 |
|
| 100 |
target_include_directories(corectrl_helper PRIVATE |
| 101 |
${Botan_INCLUDE_DIRS} |
| 102 |
${POLKIT_INCLUDE_DIRS} |
| 103 |
${PROJECT_SOURCE_DIR}/src |
| 104 |
) |
| 105 |
target_compile_definitions(corectrl_helper PRIVATE ${HELPER_COMPILE_DEFINITIONS}) |
| 106 |
target_link_libraries(corectrl_helper PRIVATE |
| 107 |
Qt6::Core |
| 108 |
Qt6::DBus |
| 109 |
stdc++fs |
| 110 |
pthread |
| 111 |
spdlog::spdlog |
| 112 |
${Botan_LIBRARIES} |
| 113 |
${POLKIT_LIBRARIES} |
| 114 |
${ATOMIC_LIB} |
| 115 |
) |
| 116 |
|
| 117 |
configure_file(org.corectrl.helper.service.in org.corectrl.helper.service) |
| 118 |
install(TARGETS corectrl_helper DESTINATION "${CMAKE_INSTALL_FULL_LIBEXECDIR}/corectrl") |
| 119 |
install(FILES org.corectrl.helper.conf DESTINATION "${DBUS_DATADIR_PREFIX_DIR}/dbus-1/system.d") |
| 120 |
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/org.corectrl.helper.service" DESTINATION "${DBUS_DATADIR_PREFIX_DIR}/dbus-1/system-services") |
| 121 |
install(FILES org.corectrl.helper.policy DESTINATION "${POLKIT_POLICY_INSTALL_DIR}") |