Skip to content

Fix configuring a second time with USE_DEFAULT_INSTALL_PATH=TRUE #1012

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

Merged
merged 3 commits into from
Aug 24, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Directories that are generated
/tags
cmake-build*
_build/

# Filetypes
*~
Expand Down
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## 3.9.0 [Unreleased]

### Added
### Added

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

Expand Down
14 changes: 8 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,14 @@ To build static libraries only, set both BUILD_SHARED_LIBS and BUILD_SHARED_AND_
endif()


option(USE_DEFAULT_INSTALL_PATH "Override the CMake default installation path" OFF)
if(NOT CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND USE_DEFAULT_INSTALL_PATH)
message(FATAL_ERROR "You cannot set both CMAKE_INSTALL_PREFIX and USE_DEFAULT_INSTALL_PATH")
endif()
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND NOT USE_DEFAULT_INSTALL_PATH)
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")
option(MONGOCXX_OVERRIDE_DEFAULT_INSTALL_PREFIX "If enabled, mongocxx will set a default CMAKE_INSTALL_PREFIX if one is not already defined" TRUE)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND MONGOCXX_OVERRIDE_DEFAULT_INSTALL_PREFIX)
message(WARNING
"mongocxx: The default CMAKE_INSTALL_PREFIX is being overridden to the "
"build directory. This behavior will not be the default in a future "
"release. Build with 'MONGOCXX_OVERRIDE_DEFAULT_INSTALL_PREFIX=ON' to opt "
"into what will be the default behavior in a future release. Setting install "
"path to: ${CMAKE_BINARY_DIR}/install")
set (CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "default install path" FORCE)
endif()

Expand Down
4 changes: 2 additions & 2 deletions docs/content/mongocxx-v3/installation/linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ from source. To configure `mongocxx` for installation into `/usr/local` as well,
```
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DUSE_DEFAULT_INSTALL_PATH=ON
-DMONGOCXX_OVERRIDE_DEFAULT_INSTALL_PREFIX=OFF
```

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

### Step 4: Build and install the driver
Expand Down
4 changes: 2 additions & 2 deletions docs/content/mongocxx-v3/installation/macos.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ from source. To configure `mongocxx` for installation into `/usr/local` as well,
```
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DUSE_DEFAULT_INSTALL_PATH=ON
-DMONGOCXX_OVERRIDE_DEFAULT_INSTALL_PREFIX=OFF
```

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

### Step 4: Build and install the driver
Expand Down
6 changes: 4 additions & 2 deletions etc/test_make_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ def test_generate_release_notes(self):

### Added

- Add CMake option `USE_DEFAULT_INSTALL_PATH`.
- Add CMake option `MONGOCXX_OVERRIDE_DEFAULT_INSTALL_PREFIX` (default is `TRUE`
for backwards-compatibility).
- Add API to manage Atlas Search Indexes.

## 3.8.0
Expand All @@ -31,7 +32,8 @@ def test_generate_release_notes(self):
expected_release_notes = textwrap.dedent("""
## Added

- Add CMake option `USE_DEFAULT_INSTALL_PATH`.
- Add CMake option `MONGOCXX_OVERRIDE_DEFAULT_INSTALL_PREFIX` (default is `TRUE`
for backwards-compatibility).
- Add API to manage Atlas Search Indexes.

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).
Expand Down