From 2ad5e57db22559fcea65ccd8260c1424f556f726 Mon Sep 17 00:00:00 2001 From: PBerger Date: Fri, 7 Mar 2014 20:05:18 +0100 Subject: [PATCH] Refactored version handling. Its now done via Tags in GIT. Added CPack configuration as to build packages on the build servers. Former-commit-id: f3d9507867155c41e82ee9d24e851a096dd59e4c --- CMakeLists.txt | 33 +++- CPackConfig.cmake | 27 +++ LICENSE-STORM.txt | 0 .../log4cplus-1.1.3-rc1/CMakeLists.txt | 6 +- .../log4cplus-1.1.3-rc1/src/CMakeLists.txt | 172 ++++++++--------- .../cmake/GetGitRevisionDescription.cmake | 176 ++++++++++++++++++ .../cmake/GetGitRevisionDescription.cmake.in | 38 ++++ src/storm.cpp | 10 +- storm-config.h.in | 9 +- 9 files changed, 378 insertions(+), 93 deletions(-) create mode 100644 CPackConfig.cmake delete mode 100644 LICENSE-STORM.txt create mode 100644 resources/cmake/GetGitRevisionDescription.cmake create mode 100644 resources/cmake/GetGitRevisionDescription.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index d560c2788..1aa26de4b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,10 +3,6 @@ cmake_minimum_required (VERSION 2.8.6) # Set project name project (storm CXX C) -# Set the version number -set (STORM_CPP_VERSION_MAJOR 1) -set (STORM_CPP_VERSION_MINOR 0) - # Add base folder for better inclusion paths include_directories("${PROJECT_SOURCE_DIR}") include_directories("${PROJECT_SOURCE_DIR}/src") @@ -168,6 +164,27 @@ endif() ## CMake-generated Config File for StoRM ## ############################################################# + +# +# Make a version file containing the current version from git. +# +include(GetGitRevisionDescription) +git_describe_checkout(STORM_GIT_VERSION_STRING) + +# Parse the git Tag into variables +string(REGEX REPLACE "^([0-9]+)\\..*" "\\1" STORM_CPP_VERSION_MAJOR "${STORM_GIT_VERSION_STRING}") +string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*" "\\1" STORM_CPP_VERSION_MINOR "${STORM_GIT_VERSION_STRING}") +string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" STORM_CPP_VERSION_PATCH "${STORM_GIT_VERSION_STRING}") +string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+)\\-([0-9]+)\\-.*" "\\1" STORM_CPP_VERSION_COMMITS_AHEAD "${STORM_GIT_VERSION_STRING}") +string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-[0-9]+\\-([a-z0-9]+).*" "\\1" STORM_CPP_VERSION_HASH "${STORM_GIT_VERSION_STRING}") +string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-[0-9]+\\-[a-z0-9]+\\-(.*)" "\\1" STORM_CPP_VERSION_APPENDIX "${STORM_GIT_VERSION_STRING}") +if ("${STORM_CPP_VERSION_APPENDIX}" MATCHES "^.*dirty.*$") + set(STORM_CPP_VERSION_DIRTY 1) +else() + set(STORM_CPP_VERSION_DIRTY 0) +endif() +message(STATUS "StoRM - Version information: ${STORM_CPP_VERSION_MAJOR}.${STORM_CPP_VERSION_MINOR}.${STORM_CPP_VERSION_PATCH} (${STORM_CPP_VERSION_COMMITS_AHEAD} commits ahead of Tag) build from ${STORM_CPP_VERSION_HASH} (Dirty: ${STORM_CPP_VERSION_DIRTY})") + # Base path for test files set(STORM_CPP_TESTS_BASE_PATH "${PROJECT_SOURCE_DIR}/test") # Gurobi Defines @@ -403,6 +420,7 @@ set(BUILD_SHARED_LIBS OFF CACHE BOOL "If TRUE, log4cplus is built as a shared li set(LOG4CPLUS_BUILD_LOGGINGSERVER OFF) set(LOG4CPLUS_BUILD_TESTING OFF) set(LOG4CPLUS_USE_UNICODE OFF) +set(LOG4CPLUS_DEFINE_INSTALL_TARGET OFF) add_subdirectory("${PROJECT_SOURCE_DIR}/resources/3rdparty/log4cplus-1.1.3-rc1") include_directories("${PROJECT_SOURCE_DIR}/resources/3rdparty/log4cplus-1.1.3-rc1/include") include_directories("${PROJECT_BINARY_DIR}/resources/3rdparty/log4cplus-1.1.3-rc1/include") # This adds the defines.hxx file @@ -493,3 +511,10 @@ add_custom_target(memcheck-performance-tests valgrind --leak-check=full --show-r set(CPPLINT_ARGS --filter=-whitespace/tab,-whitespace/line_length,-legal/copyright,-readability/streams) add_custom_target(style python cpplint.py ${CPPLINT_ARGS} `find ./src/ -iname "*.h" -or -iname "*.cpp" `) + +INSTALL(TARGETS storm storm-functional-tests storm-performance-tests + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib +) +include(CPackConfig.cmake) \ No newline at end of file diff --git a/CPackConfig.cmake b/CPackConfig.cmake new file mode 100644 index 000000000..5ce6c0f53 --- /dev/null +++ b/CPackConfig.cmake @@ -0,0 +1,27 @@ +include(InstallRequiredSystemLibraries) + +# For help take a look at: +# http://www.cmake.org/Wiki/CMake:CPackConfiguration + +### general settings +set(CPACK_PACKAGE_NAME "StoRM") +set(CPACK_PACKAGE_VENDOR "i2 RWTH Aachen University") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Stochastic Reward Model Checker - An extensible model checker written in C++.") + +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE") + +### versions +set(CPACK_PACKAGE_VERSION_MAJOR "${STORM_CPP_VERSION_MAJOR}") +set(CPACK_PACKAGE_VERSION_MINOR "${STORM_CPP_VERSION_MINOR}") +set(CPACK_PACKAGE_VERSION_PATCH "${STORM_CPP_VERSION_PATCH}") +set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}-${STORM_CPP_VERSION_HASH}") + +set(CPACK_GENERATOR "ZIP") +set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}") + +### source package settings +set(CPACK_SOURCE_GENERATOR "ZIP") +set(CPACK_SOURCE_IGNORE_FILES "~$;[.]swp$;/[.]svn/;/[.]git/;.gitignore;/build/;tags;cscope.*") +set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-src") + +include(CPack) \ No newline at end of file diff --git a/LICENSE-STORM.txt b/LICENSE-STORM.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/resources/3rdparty/log4cplus-1.1.3-rc1/CMakeLists.txt b/resources/3rdparty/log4cplus-1.1.3-rc1/CMakeLists.txt index 0fe3ce793..caf2426c3 100644 --- a/resources/3rdparty/log4cplus-1.1.3-rc1/CMakeLists.txt +++ b/resources/3rdparty/log4cplus-1.1.3-rc1/CMakeLists.txt @@ -28,6 +28,8 @@ option(LOG4CPLUS_BUILD_TESTING "Build the test suite." ON) option(LOG4CPLUS_BUILD_LOGGINGSERVER "Build the logging server." ON) +option(LOG4CPLUS_DEFINE_INSTALL_TARGET "Whether the install target should be generated." OFF) + if(NOT LOG4CPLUS_SINGLE_THREADED) find_package (Threads) message (STATUS "Threads: ${CMAKE_THREAD_LIBS_INIT}") @@ -134,4 +136,6 @@ if (LOG4CPLUS_QT4) add_subdirectory (qt4debugappender) endif (LOG4CPLUS_QT4) -include(Log4CPlusCPack.cmake) +if (LOG4CPLUS_DEFINE_INSTALL_TARGET) + include(Log4CPlusCPack.cmake) +endif() diff --git a/resources/3rdparty/log4cplus-1.1.3-rc1/src/CMakeLists.txt b/resources/3rdparty/log4cplus-1.1.3-rc1/src/CMakeLists.txt index 2ca977f95..7dfb3c690 100644 --- a/resources/3rdparty/log4cplus-1.1.3-rc1/src/CMakeLists.txt +++ b/resources/3rdparty/log4cplus-1.1.3-rc1/src/CMakeLists.txt @@ -109,91 +109,93 @@ if (WIN32) target_link_libraries (${log4cplus} ws2_32 advapi32) endif () -install(TARGETS ${log4cplus} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +if (LOG4CPLUS_DEFINE_INSTALL_TARGET) + install(TARGETS ${log4cplus} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -install(FILES ../include/log4cplus/appender.h - ../include/log4cplus/asyncappender.h - ../include/log4cplus/clogger.h - ../include/log4cplus/config.hxx - ../include/log4cplus/configurator.h - ../include/log4cplus/consoleappender.h - ../include/log4cplus/fileappender.h - ../include/log4cplus/fstreams.h - ../include/log4cplus/hierarchy.h - ../include/log4cplus/hierarchylocker.h - ../include/log4cplus/layout.h - ../include/log4cplus/log4judpappender.h - ../include/log4cplus/logger.h - ../include/log4cplus/loggingmacros.h - ../include/log4cplus/loglevel.h - ../include/log4cplus/mdc.h - ../include/log4cplus/ndc.h - ../include/log4cplus/nteventlogappender.h - ../include/log4cplus/nullappender.h - ../include/log4cplus/socketappender.h - ../include/log4cplus/streams.h - ../include/log4cplus/syslogappender.h - ../include/log4cplus/tchar.h - ../include/log4cplus/tracelogger.h - ../include/log4cplus/tstring.h - ../include/log4cplus/version.h - ../include/log4cplus/win32debugappender.h - ../include/log4cplus/win32consoleappender.h - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/log4cplus ) - -install(FILES ../include/log4cplus/boost/deviceappender.hxx - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/log4cplus/boost ) - - -install(FILES ../include/log4cplus/helpers/appenderattachableimpl.h - ../include/log4cplus/helpers/fileinfo.h - ../include/log4cplus/helpers/lockfile.h - ../include/log4cplus/helpers/loglog.h - ../include/log4cplus/helpers/logloguser.h - ../include/log4cplus/helpers/pointer.h - ../include/log4cplus/helpers/property.h - ../include/log4cplus/helpers/queue.h - ../include/log4cplus/helpers/sleep.h - ../include/log4cplus/helpers/snprintf.h - ../include/log4cplus/helpers/socket.h - ../include/log4cplus/helpers/socketbuffer.h - ../include/log4cplus/helpers/stringhelper.h - ../include/log4cplus/helpers/thread-config.h - ../include/log4cplus/helpers/timehelper.h - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/log4cplus/helpers ) - -install(FILES ../include/log4cplus/internal/env.h - ../include/log4cplus/internal/internal.h - ../include/log4cplus/internal/socket.h - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/log4cplus/internal ) - -install(FILES ../include/log4cplus/spi/appenderattachable.h - ../include/log4cplus/spi/factory.h - ../include/log4cplus/spi/filter.h - ../include/log4cplus/spi/loggerfactory.h - ../include/log4cplus/spi/loggerimpl.h - ../include/log4cplus/spi/loggingevent.h - ../include/log4cplus/spi/objectregistry.h - ../include/log4cplus/spi/rootlogger.h - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/log4cplus/spi ) - -install(FILES ../include/log4cplus/thread/impl/syncprims-impl.h -# ../include/log4cplus/thread/impl/syncprims-pmsm.h - ../include/log4cplus/thread/impl/syncprims-pthreads.h - ../include/log4cplus/thread/impl/syncprims-win32.h - ../include/log4cplus/thread/impl/threads-impl.h - ../include/log4cplus/thread/impl/tls.h - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/log4cplus/thread/impl ) - -install(FILES ../include/log4cplus/thread/syncprims-pub-impl.h - ../include/log4cplus/thread/syncprims.h - ../include/log4cplus/thread/threads.h - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/log4cplus/thread ) - -install(FILES ../include/log4cplus/config/macosx.h - ../include/log4cplus/config/win32.h - ../include/log4cplus/config/windowsh-inc.h - ${log4cplus_BINARY_DIR}/include/log4cplus/config/defines.hxx - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/log4cplus/config ) + install(FILES ../include/log4cplus/appender.h + ../include/log4cplus/asyncappender.h + ../include/log4cplus/clogger.h + ../include/log4cplus/config.hxx + ../include/log4cplus/configurator.h + ../include/log4cplus/consoleappender.h + ../include/log4cplus/fileappender.h + ../include/log4cplus/fstreams.h + ../include/log4cplus/hierarchy.h + ../include/log4cplus/hierarchylocker.h + ../include/log4cplus/layout.h + ../include/log4cplus/log4judpappender.h + ../include/log4cplus/logger.h + ../include/log4cplus/loggingmacros.h + ../include/log4cplus/loglevel.h + ../include/log4cplus/mdc.h + ../include/log4cplus/ndc.h + ../include/log4cplus/nteventlogappender.h + ../include/log4cplus/nullappender.h + ../include/log4cplus/socketappender.h + ../include/log4cplus/streams.h + ../include/log4cplus/syslogappender.h + ../include/log4cplus/tchar.h + ../include/log4cplus/tracelogger.h + ../include/log4cplus/tstring.h + ../include/log4cplus/version.h + ../include/log4cplus/win32debugappender.h + ../include/log4cplus/win32consoleappender.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/log4cplus ) + + install(FILES ../include/log4cplus/boost/deviceappender.hxx + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/log4cplus/boost ) + + + install(FILES ../include/log4cplus/helpers/appenderattachableimpl.h + ../include/log4cplus/helpers/fileinfo.h + ../include/log4cplus/helpers/lockfile.h + ../include/log4cplus/helpers/loglog.h + ../include/log4cplus/helpers/logloguser.h + ../include/log4cplus/helpers/pointer.h + ../include/log4cplus/helpers/property.h + ../include/log4cplus/helpers/queue.h + ../include/log4cplus/helpers/sleep.h + ../include/log4cplus/helpers/snprintf.h + ../include/log4cplus/helpers/socket.h + ../include/log4cplus/helpers/socketbuffer.h + ../include/log4cplus/helpers/stringhelper.h + ../include/log4cplus/helpers/thread-config.h + ../include/log4cplus/helpers/timehelper.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/log4cplus/helpers ) + + install(FILES ../include/log4cplus/internal/env.h + ../include/log4cplus/internal/internal.h + ../include/log4cplus/internal/socket.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/log4cplus/internal ) + + install(FILES ../include/log4cplus/spi/appenderattachable.h + ../include/log4cplus/spi/factory.h + ../include/log4cplus/spi/filter.h + ../include/log4cplus/spi/loggerfactory.h + ../include/log4cplus/spi/loggerimpl.h + ../include/log4cplus/spi/loggingevent.h + ../include/log4cplus/spi/objectregistry.h + ../include/log4cplus/spi/rootlogger.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/log4cplus/spi ) + + install(FILES ../include/log4cplus/thread/impl/syncprims-impl.h + # ../include/log4cplus/thread/impl/syncprims-pmsm.h + ../include/log4cplus/thread/impl/syncprims-pthreads.h + ../include/log4cplus/thread/impl/syncprims-win32.h + ../include/log4cplus/thread/impl/threads-impl.h + ../include/log4cplus/thread/impl/tls.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/log4cplus/thread/impl ) + + install(FILES ../include/log4cplus/thread/syncprims-pub-impl.h + ../include/log4cplus/thread/syncprims.h + ../include/log4cplus/thread/threads.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/log4cplus/thread ) + + install(FILES ../include/log4cplus/config/macosx.h + ../include/log4cplus/config/win32.h + ../include/log4cplus/config/windowsh-inc.h + ${log4cplus_BINARY_DIR}/include/log4cplus/config/defines.hxx + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/log4cplus/config ) +endif() diff --git a/resources/cmake/GetGitRevisionDescription.cmake b/resources/cmake/GetGitRevisionDescription.cmake new file mode 100644 index 000000000..718cee684 --- /dev/null +++ b/resources/cmake/GetGitRevisionDescription.cmake @@ -0,0 +1,176 @@ +# - Returns a version string from Git +# +# These functions force a re-configure on each git commit so that you can +# trust the values of the variables in your build system. +# +# get_git_head_revision( [ ...]) +# +# Returns the refspec and sha hash of the current head revision +# +# git_describe( [ ...]) +# +# Returns the results of git describe on the source tree, and adjusting +# the output so that it tests false if an error occurs. +# +# git_get_exact_tag( [ ...]) +# +# Returns the results of git describe --exact-match on the source tree, +# and adjusting the output so that it tests false if there was no exact +# matching tag. +# +# Requires CMake 2.6 or newer (uses the 'function' command) +# +# Original Author: +# 2009-2010 Ryan Pavlik +# http://academic.cleardefinition.com +# Iowa State University HCI Graduate Program/VRAC +# +# Copyright Iowa State University 2009-2010. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +if(__get_git_revision_description) + return() +endif() +set(__get_git_revision_description YES) + +# We must run the following at "include" time, not at function call time, +# to find the path to this module rather than the path to a calling list file +get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH) + +function(get_git_head_revision _refspecvar _hashvar) + set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}") + set(GIT_DIR "${GIT_PARENT_DIR}/.git") + while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories + set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}") + get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH) + if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT) + # We have reached the root directory, we are not in git + set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE) + set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE) + return() + endif() + set(GIT_DIR "${GIT_PARENT_DIR}/.git") + endwhile() + # check if this is a submodule + if(NOT IS_DIRECTORY ${GIT_DIR}) + file(READ ${GIT_DIR} submodule) + string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule}) + get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH) + get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE) + endif() + set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data") + if(NOT EXISTS "${GIT_DATA}") + file(MAKE_DIRECTORY "${GIT_DATA}") + endif() + + if(NOT EXISTS "${GIT_DIR}/HEAD") + return() + endif() + set(HEAD_FILE "${GIT_DATA}/HEAD") + configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY) + + configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in" + "${GIT_DATA}/grabRef.cmake" + @ONLY) + include("${GIT_DATA}/grabRef.cmake") + + set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE) + set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE) +endfunction() + +function(git_describe _var) + if(NOT GIT_FOUND) + find_package(Git QUIET) + endif() + get_git_head_revision(refspec hash) + if(NOT GIT_FOUND) + set(${_var} "GIT-NOTFOUND" PARENT_SCOPE) + return() + endif() + if(NOT hash) + set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE) + return() + endif() + + # TODO sanitize + #if((${ARGN}" MATCHES "&&") OR + # (ARGN MATCHES "||") OR + # (ARGN MATCHES "\\;")) + # message("Please report the following error to the project!") + # message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}") + #endif() + + #message(STATUS "Arguments to execute_process: ${ARGN}") + + execute_process(COMMAND + "${GIT_EXECUTABLE}" + describe + ${hash} + ${ARGN} + WORKING_DIRECTORY + "${CMAKE_SOURCE_DIR}" + RESULT_VARIABLE + res + OUTPUT_VARIABLE + out + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT res EQUAL 0) + set(out "${out}-${res}-NOTFOUND") + endif() + + set(${_var} "${out}" PARENT_SCOPE) +endfunction() + +function(git_describe_checkout _var) + if(NOT GIT_FOUND) + find_package(Git QUIET) + endif() + get_git_head_revision(refspec hash) + if(NOT GIT_FOUND) + set(${_var} "GIT-NOTFOUND" PARENT_SCOPE) + return() + endif() + if(NOT hash) + set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE) + return() + endif() + + # TODO sanitize + #if((${ARGN}" MATCHES "&&") OR + # (ARGN MATCHES "||") OR + # (ARGN MATCHES "\\;")) + # message("Please report the following error to the project!") + # message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}") + #endif() + + #message(STATUS "Arguments to execute_process: ${ARGN}") + + execute_process(COMMAND + "${GIT_EXECUTABLE}" + describe + --tags + --dirty=-dirty + --long + ${ARGN} + WORKING_DIRECTORY + "${CMAKE_SOURCE_DIR}" + RESULT_VARIABLE + res + OUTPUT_VARIABLE + out + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT res EQUAL 0) + set(out "${out}-${res}-NOTFOUND") + endif() + + set(${_var} "${out}" PARENT_SCOPE) +endfunction() + +function(git_get_exact_tag _var) + git_describe(out --exact-match ${ARGN}) + set(${_var} "${out}" PARENT_SCOPE) +endfunction() \ No newline at end of file diff --git a/resources/cmake/GetGitRevisionDescription.cmake.in b/resources/cmake/GetGitRevisionDescription.cmake.in new file mode 100644 index 000000000..30a115594 --- /dev/null +++ b/resources/cmake/GetGitRevisionDescription.cmake.in @@ -0,0 +1,38 @@ +# +# Internal file for GetGitRevisionDescription.cmake +# +# Requires CMake 2.6 or newer (uses the 'function' command) +# +# Original Author: +# 2009-2010 Ryan Pavlik +# http://academic.cleardefinition.com +# Iowa State University HCI Graduate Program/VRAC +# +# Copyright Iowa State University 2009-2010. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +set(HEAD_HASH) + +file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024) + +string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) +if(HEAD_CONTENTS MATCHES "ref") + # named branch + string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}") + if(EXISTS "@GIT_DIR@/${HEAD_REF}") + configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) + elseif(EXISTS "@GIT_DIR@/logs/${HEAD_REF}") + configure_file("@GIT_DIR@/logs/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) + set(HEAD_HASH "${HEAD_REF}") + endif() +else() + # detached HEAD + configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY) +endif() + +if(NOT HEAD_HASH) + file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024) + string(STRIP "${HEAD_HASH}" HEAD_HASH) +endif() \ No newline at end of file diff --git a/src/storm.cpp b/src/storm.cpp index 999e3c6d0..0a8ac9aae 100644 --- a/src/storm.cpp +++ b/src/storm.cpp @@ -153,7 +153,15 @@ void printHeader(const int argc, const char* argv[]) { std::cout << "StoRM" << std::endl; std::cout << "-----" << std::endl << std::endl; - std::cout << "Version: 1.0 Alpha" << std::endl; + std::cout << "Version: " << STORM_CPP_VERSION_MAJOR << "." << STORM_CPP_VERSION_MINOR << "." << STORM_CPP_VERSION_PATCH; + if (STORM_CPP_VERSION_COMMITS_AHEAD != 0) { + std::cout << " (+" << STORM_CPP_VERSION_COMMITS_AHEAD << " commits)"; + } + std::cout << " build from revision " << STORM_CPP_VERSION_HASH; + if (STORM_CPP_VERSION_DIRTY == 1) { + std::cout << " (DIRTY)"; + } + std::cout << std::endl; #ifdef STORM_HAVE_INTELTBB std::cout << "Linked with Intel Threading Building Blocks v" << TBB_VERSION_MAJOR << "." << TBB_VERSION_MINOR << " (Interface version " << TBB_INTERFACE_VERSION << ")." << std::endl; diff --git a/storm-config.h.in b/storm-config.h.in index 9107ac33f..85a33e032 100644 --- a/storm-config.h.in +++ b/storm-config.h.in @@ -9,8 +9,13 @@ #define STORM_GENERATED_STORMCONFIG_H_ // Version Information -#define STORM_CPP_VERSION_MAJOR @STORM_CPP_VERSION_MAJOR@ -#define STORM_CPP_VERSION_MINOR @STORM_CPP_VERSION_MINOR@ +#define STORM_CPP_VERSION_MAJOR @STORM_CPP_VERSION_MAJOR@ // The major version of StoRM +#define STORM_CPP_VERSION_MINOR @STORM_CPP_VERSION_MINOR@ // The minor version of StoRM +#define STORM_CPP_VERSION_PATCH @STORM_CPP_VERSION_PATCH@ // The patch version of StoRM +#define STORM_CPP_VERSION_COMMITS_AHEAD @STORM_CPP_VERSION_COMMITS_AHEAD@ // How many commits passed since the tag was last set +#define STORM_CPP_VERSION_HASH "@STORM_CPP_VERSION_HASH@" // The short hash of the git commit this build is bases on +#define STORM_CPP_VERSION_DIRTY @STORM_CPP_VERSION_DIRTY@ // 0 iff there no files were modified in the checkout, 1 else + // The path of the sources from which StoRM will be/was build #define STORM_CPP_BASE_PATH "@PROJECT_SOURCE_DIR@" // The path used in the functional and performance tests to load the supplied example files