From 3ce1982af61c7b2c06c34b2712c24dd13bf21e7e Mon Sep 17 00:00:00 2001 From: Justin Reichardt Date: Fri, 17 Sep 2021 11:28:11 -0500 Subject: [PATCH] Added config.h.in file cmake generates a config file. It currently just shows the version. rhosts now prints the version at start --- CMakeLists.txt | 4 +++- src/rhosts.c | 1 + src/rhosts.h | 2 ++ src/rhostsConfig.h.in | 2 ++ 4 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 src/rhostsConfig.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b45ac9..bd00a68 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,5 +2,7 @@ cmake_minimum_required(VERSION 3.10) project(rhosts VERSION 0.0.0 LANGUAGES C) message(" C: '${CMAKE_C_COMPILER}'") include_directories(${PROJECT_SOURCE_DIR}) -add_executable(rhosts src/rhosts.c src/rhosts.h src/download.h src/download.c) +add_executable(rhosts src/rhosts.c src/download.c) target_link_libraries(rhosts curl) +target_include_directories(rhosts PUBLIC "${PROJECT_BINARY_DIR}") +configure_file(src/rhostsConfig.h.in config.h) diff --git a/src/rhosts.c b/src/rhosts.c index 2a28c68..8df8493 100644 --- a/src/rhosts.c +++ b/src/rhosts.c @@ -27,6 +27,7 @@ int main(int argc, char *argv[]){ struct entry *entries; int rc =0; + printf("version: %s\n",rhosts_VERSION); rc = parse_config(&entries); if (rc != 0){ diff --git a/src/rhosts.h b/src/rhosts.h index 2863bac..cae96a8 100644 --- a/src/rhosts.h +++ b/src/rhosts.h @@ -21,6 +21,8 @@ #ifndef RHOSTS_HEADER #define RHOSTS_HEADER +#include "config.h" + #include #include #include diff --git a/src/rhostsConfig.h.in b/src/rhostsConfig.h.in new file mode 100644 index 0000000..acae99a --- /dev/null +++ b/src/rhostsConfig.h.in @@ -0,0 +1,2 @@ +// the configured options and settings for Tutorial +#define rhosts_VERSION "@rhosts_VERSION@"