Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CXX-2832 Restore VERSION_CURRENT in release tarball #1092

Merged
merged 6 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .evergreen/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ darwin* | linux*)
esac
: "${cmake_examples_target:?}"

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

cmake_flags=(
Expand Down
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,20 @@ set(CMAKE_MODULE_PATH
include(GNUInstallDirs)
include(ParseVersion)

set(MONGOCXX_INCLUDE_VERSION_FILE_IN_DIST OFF)
set(MONGOCXX_CURRENT_VERSION_FILE "")

if(BUILD_VERSION STREQUAL "0.0.0")
if(EXISTS ${CMAKE_BINARY_DIR}/VERSION_CURRENT)
file(STRINGS ${CMAKE_BINARY_DIR}/VERSION_CURRENT BUILD_VERSION)
eramongodb marked this conversation as resolved.
Show resolved Hide resolved
if("${CMAKE_BINARY_DIR}" STREQUAL "${PROJECT_SOURCE_DIR}/build")
# If `CMAKE_BINARY_DIR` is the `build` directory, include `VERSION_CURRENT` in the release tarball.
set(MONGOCXX_INCLUDE_VERSION_FILE_IN_DIST ON)
set(MONGOCXX_CURRENT_VERSION_FILE build/VERSION_CURRENT)
endif ()
elseif(EXISTS ${PROJECT_SOURCE_DIR}/build/VERSION_CURRENT)
set(MONGOCXX_CURRENT_VERSION_FILE ${PROJECT_SOURCE_DIR}/build/VERSION_CURRENT)
set(MONGOCXX_INCLUDE_VERSION_FILE_IN_DIST ON)
set(MONGOCXX_CURRENT_VERSION_FILE build/VERSION_CURRENT)
file(STRINGS ${MONGOCXX_CURRENT_VERSION_FILE} BUILD_VERSION)
else()
find_package(PythonInterp)
Expand Down
5 changes: 5 additions & 0 deletions cmake/make_dist/MakeDistCheck.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ function (RUN_DIST_CHECK PACKAGE_PREFIX EXT)
ERROR_MSG "Command to untar ${tarball} failed."
)

# Ensure a VERSION_CURRENT file is present.
if(MONGOCXX_INCLUDE_VERSION_FILE_IN_DIST AND NOT EXISTS ${PACKAGE_PREFIX}/build/VERSION_CURRENT)
message (FATAL_ERROR "Expected tarball to contain a `build/VERSION_CURRENT` file, but it does not")
endif ()

set (BUILD_DIR "_cmake_build")
set (INSTALL_DIR "_cmake_install")
file (REMOVE_RECURSE ${BUILD_DIR} ${INSTALL_DIR})
Expand Down