Skip to content

CXX-2726 do not override CMAKE_BUILD_TYPE for multi-config generator #1006

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 7, 2023

Conversation

kevinAlbs
Copy link
Collaborator

Summary

  • do not override CMAKE_BUILD_TYPE for multi-config generator
  • remove CMAKE_BUILD_TYPE from Windows install instructions
  • specify --config in Windows install instructions

Background & Motivation

Configuring on Windows with Visual Studio results in this log output from CMake:

-- No build type selected, default is Release

The log message is printed when overriding CMAKE_BUILD_TYPE. Overriding CMAKE_BUILD_TYPE is ignored for multi-configuration generators:

For multi-configuration generators like Visual Studio, Xcode, and Ninja Multi-Config, the configuration is chosen by the user at build time and CMAKE_BUILD_TYPE is ignored.

This may mislead users to think the build is Release, when it may be Debug. This may result in confusing runtime errors if mixing Debug and Release builds in an application. This PR changes to not override CMAKE_BUILD_TYPE for multi-configuration generator.

See CXX-2726 for user reports motivating this change.


To configure and build on Windows, the following commands were used:

$CMAKE \
    -Thost=x64 -A x64 \
    -DCMAKE_PREFIX_PATH="C:\cygwin\home\Administrator\code\c-bootstrap\install\mongo-c-driver-1.24.2x64" \
	-DCMAKE_INSTALL_PREFIX="./.install" \
	-DBUILD_VERSION=3.9.0-pre \
        -DCMAKE_CXX_STANDARD=17 \
	-S. -B./cmake-build

# To build with default config (resulted in Debug):
$CMAKE --build cmake-build --target mongocxx_shared --parallel 16

# To build with specified config:
$CMAKE --build cmake-build --target mongocxx_shared --parallel 16 --config RelWithDebInfo

@kevinAlbs kevinAlbs marked this pull request as ready for review August 3, 2023 12:34
@kevinAlbs kevinAlbs merged commit 89c1961 into mongodb:master Aug 7, 2023
kevinAlbs added a commit that referenced this pull request Aug 7, 2023
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants