Skip to content

Conversation

@Sanjana272621
Copy link

@Sanjana272621 Sanjana272621 commented Jan 24, 2026

Fixes #15016

Summary

Add an early CMake validation for MIXXX_VCPKG_ROOT to avoid confusing follow-up errors when contributors select an incorrect vcpkg root directory.

When MIXXX_VCPKG_ROOT is set but ${MIXXX_VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake is missing, configuration now fails immediately with a clear message explaining what is wrong and how to fix it.

Testing

  • Windows 11 / Visual Studio 2022
  • Repro command:
cmake -S . -B build15016 -DMIXXX_VCPKG_ROOT="C:\Windows"

Output

-- CMAKE_VERSION: 3.31.6-msvc6
-- MIXXX_VCPKG_ROOT was set to "C:\Windows", but this is not a valid vcpkg root.
Expected to find: C:\Windows\scripts\buildsystems\vcpkg.cmake
Please set MIXXX_VCPKG_ROOT to the vcpkg root directory, the folder containing the vcpkg tool (vcpkg.exe on Windows).
CMake Error at CMakeLists.txt:205 (message):
  Did you download the Mixxx build environment using
  `C:/Users/sanja/mixxx/tools/windows_release_buildenv.bat` or
  `C:/Users/sanja/mixxx/tools/windows_buildenv.bat`(includes Debug)?
Call Stack (most recent call first):
  CMakeLists.txt:309 (fatal_error_missing_env)


-- Configuring incomplete, errors occurred!

@github-actions github-actions bot added the build label Jan 24, 2026
@JoergAtGithub
Copy link
Member

Welcome at Mixxx!
As a first-time contributor we need you to sign the Mixxx Contributor Agreement and comment here when you have done so. It gives us permission to distribute your contribution under the GPL v2 or later license and the Apple Mac App Store. It is also helpful for us to have contact information for contributors in case we may need it in the future.

Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. This looks already helpful.
Some tweaking is required to make it more robust. Se my comments.

CMakeLists.txt Outdated
endif()

# Validate MIXXX_VCPKG_ROOT points to a vcpkg root to avoid confusing follow-up errors.
set(_vcpkg_toolchain "${MIXXX_VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MIXXX_VCPKG_ROOT is already used above. Why does it not fail? Why does the error above not kick in? I think this first sanity check need to be moved above.

CMakeLists.txt Outdated
set(_vcpkg_toolchain "${MIXXX_VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
if(NOT EXISTS "${_vcpkg_toolchain}")
message(FATAL_ERROR
"MIXXX_VCPKG_ROOT was set to \"${MIXXX_VCPKG_ROOT}\", but this is not a valid vcpkg root\n"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The message in the PR description uses different path separators / . CMake uses internally the unix / separator. I am not on windows. Does it work with both? At least the output looks visually wrong. Please verify where this happens.

CMakeLists.txt Outdated
message(FATAL_ERROR
"MIXXX_VCPKG_ROOT was set to \"${MIXXX_VCPKG_ROOT}\", but this is not a valid vcpkg root\n"
"Expected to find: ${_vcpkg_toolchain}\n"
"Please set MIXXX_VCPKG_ROOT to the vcpkg root directory (the folder containing vcpkg.exe)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vcpkg.exe is the windows file, on macOs it is just vcpkg without .exe.
Maybe something like this:

Suggested change
"Please set MIXXX_VCPKG_ROOT to the vcpkg root directory (the folder containing vcpkg.exe)"
"Please set MIXXX_VCPKG_ROOT to the vcpkg root directory, the folder containing the vcpkg tool (vcpkg.exe on Windows)."

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the end you may also call "fatal_error_missing_env" for extra info like above.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed updates addressing review comments:

  • moved the toolchain existence check to the top of the MIXXX_VCPKG_ROOT block
  • normalized the displayed expected path on Windows via file(TO_NATIVE_PATH ...)
  • made wording cross-platform in status message
  • used message(STATUS ...) and fatal_error_missing_env()

@Sanjana272621
Copy link
Author

Welcome at Mixxx! As a first-time contributor we need you to sign the Mixxx Contributor Agreement and comment here when you have done so. It gives us permission to distribute your contribution under the GPL v2 or later license and the Apple Mac App Store. It is also helpful for us to have contact information for contributors in case we may need it in the future.

Yes, I have agreed to the Mixxx Contributor Agreement. Thanks!

CMakeLists.txt Outdated
if(DEFINED MIXXX_VCPKG_ROOT)
# Validate MIXXX_VCPKG_ROOT points to a vcpkg root to avoid confusing follow-up errors.
set(_vcpkg_toolchain "${MIXXX_VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
file(TO_NATIVE_PATH "${_vcpkg_toolchain}" _vcpkg_toolchain_native)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This statement can be moved below into the if scope. Saves a bit CPU in the good case.

@Sanjana272621
Copy link
Author

Hi @daschuer,
I’ve addressed all the requested changes and pushed the updates.
Could you please take another look when you have time? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CMake: Fail early if .vcpkg-root does not exist

3 participants