From 95d519c87bfa98ad82e154dfc76c7db96a59047d Mon Sep 17 00:00:00 2001 From: Michael Uleysky Date: Fri, 27 Dec 2024 12:43:21 +1000 Subject: [PATCH] Added the ability to select the location of the configuration file --- CMakeLists.txt | 5 ++++- include/ParseArgs.h | 6 +++++- src/ParseArgs.cpp | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 892cf29..afca25a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.9) +cmake_minimum_required(VERSION 3.20) # Make sure the user doesn't play dirty with symlinks get_filename_component(srcdir "${CMAKE_SOURCE_DIR}" REALPATH) @@ -41,6 +41,9 @@ set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON) include_directories(include sources sources-add GSW-C) add_compile_options(-Wall -Wno-deprecated-declarations) +set(CONFIG_FILE "/etc/odm.conf" CACHE STRING "Path to config file") +add_compile_options(-DCONFIGFILE="${CONFIG_FILE}") + # Dwarf-4 support check include(CheckCXXCompilerFlag) CHECK_CXX_COMPILER_FLAG(-gdwarf-4 COMPILER_SUPPORTS_DWARF4) diff --git a/include/ParseArgs.h b/include/ParseArgs.h index d286093..1a72762 100644 --- a/include/ParseArgs.h +++ b/include/ParseArgs.h @@ -5,5 +5,9 @@ using michlib::MString; using michlib::SList; using CLArgs = std::map; -CLArgs ParseArgs(int argc, char** argv); +CLArgs ParseArgs(int argc, char** argv); MString GetExt(const MString& fname); + +#ifndef CONFIGFILE +#define CONFIGFILE "/etc/odm.conf" +#endif diff --git a/src/ParseArgs.cpp b/src/ParseArgs.cpp index 5bbe757..6cafc5f 100644 --- a/src/ParseArgs.cpp +++ b/src/ParseArgs.cpp @@ -29,7 +29,7 @@ CLArgs ParseArgs(int argc, char** argv) } SList sl; - michlib_internal::ParseParameterFile("/etc/odm.conf", sl, 0); + michlib_internal::ParseParameterFile(CONFIGFILE, sl, 0); return out; }