From b0acd4e5705fc4c28d4a42cde86dae7a433a2f95 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Mon, 31 Aug 2020 10:28:37 -0400 Subject: Bake in path to rsync a compile-time --- CMakeLists.txt | 18 +++++++++--------- config.h.in | 1 + multihome.h | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) create mode 100644 config.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 3de427f..af22806 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ include(CheckCSourceCompiles) set(CMAKE_C_STANDARD 99) -include_directories(.) +include_directories("${CMAKE_CURRENT_BINARY_DIR}") check_symbol_exists(basename "libgen.h" HAVE_BASENAME) check_symbol_exists(dirname "libgen.h" HAVE_DIRNAME) @@ -16,20 +16,20 @@ check_c_source_compiles( " #include int main(int argc, char *argv[]) { - struct argp_option option[10]; + struct argp_option option[1]; } " HAVE_ARGP ) -if (NOT HAVE_ARGP) - message(FATAL_ERROR "Your toolchain does not provide argp") -endif() -find_program(PROGRAM_RSYNC rsync REQUIRED) +find_program(RSYNC_BIN + NAMES rsync + REQUIRED) + +configure_file("config.h.in" "config.h" @ONLY) add_executable(multihome - multihome.c - multihome.h) + multihome.c) install(TARGETS multihome - RUNTIME DESTINATION bin) \ No newline at end of file + RUNTIME DESTINATION bin) diff --git a/config.h.in b/config.h.in new file mode 100644 index 0000000..6007830 --- /dev/null +++ b/config.h.in @@ -0,0 +1 @@ +#cmakedefine RSYNC_BIN "@RSYNC_BIN@" diff --git a/multihome.h b/multihome.h index 5943b4e..c08401c 100644 --- a/multihome.h +++ b/multihome.h @@ -19,11 +19,11 @@ #include #include #include +#include "config.h" #define VERSION "0.0.1" #define MULTIHOME_ROOT "home_local" #define OS_SKEL_DIR "/etc/skel/" // NOTE: Trailing slash is required -#define RSYNC_BIN "/usr/bin/rsync" #define RSYNC_ARGS "-aq" #endif //MULTIHOME_MULTIHOME_H -- cgit