Skip to content

Commit fcacfcf

Browse files
committed
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 2fd7105 commit fcacfcf

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
@@ -179,7 +179,10 @@ if(BUILD_VERSION STREQUAL "0.0.0")
179179
endif()
180180
endif()
181181

182-
if(NOT CMAKE_BUILD_TYPE)
182+
get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
183+
184+
if(NOT CMAKE_BUILD_TYPE AND NOT isMultiConfig)
185+
# Do not override CMAKE_BUILD_TYPE if generator is multi config. CMAKE_BUILD_TYPE is ignored for multi-config generators.
183186
message(STATUS "No build type selected, default is Release")
184187
set(CMAKE_BUILD_TYPE "Release")
185188
endif()

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,19 +145,18 @@ directory by using the `-DLIBMONGOC_DIR` and `-DLIBBSON_DIR` options:
145145

146146
```sh
147147
cmake .. \
148-
-DCMAKE_BUILD_TYPE=Release \
149148
-DLIBMONGOC_DIR=C:\mongo-c-driver \
150149
-DLIBBSON_DIR=C:\mongo-c-driver \
151150
-DCMAKE_INSTALL_PREFIX=C:\mongo-cxx-driver
152151
```
153152

154153
### Step 5: Build and install the driver
155154

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

158157
```sh
159-
cmake --build .
160-
cmake --build . --target install
158+
cmake --build . --config RelWithDebInfo
159+
cmake --build . --target install --config RelWithDebInfo
161160
```
162161

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

0 commit comments

Comments
 (0)