Skip to content

Restore cmake_policy in GenerateUninstaller, fix EVG batch scripts, and use Ninja with mingw-w64 #2070

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

eramongodb
Copy link
Contributor

Followup to #2066. Identified the following error on closer inspection of the install-uninstall-check-msvc task output (despite task success):

CMake Error at CMakeLists.txt:1 (cmake_minimum_required):
  CMake 3.15...4.0 or higher is required.  You are running version 3.11.0
-- Configuring incomplete, errors occurred!

This is caused by the CMAKE env var being overridden in the batch script, which ends up using an older system-provided CMake version than expected. The install-uninstall-* tasks for MSVC and MinGW have apparently been silently broken for years (😱) since 3165a35 raised the minimum required CMake version from 3.1 to 3.15 in the 1.24.0 release on June 2023. Furthermore, 070b35ab broke the uninstall batch script on Windows (but not in a way that impacts the uninstall operations themselves, as files and directories are still correctly removed), resulting in baffling error messages such as:

The filename, directory name, or volume label syntax is incorrect.
The parameter is incorrect.
The parameter is incorrect.

These issues will be fixed by a followup PR that resolves CDRIVER-6062. For now, the non-zero exit code for the uninstall command is deliberately ignored.

These issues exposed a severe lack of error-handling checks in the batch scripts, for which there is unfortunately no Bash set -o errexit equivalent. This PR updates all batch scripts to consistently use the || goto :error pattern for all potentially-failing commands. Applying these changes revealed a whole host of silently-ignored issues which are now addressed by this PR:

  • Unnecessary call to robocopy which copies the source directory into the binary directory.
  • Obsolete PATH manipulation to obtain mingw-w64 GCC which is now reliably provided via Chocolatey.
  • Outdated/broken path to vsvars64.bat to load the Visual Studio developer environment.
  • Revert of removal of call to cmake_policy() by CDRIVER-6059 set CMake max policy version to 4.0 #2066 in GenerateUninstaller.cmake after realizing it may be evaluated in CMake script mode during the install step.
    • This in turn exposed cmake/cmake#26678 due to CMP0147, which is set to OLD to avoid even more noisy diagnostic output.

And as drive-by improvements:

  • Add redirect_standard_error_to_output: true to prevent confusing log output due to interleaving of stdout and stderr.
  • Split msvc and mingw scripts so the giant echo.%CC%| findstr /I "gcc">Nul && ( ... ) || ( ... ) is not treated as a single big echoed batch command.
  • Updated all mingw-task control paths to use the Ninja generator (as provided by Chocolatey on all latest Windows distros).
    • The CC env var is also updated to correctly indicate the compiler to use (gcc, not mingw), since we are only really interested in testing compilation of our libraries with the mingw-w64 compiler on Windows, not the particulars of the build system of choice.

Note

The link-with-bson-mingw and link-with-cmake-mingw tasks are left as effectively no-op tasks due to the lack of pkg-config availability on Windows distros.

@eramongodb eramongodb self-assigned this Jul 24, 2025
@eramongodb eramongodb requested a review from a team as a code owner July 24, 2025 16:42
@eramongodb eramongodb requested review from rcsanchez97 and kevinAlbs and removed request for rcsanchez97 July 24, 2025 16:42
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.

1 participant