From 792020b65d4f4b0141a07aa5bbac7d931b18d62f Mon Sep 17 00:00:00 2001 From: Mattia Biondi Date: Sun, 3 May 2020 15:34:22 +0200 Subject: [PATCH] Fix CADO_SPOOL_DIR path and change PostInstall flag --- CMakeLists.txt | 29 ++++++++++++++++------------- src/CMakeLists.txt | 44 ++++++++++++++++++++++---------------------- 2 files changed, 38 insertions(+), 35 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e617bcd..5a8f43d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,34 +1,37 @@ cmake_minimum_required(VERSION 3.13) project(cado - VERSION 0.9.4 - DESCRIPTION "Capability Ambient DO. Provide users just the capabilities they need." - HOMEPAGE_URL "https://github.com/rd235/cado" - LANGUAGES C) + VERSION 0.9.4 + DESCRIPTION "Capability Ambient DO. Provide users just the capabilities they need." + HOMEPAGE_URL "https://github.com/rd235/cado" + LANGUAGES C) include(GNUInstallDirs) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FORTIFY_SOURCE=2 -O2 -Wall -pedantic") set(LIBS_REQUIRED cap execs mhash pam pam_misc) +option(CADO_RUN_POST_INSTALL "Run PostInstall.cmake" ON) + foreach(THISLIB IN LISTS LIBS_REQUIRED) - find_library(${THISLIB}_library ${THISLIB}) - if(NOT ${THISLIB}_library) - message(FATAL_ERROR "library lib${THISLIB} not found") - endif() + find_library(${THISLIB}_library ${THISLIB}) + if(NOT ${THISLIB}_library) + message(FATAL_ERROR "library lib${THISLIB} not found") + endif() endforeach(THISLIB) if (WITHEDITOR) - set(EDITOR "${WITHEDITOR}") + set(EDITOR "${WITHEDITOR}") else (WITHEDITOR) - set(EDITOR "/usr/bin/vi") + set(EDITOR "/usr/bin/vi") endif (WITHEDITOR) # Spool dir for scado files -set(CADO_SPOOL_DIR "/usr/local/var/spool/cado") +set(CADO_SPOOL_DIR + "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/spool/${CMAKE_PROJECT_NAME}") configure_file( - "include/config.h.in" - "include/config.h" + "include/config.h.in" + "include/config.h" ) add_subdirectory(man) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9a3562b..fb9d216 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,27 +1,27 @@ cmake_minimum_required(VERSION 3.13) add_executable( - cado cado.c pam_check.c get_user_groups.c capset_from_namelist.c - read_conf.c set_ambient_cap.c compute_digest.c file_utils.c - scado_parse.c cado_scado_check.c + cado cado.c pam_check.c get_user_groups.c capset_from_namelist.c + read_conf.c set_ambient_cap.c compute_digest.c file_utils.c + scado_parse.c cado_scado_check.c ) target_include_directories(cado PRIVATE ${PROJECT_SOURCE_DIR}/include ${CMAKE_BINARY_DIR}/include) target_link_libraries( - cado ${pam_library} ${pam_misc_library} ${cap_library} ${mhash_library} - ${execs_library}) + cado ${pam_library} ${pam_misc_library} ${cap_library} ${mhash_library} + ${execs_library}) add_executable(cadrop cadrop.c capset_from_namelist.c set_ambient_cap.c) target_include_directories(cadrop PRIVATE ${PROJECT_SOURCE_DIR}/include ${CMAKE_BINARY_DIR}/include) target_link_libraries(cadrop ${cap_library}) add_executable( - scado scado.c pam_check.c file_utils.c compute_digest.c - capset_from_namelist.c scado_parse.c + scado scado.c pam_check.c file_utils.c compute_digest.c + capset_from_namelist.c scado_parse.c ) target_include_directories(scado PRIVATE ${PROJECT_SOURCE_DIR}/include ${CMAKE_BINARY_DIR}/include) target_link_libraries( - scado ${pam_library} ${pam_misc_library} ${cap_library} ${mhash_library} - ${execs_library} + scado ${pam_library} ${pam_misc_library} ${cap_library} ${mhash_library} + ${execs_library} ) add_executable(caprint caprint.c) @@ -29,19 +29,19 @@ target_include_directories(caprint PRIVATE ${PROJECT_SOURCE_DIR}/include ${CMAKE target_link_libraries(caprint ${cap_library}) install( - TARGETS cado cadrop scado caprint - RUNTIME - DESTINATION ${CMAKE_INSTALL_BINDIR} + TARGETS cado cadrop scado caprint + RUNTIME + DESTINATION ${CMAKE_INSTALL_BINDIR} ) -if(NOT DEBUILD) - install( - CODE "execute_process( - COMMAND ${CMAKE_COMMAND} - -DBINDIR=${CMAKE_INSTALL_FULL_BINDIR} - -DLIBDIR=${CMAKE_INSTALL_FULL_LIBDIR} - -DCADO_SPOOL_DIR=${CADO_SPOOL_DIR} - -P ${PROJECT_SOURCE_DIR}/PostInstall.cmake - )" - ) +if(CADO_RUN_POST_INSTALL) + install( + CODE "execute_process( + COMMAND ${CMAKE_COMMAND} + -DBINDIR=${CMAKE_INSTALL_FULL_BINDIR} + -DLIBDIR=${CMAKE_INSTALL_FULL_LIBDIR} + -DCADO_SPOOL_DIR=${CADO_SPOOL_DIR} + -P ${PROJECT_SOURCE_DIR}/PostInstall.cmake + )" + ) endif()