Skip to content

Commit 5dff747

Browse files
authored
Show version number in --help output (#260)
1 parent 60d087d commit 5dff747

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ include_directories(${ZLIB_INCLUDE_DIR})
5858

5959
set(CMAKE_CXX_STANDARD 14)
6060

61+
execute_process(
62+
COMMAND git describe --tags --abbrev=0
63+
OUTPUT_VARIABLE tm_version)
64+
add_compile_definitions(TM_VERSION=${tm_version})
65+
6166
if(MSVC)
6267
find_package(unofficial-sqlite3 CONFIG REQUIRED)
6368
add_definitions(-D_USE_MATH_DEFINES -DWIN32_LEAN_AND_MEAN -DNOGDI)

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ endif
6161

6262
# Main includes
6363

64-
CXXFLAGS := -O3 -Wall -Wno-unknown-pragmas -Wno-sign-compare -std=c++14 -pthread -fPIE $(CONFIG)
64+
TM_VERSION := $(shell git describe --tags --abbrev=0)
65+
CXXFLAGS := -O3 -Wall -Wno-unknown-pragmas -Wno-sign-compare -std=c++14 -pthread -fPIE -DTM_VERSION=$(TM_VERSION) $(CONFIG)
6566
LIB := -L/usr/local/lib -lz $(LUA_LIBS) -lboost_program_options -lsqlite3 -lboost_filesystem -lboost_system -lboost_iostreams -lprotobuf -lshp
6667
INC := -I/usr/local/include -isystem ./include -I./src $(LUA_CFLAGS)
6768

src/tilemaker.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@
5252
#include <boost/asio/post.hpp>
5353
#include <boost/interprocess/streams/bufferstream.hpp>
5454

55+
#ifndef TM_VERSION
56+
#define TM_VERSION (version not set)
57+
#endif
58+
#define STR1(x) #x
59+
#define STR(x) STR1(x)
60+
5561
// Namespaces
5662
using namespace std;
5763
namespace po = boost::program_options;
@@ -137,7 +143,7 @@ int main(int argc, char* argv[]) {
137143
string outputFile;
138144
bool _verbose = false, sqlite= false, mergeSqlite = false, mapsplit = false;
139145

140-
po::options_description desc("tilemaker (c) 2016-2020 Richard Fairhurst and contributors\nConvert OpenStreetMap .pbf files into vector tiles\n\nAvailable options");
146+
po::options_description desc("tilemaker " STR(TM_VERSION) "\nConvert OpenStreetMap .pbf files into vector tiles\n\nAvailable options");
141147
desc.add_options()
142148
("help", "show help message")
143149
("input", po::value< vector<string> >(&inputFiles), "source .osm.pbf file")

0 commit comments

Comments
 (0)