diff options
author | Peter Wu <peter@lekensteyn.nl> | 2018-04-16 16:48:42 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2018-04-16 15:29:43 +0000 |
commit | 3a30bc3bb59e343de464ca8aa575d0067abcc3a6 (patch) | |
tree | af03dc40ce5b0db2b55b10498d524834e262d3d9 /CMakeLists.txt | |
parent | 38ff2e743fefb1ced66c8c6442fc576f37f02a73 (diff) |
RPM: enable rpm target even if git is not available
Change-Id: Ic6a7d656aeb0ae30c5e1cc1d8f12ed5ad43f73d7
Reviewed-on: https://code.wireshark.org/review/26968
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 60466419b2..b6c4275bdc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2886,8 +2886,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux") find_program(GIT_EXECUTABLE git) endif() -# This will fail if we're not building from a git checkout. -if(RPMBUILD_EXECUTABLE AND GIT_EXECUTABLE) +if(RPMBUILD_EXECUTABLE) foreach(_rpm_dir BUILD RPMS SOURCES SPECS SRPMS) file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/packaging/rpm/${_rpm_dir}") endforeach() @@ -2924,15 +2923,20 @@ if(RPMBUILD_EXECUTABLE AND GIT_EXECUTABLE) list(APPEND _rpmbuild_with_args --with nghttp2) endif() - execute_process( - COMMAND git describe --abbrev=8 --match v[1-9]* - OUTPUT_VARIABLE _git_description - OUTPUT_STRIP_TRAILING_WHITESPACE - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - ) + if(GIT_EXECUTABLE) + execute_process( + COMMAND ${GIT_EXECUTABLE} describe --abbrev=8 --match v[1-9]* + OUTPUT_VARIABLE _git_description + OUTPUT_STRIP_TRAILING_WHITESPACE + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + ) + else() + set(_git_description "") + endif() if (NOT _git_description) # We're building the rpm outside the source. Guess the version from the dirname. get_filename_component(CMAKE_SOURCE_DIR_NAME ${CMAKE_SOURCE_DIR} NAME) + # XXX this assumes the directory to start with "wireshark-" string(SUBSTRING "${CMAKE_SOURCE_DIR_NAME}" 10 -1 _git_description) endif() string(SUBSTRING "${_git_description}" 1 -1 RPM_TARBALL_VERSION) |