Skip to content

Commit 775b978

Browse files
CXX-2832 Restore VERSION_CURRENT in release tarball (#1092)
* add check to ensure VERSION_CURRENT file is present in dist tarball * use relative path to VERSION_CURRENT * include VERSION_CURRENT in dist list if binary dir is the build dir * create VERSION_CURRENT file for Evg tasks To fix tasks running the distcheck target --------- Co-authored-by: Ezra Chung <[email protected]>
1 parent 08e7916 commit 775b978

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

.evergreen/compile.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ darwin* | linux*)
9898
esac
9999
: "${cmake_examples_target:?}"
100100

101+
# Create a VERSION_CURRENT file in the build directory to include in the dist tarball.
102+
python ./etc/calc_release_version.py > ./build/VERSION_CURRENT
101103
cd build
102104

103105
cmake_flags=(

CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,13 +238,20 @@ set(CMAKE_MODULE_PATH
238238
include(GNUInstallDirs)
239239
include(ParseVersion)
240240

241+
set(MONGOCXX_INCLUDE_VERSION_FILE_IN_DIST OFF)
241242
set(MONGOCXX_CURRENT_VERSION_FILE "")
242243

243244
if(BUILD_VERSION STREQUAL "0.0.0")
244245
if(EXISTS ${CMAKE_BINARY_DIR}/VERSION_CURRENT)
245246
file(STRINGS ${CMAKE_BINARY_DIR}/VERSION_CURRENT BUILD_VERSION)
247+
if("${CMAKE_BINARY_DIR}" STREQUAL "${PROJECT_SOURCE_DIR}/build")
248+
# If `CMAKE_BINARY_DIR` is the `build` directory, include `VERSION_CURRENT` in the release tarball.
249+
set(MONGOCXX_INCLUDE_VERSION_FILE_IN_DIST ON)
250+
set(MONGOCXX_CURRENT_VERSION_FILE build/VERSION_CURRENT)
251+
endif ()
246252
elseif(EXISTS ${PROJECT_SOURCE_DIR}/build/VERSION_CURRENT)
247-
set(MONGOCXX_CURRENT_VERSION_FILE ${PROJECT_SOURCE_DIR}/build/VERSION_CURRENT)
253+
set(MONGOCXX_INCLUDE_VERSION_FILE_IN_DIST ON)
254+
set(MONGOCXX_CURRENT_VERSION_FILE build/VERSION_CURRENT)
248255
file(STRINGS ${MONGOCXX_CURRENT_VERSION_FILE} BUILD_VERSION)
249256
else()
250257
find_package(PythonInterp)

cmake/make_dist/MakeDistCheck.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ function (RUN_DIST_CHECK PACKAGE_PREFIX EXT)
2222
ERROR_MSG "Command to untar ${tarball} failed."
2323
)
2424

25+
# Ensure a VERSION_CURRENT file is present.
26+
if(MONGOCXX_INCLUDE_VERSION_FILE_IN_DIST AND NOT EXISTS ${PACKAGE_PREFIX}/build/VERSION_CURRENT)
27+
message (FATAL_ERROR "Expected tarball to contain a `build/VERSION_CURRENT` file, but it does not")
28+
endif ()
29+
2530
set (BUILD_DIR "_cmake_build")
2631
set (INSTALL_DIR "_cmake_install")
2732
file (REMOVE_RECURSE ${BUILD_DIR} ${INSTALL_DIR})

0 commit comments

Comments
 (0)