Skip to content
This repository was archived by the owner on Mar 22, 2023. It is now read-only.

Commit bdb0b1b

Browse files
authored
Merge pull request #971 from lukaszstolarczuk/fix-srcversion-in-cmake
Fix SRCVERSION in CMake
2 parents ed05926 + ec354e8 commit bdb0b1b

File tree

5 files changed

+27
-23
lines changed

5 files changed

+27
-23
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@ build/
1111
*.swp
1212
~*
1313
tags
14-
include/libpmemobj++/version.hpp

CMakeLists.txt

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,25 @@ if(VERSION_PRERELEASE)
1818
set(VERSION ${VERSION}-${VERSION_PRERELEASE})
1919
endif()
2020

21+
# Set ${SRCVERSION}
22+
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
23+
execute_process(COMMAND git describe
24+
OUTPUT_VARIABLE SRCVERSION
25+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
26+
OUTPUT_STRIP_TRAILING_WHITESPACE
27+
ERROR_QUIET)
28+
if(NOT SRCVERSION)
29+
execute_process(COMMAND git log -1 --format=%h
30+
OUTPUT_VARIABLE SRCVERSION
31+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
32+
OUTPUT_STRIP_TRAILING_WHITESPACE)
33+
endif()
34+
elseif(EXISTS "${CMAKE_SOURCE_DIR}/.version")
35+
file(STRINGS ${CMAKE_SOURCE_DIR}/.version SRCVERSION)
36+
else()
37+
set(SRCVERSION ${VERSION})
38+
endif()
39+
2140
set(LIBPMEMOBJ_REQUIRED_VERSION 1.8)
2241
set(LIBPMEM_REQUIRED_VERSION 1.7)
2342
# Only pmreorder in ver. >= 1.9 guarantees reliable output
@@ -43,24 +62,6 @@ endif()
4362

4463
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
4564

46-
# XXX: use it in version.hpp and in Doxygen.in
47-
# Set ${SRCVERSION}
48-
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
49-
execute_process(COMMAND git describe
50-
OUTPUT_VARIABLE SRCVERSION
51-
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
52-
OUTPUT_STRIP_TRAILING_WHITESPACE
53-
ERROR_QUIET)
54-
if(NOT SRCVERSION)
55-
execute_process(COMMAND git log -1 --format=%h
56-
OUTPUT_VARIABLE SRCVERSION
57-
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
58-
OUTPUT_STRIP_TRAILING_WHITESPACE)
59-
endif()
60-
else()
61-
file(STRINGS ${CMAKE_SOURCE_DIR}/.version SRCVERSION)
62-
endif()
63-
6465
## CMake build options
6566
option(BUILD_EXAMPLES "build examples" ON)
6667
option(BUILD_TESTS "build tests" ON)
@@ -235,7 +236,10 @@ add_check_whitespace(cmake-helpers ${CMAKE_CURRENT_SOURCE_DIR}/cmake/*.cmake)
235236

236237
## Configure make install/uninstall and packages
237238
configure_file(${CMAKE_SOURCE_DIR}/cmake/version.hpp.in
238-
${CMAKE_SOURCE_DIR}/include/libpmemobj++/version.hpp @ONLY)
239+
${CMAKE_CURRENT_BINARY_DIR}/version.hpp @ONLY)
240+
241+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/version.hpp
242+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libpmemobj++)
239243

240244
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
241245
FILES_MATCHING PATTERN "*.hpp")

cmake/libpmemobj++.pc.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
33

44
Name: libpmemobj++
55
Description: libpmemobj++ - c++ bindings for libpmemobj library
6-
Version: @VERSION@
6+
Version: @SRCVERSION@
77
URL: https://github.com/pmem/libpmemobj-cpp
88
Requires: libpmemobj >= @LIBPMEMOBJ_REQUIRED_VERSION@
99
Cflags: -I${includedir}

cmake/version.hpp.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: BSD-3-Clause
2-
/* Copyright 2018, Intel Corporation */
2+
/* Copyright 2018-2020, Intel Corporation */
33

44
/**
55
* @file
@@ -14,5 +14,6 @@
1414
#define LIBPMEMOBJ_CPP_VERSION_PATCH @VERSION_PATCH@
1515

1616
#define LIBPMEMOBJ_CPP_VERSION "@VERSION@"
17+
#define LIBPMEMOBJ_CPP_SRCVERSION "@SRCVERSION@"
1718

1819
#endif /* LIBPMEMOBJ_CPP_VERSION_HPP */

doc/libpmemobj++.Doxyfile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ PROJECT_NAME = "PMDK C++ bindings"
2323
# could be handy for archiving the generated documentation or if some version
2424
# control system is used.
2525

26-
PROJECT_NUMBER = @VERSION@
26+
PROJECT_NUMBER = @SRCVERSION@
2727

2828
# Using the PROJECT_BRIEF tag one can provide an optional one line description
2929
# for a project that appears at the top of each page and should give viewer a

0 commit comments

Comments
 (0)