[Positioning] Print version info with -V
This commit is contained in:
parent
82d1041ab2
commit
6fa1ae15d0
|
@ -1,5 +1,9 @@
|
||||||
.PHONY : all test doc clean purge install uninstall style check
|
# Source version
|
||||||
|
ifndef OWLPS_VERSION
|
||||||
|
OWLPS_VERSION = $$(git describe || echo 'UNKNOWN_VERSION')
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Directories & files
|
||||||
SRC_DIR = src
|
SRC_DIR = src
|
||||||
OBJ_DIR = obj
|
OBJ_DIR = obj
|
||||||
TESTS_DIR = tests
|
TESTS_DIR = tests
|
||||||
|
@ -36,8 +40,11 @@ GXXFLAGS = $(DEBUG) -Wall -Wextra -I$(LIBOWLPS_DIR)
|
||||||
LD = $(CXX)
|
LD = $(CXX)
|
||||||
LDFLAGS = -lstdc++ -lm -lrt -lboost_program_options \
|
LDFLAGS = -lstdc++ -lm -lrt -lboost_program_options \
|
||||||
-L$(LIBOWLPS_DIR) -lowlps
|
-L$(LIBOWLPS_DIR) -lowlps
|
||||||
|
OWLPSFLAGS = -D OWLPS_VERSION=\"$(OWLPS_VERSION)\"
|
||||||
|
|
||||||
# Targets
|
# Targets
|
||||||
|
.PHONY : all test doc clean purge install uninstall style check
|
||||||
|
|
||||||
TARGET = owlps-positioning
|
TARGET = owlps-positioning
|
||||||
OBJ_TARGET = $(OBJ_DIR)/$(TARGET).o
|
OBJ_TARGET = $(OBJ_DIR)/$(TARGET).o
|
||||||
SOURCE_TARGET = $(SRC_DIR)/$(TARGET).cc
|
SOURCE_TARGET = $(SRC_DIR)/$(TARGET).cc
|
||||||
|
@ -120,7 +127,7 @@ $(TESTS_DIR)/%.o: $(TESTS_DIR)/%.cc $(TESTS_DIR)/%.hh
|
||||||
$(CXX) $(GXXFLAGS) $(TESTSGXXFLAGS) -o $@ -c $<
|
$(CXX) $(GXXFLAGS) $(TESTSGXXFLAGS) -o $@ -c $<
|
||||||
|
|
||||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cc $(SRC_DIR)/%.hh
|
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cc $(SRC_DIR)/%.hh
|
||||||
$(MKDIR) $(OBJ_DIR) && $(CXX) $(GXXFLAGS) -o $@ -c $<
|
$(MKDIR) $(OBJ_DIR) && $(CXX) $(GXXFLAGS) $(OWLPSFLAGS) -o $@ -c $<
|
||||||
|
|
||||||
%: $(OBJ_DIR)/%.o
|
%: $(OBJ_DIR)/%.o
|
||||||
$(LD) $(LDFLAGS) -o $@ $^
|
$(LD) $(LDFLAGS) -o $@ $^
|
||||||
|
|
|
@ -72,10 +72,11 @@ void UserInterface::fill_options()
|
||||||
void UserInterface::fill_cli_options()
|
void UserInterface::fill_cli_options()
|
||||||
{
|
{
|
||||||
cli_options->add_options()
|
cli_options->add_options()
|
||||||
("help,h", "Print help")
|
("help,h", "Print help.")
|
||||||
|
("version,V", "Print version information.")
|
||||||
("config-file,f", po::value<string>()
|
("config-file,f", po::value<string>()
|
||||||
->default_value(DEFAULT_CONFIG_FILE_NAME),
|
->default_value(DEFAULT_CONFIG_FILE_NAME),
|
||||||
"Alternative configuration file")
|
"Alternative configuration file.")
|
||||||
; // End of options
|
; // End of options
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,7 +215,7 @@ void UserInterface::fill_misc_options()
|
||||||
void UserInterface::parse_options()
|
void UserInterface::parse_options()
|
||||||
{
|
{
|
||||||
parse_command_line() ;
|
parse_command_line() ;
|
||||||
print_usage_and_exit_if_requested() ;
|
print_information_and_exit_if_requested() ;
|
||||||
|
|
||||||
parse_file() ;
|
parse_file() ;
|
||||||
|
|
||||||
|
@ -231,13 +232,34 @@ void UserInterface::parse_command_line() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void UserInterface::print_usage_and_exit_if_requested() const
|
void UserInterface::print_information_and_exit_if_requested() const
|
||||||
{
|
{
|
||||||
|
bool exit_program = false ;
|
||||||
|
|
||||||
|
// Print version if requested
|
||||||
|
if (Configuration::is_configured("version"))
|
||||||
|
{
|
||||||
|
cout
|
||||||
|
<< "This is OwlPS Positioning, part of the Open Wireless"
|
||||||
|
<< " Positioning System project.\nVersion: " <<
|
||||||
|
#ifdef OWLPS_VERSION
|
||||||
|
OWLPS_VERSION
|
||||||
|
#else // OWLPS_VERSION
|
||||||
|
"unknown version"
|
||||||
|
#endif // OWLPS_VERSION
|
||||||
|
<< ".\n" ;
|
||||||
|
exit_program = true ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print usage if requested
|
||||||
if (Configuration::is_configured("help"))
|
if (Configuration::is_configured("help"))
|
||||||
{
|
{
|
||||||
cout << *cli_options ;
|
cout << *cli_options ;
|
||||||
exit(0) ;
|
exit_program = true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (exit_program)
|
||||||
|
exit(0) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,8 @@ protected:
|
||||||
void parse_command_line(void) const ;
|
void parse_command_line(void) const ;
|
||||||
void parse_file(void) const ;
|
void parse_file(void) const ;
|
||||||
|
|
||||||
/// If help was requested by user, displays accepted options and exit
|
/// Print usage and/or version information if requested by the user
|
||||||
void print_usage_and_exit_if_requested(void) const ;
|
void print_information_and_exit_if_requested(void) const ;
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in New Issue