Skip to content

Commit 89c1961

Browse files
authored
CXX-2726 do not override CMAKE_BUILD_TYPE for multi-config generator (#1006)
* do not override CMAKE_BUILD_TYPE for multi-config generator * remove CMAKE_BUILD_TYPE from Windows install instructions CMAKE_BUILT_TYPE is ignored for multi-config generators like Visual Studio * specify `--config` in Windows install instructions
1 parent effc286 commit 89c1961

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,10 @@ if(BUILD_VERSION STREQUAL "0.0.0")
250250
endif()
251251
endif()
252252

253-
if(NOT CMAKE_BUILD_TYPE)
253+
get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
254+
255+
if(NOT CMAKE_BUILD_TYPE AND NOT isMultiConfig)
256+
# Do not override CMAKE_BUILD_TYPE if generator is multi config. CMAKE_BUILD_TYPE is ignored for multi-config generators.
254257
message(STATUS "No build type selected, default is Release")
255258
set(CMAKE_BUILD_TYPE "Release")
256259
endif()

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,18 +104,17 @@ To build versions 3.7.0 and older without a C++17 polyfill, it is necessary to c
104104

105105
```sh
106106
cmake .. \
107-
-DCMAKE_BUILD_TYPE=Release \
108107
-DLIBMONGOC_DIR=C:\mongo-c-driver \
109108
-DCMAKE_INSTALL_PREFIX=C:\mongo-cxx-driver
110109
```
111110

112111
### Step 4: Build and install the driver
113112

114-
Build and install the driver:
113+
Build and install the driver. Use `--config` to select a build configuration (e.g. `Debug`, `RelWithDebInfo`, `Release`):
115114

116115
```sh
117-
cmake --build .
118-
cmake --build . --target install
116+
cmake --build . --config RelWithDebInfo
117+
cmake --build . --target install --config RelWithDebInfo
119118
```
120119

121120
The driver can be uninstalled at a later time in one of two ways. First,

0 commit comments

Comments
 (0)