diff --git a/CMakeLists.txt b/CMakeLists.txt index 07d40e4ba6..4a4bd4b1be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1505,13 +1505,21 @@ include(gmxTestLargeFiles) gmx_test_large_files(GMX_LARGEFILES) set( VERSION ${PROJECT_VERSION} ) -add_custom_target(version - BYPRODUCTS version.h - COMMAND ${PERL_EXECUTABLE} - ${CMAKE_SOURCE_DIR}/tools/make-version.pl - ${CMAKE_SOURCE_DIR} -) -set_target_properties(version PROPERTIES FOLDER "Auxiliary") +if(VCSVERSION_OVERRIDE) + # Allow distributors to override detection of the Git tag and version. + string(CONFIGURE "#define VCSVERSION \"@VCSVERSION_OVERRIDE@\"\n" + _version_h_contents ESCAPE_QUOTES) + file(WRITE "${CMAKE_BINARY_DIR}/version.h" "${_version_h_contents}") + message(STATUS "VCSVERSION_OVERRIDE: ${VCSVERSION_OVERRIDE}") +else() + add_custom_target(version + BYPRODUCTS version.h + COMMAND ${PERL_EXECUTABLE} + ${CMAKE_SOURCE_DIR}/tools/make-version.pl + ${CMAKE_SOURCE_DIR} + ) + set_target_properties(version PROPERTIES FOLDER "Auxiliary") +endif() set( configure_input "Built with CMake ${CMAKE_VERSION}" ) configure_file(${CMAKE_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_BINARY_DIR}/config.h) @@ -2119,7 +2127,9 @@ set_target_properties(copy_data_files PROPERTIES FOLDER "Copy Tasks") # Shared code, build object files once for all users. add_library(version_info OBJECT version_info.c) target_include_directories(version_info SYSTEM PRIVATE ${VERSION_INFO_INCLUDE_DIRS}) -add_dependencies(version_info version) +if(NOT VCSVERSION_OVERRIDE) + add_dependencies(version_info version) +endif() # sources common for wireshark, tshark, rawshark and sharkd add_library(shark_common OBJECT cfile.c diff --git a/tools/make-version.pl b/tools/make-version.pl index aa89e690b1..553eccc472 100755 --- a/tools/make-version.pl +++ b/tools/make-version.pl @@ -14,6 +14,12 @@ # CMakeLists.txt will have the version_extra template appended to the # version number. version.h will _not_ be generated if either argument is # present. +# +# make-version.pl is called during the build to update version.h in the build +# directory. To set a fixed version, use something like: +# +# cmake -DVCSVERSION_OVERRIDE="Git v3.1.0 packaged as 3.1.0-1" +# # XXX - We're pretty dumb about the "{vcsinfo}" substitution, and about having # spaces in the package format.