cmake: rework version.h handling to treat it like config.h

It wasn't working on my system: I kept seeing the old git revision
in '...shark -v' even after deleting version.h

Change-Id: I75f41a7afcee4b9384f33a56014e4af6b527fec5
Reviewed-on: https://code.wireshark.org/review/10265
Petri-Dish: Jörg Mayer <jmayer@loplof.de>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Jörg Mayer <jmayer@loplof.de>
This commit is contained in:
Joerg Mayer 2015-08-26 08:50:09 +04:00 committed by Jörg Mayer
parent c18d2f8193
commit 57b2b77022
4 changed files with 28 additions and 27 deletions

View File

@ -922,21 +922,6 @@ test_big_endian(WORDS_BIGENDIAN)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/version.h
COMMAND ${PERL_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
)
add_custom_target(
gitversion ALL
DEPENDS ${CMAKE_BINARY_DIR}/version.h
)
set_target_properties(gitversion PROPERTIES FOLDER "Auxiliary")
add_subdirectory( asn1 EXCLUDE_FROM_ALL )
add_subdirectory( capchild )
add_subdirectory( caputils )
@ -948,8 +933,6 @@ add_subdirectory( ui )
add_subdirectory( wiretap )
add_subdirectory( wsutil )
add_dependencies(wsutil gitversion)
if(NOT WIN32)
add_custom_target(dumpabi DEPENDS dumpabi-libwireshark dumpabi-libwiretap dumpabi-libwsutil color.h)
endif()
@ -1064,8 +1047,18 @@ else()
endif()
set( VERSION ${PROJECT_VERSION} )
execute_process(
COMMAND ${PERL_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/make-version.pl
--print-vcs
${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE VERSION_H_CONTENT
)
set( configure_input "Built with CMake ${CMAKE_VERSION}" )
configure_file(${CMAKE_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_BINARY_DIR}/config.h)
configure_file(${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_BINARY_DIR}/version.h)
#set_target_properties(${CMAKE_BINARY_DIR}/version.h PROPERTIES FOLDER "Auxiliary")
set(ICON_PATH "${CMAKE_SOURCE_DIR}/image/")
set( IN_FILES
adns_dll.rc
@ -1693,8 +1686,6 @@ if(BUILD_wireshark AND QT_FOUND)
${APPLE_SYSTEM_CONFIGURATION_LIBRARY}
${NL_LIBRARIES}
)
# wireshark and wireshark-gtk share wireshark_FILES
add_dependencies(qtui gitversion)
# Policy since 2.8.11
if (POLICY CMP0020)
@ -2242,7 +2233,6 @@ if(BUILD_androiddump)
add_executable(androiddump WIN32 ${androiddump_FILES})
# XXX Shouldn't we add wsutil to androiddump_LIBS instead?
add_dependencies(androiddump gitversion)
set_extcap_executable_properties(androiddump)
target_link_libraries(androiddump ${androiddump_LIBS})
install(TARGETS androiddump RUNTIME DESTINATION ${EXTCAP_DIR})

View File

@ -76,6 +76,7 @@ my $repo_branch = "unknown";
my $git_description = undef;
my $get_vcs = 0;
my $set_vcs = 0;
my $print_vcs = 0;
my $set_version = 0;
my $set_release = 0;
my %version_pref = (
@ -374,6 +375,8 @@ Commit ID : $commit_id
Revision source : $info_source
Release stamp : $package_string
Fin
} elsif ($print_vcs) {
print new_version_h();
}
}
@ -625,12 +628,9 @@ sub update_versioned_files
&update_cmake_lib_releases;
}
# Print the version control system's version to $version_file.
# Don't change the file if it is not needed.
sub print_VCS_REVISION
sub new_version_h
{
my $VCS_REVISION;
my $needs_update = 1;
if ($git_description) {
$VCS_REVISION = "#define VCSVERSION \"" .
@ -645,6 +645,16 @@ sub print_VCS_REVISION
" Rev Unknown\"\n" .
"#define VCSBRANCH \"unknown\"\n";
}
return $VCS_REVISION;
}
# Print the version control system's version to $version_file.
# Don't change the file if it is not needed.
sub print_VCS_REVISION
{
my $VCS_REVISION = new_version_h();
my $needs_update = 1;
if (open(OLDREV, "<$version_file")) {
my $old_VCS_REVISION = <OLDREV> . <OLDREV>;
if ($old_VCS_REVISION eq $VCS_REVISION) {
@ -677,13 +687,14 @@ sub get_config {
"help|h", \$show_help,
"get-vcs|get-svn|g", \$get_vcs,
"set-vcs|set-svn|s", \$set_vcs,
"print-vcs", \$print_vcs,
"set-version|v", \$set_version,
"set-release|r|package-version|p", \$set_release
) || pod2usage(2);
if ($show_help) { pod2usage(1); }
if ( !( $show_help || $get_vcs || $set_vcs || $set_version || $set_release ) ) {
if ( !( $show_help || $get_vcs || $set_vcs || $print_vcs || $set_version || $set_release ) ) {
$set_vcs = 1;
}
@ -753,6 +764,7 @@ make-version.pl [options] [source directory]
--help, -h This help message
--get-vcs, -g Print the VCS revision and source.
--set-vcs, -s Set the information in version.h
--print-vcs Print the vcs version to standard output
--set-version, -v Set the major, minor, and micro versions in
configure.ac, config.nmake, debian/changelog,
and docbook/asciidoc.conf.

1
version.h.in Normal file
View File

@ -0,0 +1 @@
@VERSION_H_CONTENT@

View File

@ -214,8 +214,6 @@ add_library(wsutil ${LINK_MODE_LIB}
${CMAKE_BINARY_DIR}/image/libwsutil.rc
)
add_dependencies(wsutil gitversion)
set(FULL_SO_VERSION "0.0.0")
set_target_properties(wsutil PROPERTIES