Skip to content

Commit

Permalink
Got version and date string moderately automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter F. Peterson committed Sep 16, 2011
1 parent ed4abed commit 1893c7f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
25 changes: 20 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@ endif ( NOT stdint )
# boost
find_package ( Boost REQUIRED program_options )

find_program ( DATE_CMD date )
if (DATE_CMD)
execute_process ( COMMAND ${DATE_CMD} --iso-8601=minutes
OUTPUT_VARIABLE BUILD_DATE_TIME
OUTPUT_STRIP_TRAILING_WHITESPACE )
else (DATE_CMD)
set ( BUILD_DATE_TIME "UNKNOWN" )
endif (DATE_CMD)

######################################################################
set ( CPACK_PACKAGE_VERSION_MAJOR 2 )
set ( CPACK_PACKAGE_VERSION_MINOR 0 )
set ( CPACK_PACKAGE_VERSION_PATCH "SNAPSHOT" )
set ( CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}" )

configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/version.hpp.in
${CMAKE_CURRENT_SOURCE_DIR}/version.hpp )

######################################################################
# files to use for building
set ( SRC_FILES
Expand All @@ -29,7 +47,8 @@ set ( SRC_FILES
statistics.cpp
statistics.hpp
string_util.cpp
string_util.hpp )
string_util.hpp
version.hpp )

add_executable( morebin ${SRC_FILES} )
target_link_libraries ( morebin ${Boost_LIBRARIES} )
Expand All @@ -43,10 +62,6 @@ set ( CPACK_PACKAGE_URL "???" )
set ( CPACK_PACKAGE_CONTACT [email protected] )
#set ( CPACK_PACKAGE_ICON )
#set ( CPACK_PACKAGE_NAME morebin )
set ( CPACK_PACKAGE_VERSION_MAJOR 2 )
set ( CPACK_PACKAGE_VERSION_MINOR 0 )
set ( CPACK_PACKAGE_VERSION_PATCH "SNAPSHOT" )
set ( CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}" )
set ( CPACK_PACKAGING_INSTALL_PREFIX /usr/local/ )

# cpack information
Expand Down
3 changes: 2 additions & 1 deletion more_bin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <vector>
#include "bin_file.hpp"
#include "renderer.hpp"
#include "version.hpp"

using std::cerr;
using std::cout;
Expand Down Expand Up @@ -208,7 +209,7 @@ int main(int argc, char** argv)
return 1;
}
if (vm.count("version")) {
cout << "morebin version UNSET" << endl;
cout << "morebin version " << VERSION << " built " << DATE << endl;
return 0;
}

Expand Down
4 changes: 4 additions & 0 deletions version.hpp.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include <string>

static const std::string VERSION("@CPACK_PACKAGE_VERSION@");
static const std::string DATE("@BUILD_DATE_TIME@");

0 comments on commit 1893c7f

Please sign in to comment.