Skip to content

Commit b20d713

Browse files
Fix configuring a second time with USE_DEFAULT_INSTALL_PATH=TRUE (#1012)
* Fix double-configure failing if USE_DEFAULT_INSTALL_PATH is enabled. Changed name of USE_DEFAULT_INSTALL_PATH to a name-qualified version
1 parent 5356841 commit b20d713

File tree

6 files changed

+20
-14
lines changed

6 files changed

+20
-14
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Directories that are generated
22
/tags
33
cmake-build*
4+
_build/
45

56
# Filetypes
67
*~

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## 3.9.0 [Unreleased]
99

10-
### Added
10+
### Added
1111

12-
- Add CMake option `USE_DEFAULT_INSTALL_PATH`.
12+
- Add CMake option `MONGOCXX_OVERRIDE_DEFAULT_INSTALL_PREFIX` (default is `TRUE`
13+
for backwards-compatibility).
1314
- Add API to manage Atlas Search Indexes.
1415
- Automatically download C driver dependency if not provided.
1516

CMakeLists.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,14 @@ To build static libraries only, set both BUILD_SHARED_LIBS and BUILD_SHARED_AND_
202202
endif()
203203

204204

205-
option(USE_DEFAULT_INSTALL_PATH "Override the CMake default installation path" OFF)
206-
if(NOT CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND USE_DEFAULT_INSTALL_PATH)
207-
message(FATAL_ERROR "You cannot set both CMAKE_INSTALL_PREFIX and USE_DEFAULT_INSTALL_PATH")
208-
endif()
209-
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND NOT USE_DEFAULT_INSTALL_PATH)
210-
message(WARNING "the CMake default install path is being overridden to the build directory. This behavior will not be the default in a future release. Build with -DUSE_DEFAULT_INSTALL_PATH=ON to opt into what will be the default behavior in a future release. Setting install path to: ${CMAKE_BINARY_DIR}/install")
205+
option(MONGOCXX_OVERRIDE_DEFAULT_INSTALL_PREFIX "If enabled, mongocxx will set a default CMAKE_INSTALL_PREFIX if one is not already defined" TRUE)
206+
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND MONGOCXX_OVERRIDE_DEFAULT_INSTALL_PREFIX)
207+
message(WARNING
208+
"mongocxx: The default CMAKE_INSTALL_PREFIX is being overridden to the "
209+
"build directory. This behavior will not be the default in a future "
210+
"release. Build with 'MONGOCXX_OVERRIDE_DEFAULT_INSTALL_PREFIX=ON' to opt "
211+
"into what will be the default behavior in a future release. Setting install "
212+
"path to: ${CMAKE_BINARY_DIR}/install")
211213
set (CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "default install path" FORCE)
212214
endif()
213215

docs/content/mongocxx-v3/installation/linux.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ from source. To configure `mongocxx` for installation into `/usr/local` as well,
7171
```
7272
cmake .. \
7373
-DCMAKE_BUILD_TYPE=Release \
74-
-DUSE_DEFAULT_INSTALL_PATH=ON
74+
-DMONGOCXX_OVERRIDE_DEFAULT_INSTALL_PREFIX=OFF
7575
```
7676

7777
These options can be freely mixed with a C++17 polyfill option. For instance, this is how a user
@@ -80,7 +80,7 @@ would run the command above with the Boost polyfill option:
8080
cmake .. \
8181
-DCMAKE_BUILD_TYPE=Release \
8282
-DBSONCXX_POLY_USE_BOOST=1 \
83-
-DUSE_DEFAULT_INSTALL_PATH=ON
83+
-DMONGOCXX_OVERRIDE_DEFAULT_INSTALL_PREFIX=OFF
8484
```
8585

8686
### Step 4: Build and install the driver

docs/content/mongocxx-v3/installation/macos.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ from source. To configure `mongocxx` for installation into `/usr/local` as well,
7171
```
7272
cmake .. \
7373
-DCMAKE_BUILD_TYPE=Release \
74-
-DUSE_DEFAULT_INSTALL_PATH=ON
74+
-DMONGOCXX_OVERRIDE_DEFAULT_INSTALL_PREFIX=OFF
7575
```
7676

7777
These options can be freely mixed with a C++17 polyfill option. For instance, this is how a user
@@ -80,7 +80,7 @@ would run the command above with the Boost polyfill option:
8080
cmake .. \
8181
-DCMAKE_BUILD_TYPE=Release \
8282
-DBSONCXX_POLY_USE_BOOST=1 \
83-
-DUSE_DEFAULT_INSTALL_PATH=ON
83+
-DMONGOCXX_OVERRIDE_DEFAULT_INSTALL_PREFIX=OFF
8484
```
8585

8686
### Step 4: Build and install the driver

etc/test_make_release.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ def test_generate_release_notes(self):
1919
2020
### Added
2121
22-
- Add CMake option `USE_DEFAULT_INSTALL_PATH`.
22+
- Add CMake option `MONGOCXX_OVERRIDE_DEFAULT_INSTALL_PREFIX` (default is `TRUE`
23+
for backwards-compatibility).
2324
- Add API to manage Atlas Search Indexes.
2425
2526
## 3.8.0
@@ -31,7 +32,8 @@ def test_generate_release_notes(self):
3132
expected_release_notes = textwrap.dedent("""
3233
## Added
3334
34-
- Add CMake option `USE_DEFAULT_INSTALL_PATH`.
35+
- Add CMake option `MONGOCXX_OVERRIDE_DEFAULT_INSTALL_PREFIX` (default is `TRUE`
36+
for backwards-compatibility).
3537
- Add API to manage Atlas Search Indexes.
3638
3739
See the [full list of changes in Jira](https://jira.mongodb.org/issues/?jql=project%20%3D%20CXX%20AND%20fixVersion%20%3D%203.9.0).

0 commit comments

Comments
 (0)