Skip to content

Commit dfe5507

Browse files
committed
MB-22191: Always set PRODUCT_VERSION reasonably
Make PRODUCT_VERSION a cached variable to avoid losing it between builds. If it is set to "" (the default), override the cached value by attempting to introspect the VERSION from the manifest plus a build number of 0000. If introspection fails, ultimate default value is "0.0.0-9999". Since we produce a better default, we removed the ability to easily override it via Makefile. In general it's bad to automatically pass -D arguments to CMake with default values because CMake assumes those are the most correct values. Change-Id: I209456870c900cdd392ab010cb03e3512a78da27 Reviewed-on: http://review.couchbase.org/77692 Reviewed-by: Kenneth Lareau <[email protected]> Tested-by: Build Bot <[email protected]>
1 parent 6707b14 commit dfe5507

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

CMakeLists.txt

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,6 @@ OPTION (CB_DEVELOPER_BUILD "Produce Developer builds" ON)
9797
MESSAGE(STATUS "Using cmake version: ${CMAKE_VERSION}")
9898
MESSAGE(STATUS "Installing to ${CMAKE_INSTALL_PREFIX}")
9999
MESSAGE(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
100-
IF (BUILD_ENTERPRISE)
101-
MESSAGE (STATUS "Building Couchbase Server Enterprise Edition")
102-
ELSE ()
103-
MESSAGE (STATUS "Building Couchbase Server Community Edition")
104-
ENDIF ()
105100

106101
INCLUDE(CouchbaseAddressSanitizer)
107102
INCLUDE(CouchbaseAsciiDocs)
@@ -127,19 +122,29 @@ INCLUDE(FindCouchbaseV8)
127122
INCLUDE(FindCouchbaseNlohmannJson)
128123
INCLUDE(FindCouchbaseMaven)
129124

125+
# Declare PRODUCT_VERSION in cache, but then override user-defined value
126+
# if it is an empty string
127+
SET (PRODUCT_VERSION "" CACHE STRING "Product version with build number")
130128
IF ("${PRODUCT_VERSION}" STREQUAL "")
131129
IF (PYTHON_EXECUTABLE)
132130
# Try to determine product version from manifest
133131
EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} tlm/scripts/get_version.py
134132
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
135-
OUTPUT_VARIABLE PRODUCT_VERSION
133+
OUTPUT_VARIABLE _product_version
136134
ERROR_QUIET
137135
OUTPUT_STRIP_TRAILING_WHITESPACE)
138136
ELSE (PYTHON_EXECUTABLE)
139-
SET(PRODUCT_VERSION "0.0.0-9999")
137+
SET(_product_version "0.0.0-9999")
140138
ENDIF (PYTHON_EXECUTABLE)
139+
SET (PRODUCT_VERSION ${_product_version} CACHE STRING "Product version with build number" FORCE)
141140
ENDIF ("${PRODUCT_VERSION}" STREQUAL "")
142141

142+
IF (BUILD_ENTERPRISE)
143+
MESSAGE (STATUS "Building Couchbase Server ${PRODUCT_VERSION} Enterprise Edition")
144+
ELSE ()
145+
MESSAGE (STATUS "Building Couchbase Server ${PRODUCT_VERSION} Community Edition")
146+
ENDIF ()
147+
143148
IF (WIN32)
144149
SET(COUCHBASE_NETWORK_LIBS "Ws2_32")
145150
ELSEIF ("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ SEPARATOR=\\
2828

2929
CMAKE=cmake
3030

31-
CMAKE_ARGS=-G "$(MAKETYPE)" -D PRODUCT_VERSION=$(PRODUCT_VERSION) \
32-
$(EXTRA_CMAKE_OPTIONS)
31+
CMAKE_ARGS=-G "$(MAKETYPE)" $(EXTRA_CMAKE_OPTIONS)
3332

3433

3534
all: CMakeLists.txt Makefile GNUmakefile build/Makefile compile

0 commit comments

Comments
 (0)