From d32813376b6a0f776a176ba2dccde26750a7ac39 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Tue, 4 Jun 2013 11:57:59 -0400 Subject: [PATCH] CMake: pass installation prefix to programs The file libowlps/owlps-config.h.in was added to allow CMake to pass the installation prefix variable to the programs. That allows the programs to look for their configuration file at the right position (i.e. in the etc/owlps directory under the installation prefix). --- TODO.t2t | 5 ----- libowlps/CMakeLists.txt | 4 ++++ libowlps/owlps-config.h.in | 27 +++++++++++++++++++++++++++ owlps-aggregator/owlps-aggregator.h | 4 +++- owlps-listener/owlps-listener.h | 3 ++- owlps-positioner/src/userinterface.cc | 7 ++++--- 6 files changed, 40 insertions(+), 10 deletions(-) create mode 100644 libowlps/owlps-config.h.in diff --git a/TODO.t2t b/TODO.t2t index 7e791b3..b4f4205 100644 --- a/TODO.t2t +++ b/TODO.t2t @@ -52,11 +52,6 @@ Work to do in OwlPS - Add option dump-configuration (displays the config & exits). -- CMake: - - handle logo/ - - use the installation prefix as search prefix for configuration files - in Listener, Aggregator and Positioner - - Support string-based positioning requests Along with the binary requests, implement a string-based request diff --git a/libowlps/CMakeLists.txt b/libowlps/CMakeLists.txt index 504ff6c..4b9bff1 100644 --- a/libowlps/CMakeLists.txt +++ b/libowlps/CMakeLists.txt @@ -9,6 +9,10 @@ # distributed along with this file, either separately or by replacing # this notice by the COPYRIGHT.t2t file's contents. +# Generate configuration header +configure_file(owlps-config.h.in + "${GENERATED_INCLUDE}/owlps-config.h") + # On Linux and other GNU systems (e.g. GNU/kFreeBSD), we need -lrt for # clock_gettime() string(REGEX MATCH "^GNU" GNU_SYSTEM ${CMAKE_SYSTEM_NAME}) diff --git a/libowlps/owlps-config.h.in b/libowlps/owlps-config.h.in new file mode 100644 index 0000000..e399992 --- /dev/null +++ b/libowlps/owlps-config.h.in @@ -0,0 +1,27 @@ +/* + * This file is part of the Owl Positioning System (OwlPS) project. + * It is subject to the copyright notice and license terms in the + * COPYRIGHT.t2t file found in the top-level directory of this + * distribution and at + * http://code.lm7.fr/p/owlps/source/tree/master/COPYRIGHT.t2t + * No part of the OwlPS Project, including this file, may be copied, + * modified, propagated, or distributed except according to the terms + * contained in the COPYRIGHT.t2t file; the COPYRIGHT.t2t file must be + * distributed along with this file, either separately or by replacing + * this notice by the COPYRIGHT.t2t file's contents. + * + *********************************************************************** + * + * This is the configuration header file for OwlPS. It is not strictly + * related with libowlps, but it sits in the same directory because + * libowlps is used by all the C/C++ programs in OwlPS. + */ + + +#ifndef _OWLPS_CONFIG_H_ +#define _OWLPS_CONFIG_H_ + +// Directory in which are located the configuration files +#define OWL_CONFIG_PREFIX "${CMAKE_INSTALL_PREFIX}/etc/owlps" + +#endif // _OWLPS_CONFIG_H_ diff --git a/owlps-aggregator/owlps-aggregator.h b/owlps-aggregator/owlps-aggregator.h index d9b3caf..880a7e1 100644 --- a/owlps-aggregator/owlps-aggregator.h +++ b/owlps-aggregator/owlps-aggregator.h @@ -19,12 +19,14 @@ #ifndef _OWLPS_AGGREGATOR_H_ #define _OWLPS_AGGREGATOR_H_ +#include + #include /* Arguments & program configuration */ #define OPTIONS "Ac:C:Df:hH:i:k:K:l:o:O:p:qt:vV" // getopt string -#define DEFAULT_CONFIG_FILE "/usr/local/etc/owlps/owlps-aggregator.conf" +#define DEFAULT_CONFIG_FILE OWL_CONFIG_PREFIX "/owlps-aggregator.conf" #define DEFAULT_AGGREGATE_TIMEOUT 600 // milliseconds #define DEFAULT_KEEP_TIMEOUT 3000 // milliseconds #define DEFAULT_CHECK_INTERVAL 300 // milliseconds diff --git a/owlps-listener/owlps-listener.h b/owlps-listener/owlps-listener.h index 375b809..75fc990 100644 --- a/owlps-listener/owlps-listener.h +++ b/owlps-listener/owlps-listener.h @@ -19,6 +19,7 @@ #ifndef _OWLPS_LISTENER_H_ #define _OWLPS_LISTENER_H_ +#include #include #ifdef OWLPS_LISTENER_KEEPS_MONITOR @@ -70,7 +71,7 @@ /* Arguments & program configuration */ #define OPTIONS "ADf:hH:i:I:Kl:m:n:O:p:P:qr:R:t:T:vVw:" // getopt string -#define DEFAULT_CONFIG_FILE "/usr/local/etc/owlps/owlps-listener.conf" +#define DEFAULT_CONFIG_FILE OWL_CONFIG_PREFIX "/owlps-listener.conf" enum {MODE_ACTIVE = 'a', MODE_PASSIVE = 'p', MODE_MIXED = 'm'} ; #define DEFAULT_AUTOCALIBRATION_HELLO_DELAY 15 // seconds #define DEFAULT_AUTOCALIBRATION_DELAY 25 // milliseconds diff --git a/owlps-positioner/src/userinterface.cc b/owlps-positioner/src/userinterface.cc index 0e48f9c..57b055f 100644 --- a/owlps-positioner/src/userinterface.cc +++ b/owlps-positioner/src/userinterface.cc @@ -15,6 +15,8 @@ #include "userinterface.hh" #include "configuration.hh" +#include + #include #include @@ -29,8 +31,7 @@ namespace po = boost::program_options ; /* *** Default value definitions *** */ /* General options */ -#define DEFAULT_CONFIG_FILE_NAME \ - "/usr/local/etc/owlps/owlps-positioner.conf" +#define DEFAULT_CONFIG_FILE OWL_CONFIG_PREFIX "/owlps-positioner.conf" /* Positioning options */ #define DEFAULT_SS_SIMILARITY "mean" @@ -103,7 +104,7 @@ void UserInterface::fill_cli_options() ("version,V", "Print version information.") ("config-file,f", - po::value()->default_value(DEFAULT_CONFIG_FILE_NAME), + po::value()->default_value(DEFAULT_CONFIG_FILE), "Alternative configuration file.") ("verbose,v", "Verbose mode.")