CMake: Make PROJECT_VERSION_EXTENSION code simpler
authorJoão Valverde <joao.valverde@tecnico.ulisboa.pt>
Sat, 11 Jun 2016 05:10:17 +0000 (06:10 +0100)
committerJoão Valverde <j@v6e.pt>
Sun, 12 Jun 2016 19:29:47 +0000 (19:29 +0000)
The intent was to allow all sorts of overrides but, ugly.

I don't think we need $cmake_package_string either, at least with
these changes.

Follow-up to 7c6e859ccf210a45e1cc0f6da17692845e6b5a23.

(And bdec712166ba924a2cdeaaca8ae580c343eaf02c).

Change-Id: I808b6bd3a3c64d2a67165344e8fe23e8314c27db
Reviewed-on: https://code.wireshark.org/review/15835
Reviewed-by: João Valverde <j@v6e.pt>
CMakeLists.txt
make-version.pl

index 12b8f13cdb6f59386508ac12174db43278cfc503..0d1d94836726d75687e078adad03745778d55ce1 100644 (file)
@@ -180,14 +180,10 @@ set(PROJECT_MAJOR_VERSION 2)
 set(PROJECT_MINOR_VERSION 1)
 set(PROJECT_PATCH_VERSION 1)
 set(PROJECT_BUILD_VERSION ${GIT_REVISION})
-# Updated by make-version.pl
-set(PROJECT_VERSION_EXTENSION "$ENV{WIRESHARK_VERSION_EXTRA}")
-if(NOT DEFINED PROJECT_VERSION_EXTENSION)
-       if (DEFINED ENV{WIRESHARK_VERSION_EXTRA})
-               set(PROJECT_VERSION_EXTENSION "$ENV{WIRESHARK_VERSION_EXTRA}")
-       else()
-               set(PROJECT_VERSION_EXTENSION "-git")
-       endif()
+set(PROJECT_VERSION_EXTENSION "-git")
+
+if(ENV{WIRESHARK_VERSION_EXTRA})
+       set(PROJECT_VERSION_EXTENSION "$ENV{WIRESHARK_VERSION_EXTRA}")
 endif()
 
 set(PROJECT_VERSION "${PROJECT_MAJOR_VERSION}.${PROJECT_MINOR_VERSION}.${PROJECT_PATCH_VERSION}${PROJECT_VERSION_EXTENSION}")
index 626516db7949f3629785bcfa83e834c2d348f219..74b9490a86bd1cea9812ff5e017541413109c199 100755 (executable)
@@ -405,9 +405,6 @@ sub update_cmakelists_txt
        my $contents = "";
        my $version = "";
        my $filepath = "$srcdir/CMakeLists.txt";
-       my $cmake_package_string = "\$ENV{WIRESHARK_VERSION_EXTRA}";
-
-       if ($package_string ne "") { $cmake_package_string = $package_string; }
 
        return if (!$set_version && $package_string eq "");
 
@@ -421,8 +418,8 @@ sub update_cmakelists_txt
                        $line = sprintf("set(PROJECT_MINOR_VERSION %d)$1", $version_pref{"version_minor"});
                } elsif ($line =~ /^set *\( *PROJECT_PATCH_VERSION .*([\r\n]+)$/) {
                        $line = sprintf("set(PROJECT_PATCH_VERSION %d)$1", $version_pref{"version_micro"});
-               } elsif ($line =~ /^set *\( *PROJECT_VERSION_EXTENSION\b.*\) *([\r\n]+)$/) {
-                       $line = sprintf("set(PROJECT_VERSION_EXTENSION \"%s\")$1", $cmake_package_string);
+               } elsif ($line =~ /^set *\( *PROJECT_VERSION_EXTENSION .*([\r\n]+)$/) {
+                       $line = sprintf("set(PROJECT_VERSION_EXTENSION \"%s\")$1", $package_string);
                }
                $contents .= $line
        }