Skip to content

Adding install option for vcpkg to solve compiling issues with cmake versions after 4.0#11904

Merged
TomGoodIdea merged 10 commits intoendless-sky:masterfrom
ciphell:fix/cmake4
Nov 5, 2025
Merged

Adding install option for vcpkg to solve compiling issues with cmake versions after 4.0#11904
TomGoodIdea merged 10 commits intoendless-sky:masterfrom
ciphell:fix/cmake4

Conversation

@ciphell
Copy link
Contributor

@ciphell ciphell commented Nov 4, 2025

Bug Fix

This PR addresses the issue described in #11812.

Acknowledgement

Summary

Currently, several dependency libraries used for building the project specify cmake_minimum_required versions lower than 3.5 in their CMake files. However, CMake versions 4.0 and later no longer allow this.
As a result, when CMake 4.0 or newer is installed on a system, the project fails to build.

To resolve this, adding the --x-abi-tools-use-exact-versions flag to the vcpkg install command ensures that vcpkg uses the CMake version specified in vcpkg/scripts/vcpkg-tools.json (which is currently 3.30.1).

This issue and its solution are discussed here: microsoft/vcpkg#44784.

Testing Done

OS: Windows 10

Initially, I used winlibs-x86_64-posix-seh-gcc-15.2.0-mingw-w64ucrt-13.0.0-r3, which includes CMake version 4.1.2, and encountered the same error as described in issue #11812.
After applying the changes from this PR, the build used CMake version 3.30.1 instead, and the project successfully built and ran with my existing save file.

@TomGoodIdea
Copy link
Member

Microsoft docs say that

vcpkg fetches its own copy if necessary

I don't think this is what we want.

@ciphell
Copy link
Contributor Author

ciphell commented Nov 4, 2025

I searched again and according to microsoft/vcpkg#45519 the problem with cmake has been resolved in newer versions of vcpkg.
So, I changed the value of baseline in vcpkg-configuration.json from b02e341c927f16d991edbd915d8ea43eac52096c to newer version b27f6bfad367d64f8f0f3296351c5d246e182bb4 then rebuilt everything from scratch using newer vcpkg (without added --x-abi-tools-use-exact-versions) and it is worked - I can load and play my save file.

@TomGoodIdea
Copy link
Member

That can work if it still allows us to keep an old version of openal-soft. Have you tried also removing our existing CMake 4 workarounds from overlays/ and CMakePresets.json?

@TomGoodIdea TomGoodIdea added the cd/ci/testing Issues and PRs relating to CD, CI, or unit testing. label Nov 4, 2025
@TomGoodIdea
Copy link
Member

There are still v3.5 compatibility declarations in https://github.com/endless-sky/endless-sky/blob/master/CMakePresets.json

@ciphell
Copy link
Contributor Author

ciphell commented Nov 4, 2025

I tested again with the new vcpkg. First, I deleted all instances of
set(VCPKG_CMAKE_CONFIGURE_OPTIONS -DCMAKE_POLICY_VERSION_MINIMUM=3.5)
from the overlays/ directory and all occurrences of
"CMAKE_POLICY_VERSION_MINIMUM": "3.5"
from the CMakePresets.json file.

After that, vcpkg successfully installed all the packages, but OpenAL produced the following error after the installation was complete:

All requested installations completed successfully in: 23 min
-- Running vcpkg install - done
-- The CXX compiler identification is GNU 15.2.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: E:/Programming_Resources/winlibs-x86_64/mingw64/bin/x86_64-w64-mingw32-g++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found ZLIB: optimized;F:/repos/endless-sky/build/mingw/vcpkg_installed/x64-mingw-dynamic/lib/libzlib.dll.a;debug;F:/repos/endless-sky/build/mingw/vcpkg_installed/x64-mingw-dynamic/debug/lib/libzlibd.dll.a (found version "1.3.1")
-- Found PNG: optimized;F:/repos/endless-sky/build/mingw/vcpkg_installed/x64-mingw-dynamic/lib/libpng16.dll.a;debug;F:/repos/endless-sky/build/mingw/vcpkg_installed/x64-mingw-dynamic/debug/lib/libpng16d.dll.a (found version "1.6.50")
-- Found JPEG: optimized;F:/repos/endless-sky/build/mingw/vcpkg_installed/x64-mingw-dynamic/lib/libjpeg.dll.a;debug;F:/repos/endless-sky/build/mingw/vcpkg_installed/x64-mingw-dynamic/debug/lib/libjpeg.dll.a (found version "62")
CMake Error at build/mingw/vcpkg_installed/x64-mingw-dynamic/share/openal-soft/OpenALConfig.cmake:1 (cmake_minimum_required):
  Compatibility with CMake < 3.5 has been removed from CMake.
  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.

  Or, add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to try configuring anyway.
Call Stack (most recent call first):
  vcpkg/scripts/buildsystems/vcpkg.cmake:904 (_find_package)
  CMakeLists.txt:79 (find_package)


-- Configuring incomplete, errors occurred!

After this, I re-added all the "CMAKE_POLICY_VERSION_MINIMUM": "3.5" to the CMakePresets.json and built the project again. This time it built successfully (with a warning instead of an error):

All requested installations completed successfully in: 993 us
-- Running vcpkg install - done
CMake Deprecation Warning at build/mingw/vcpkg_installed/x64-mingw-dynamic/share/openal-soft/OpenALConfig.cmake:1 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  vcpkg/scripts/buildsystems/vcpkg.cmake:904 (_find_package)
  CMakeLists.txt:79 (find_package)

-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Found OpenGL: opengl32
CMake Error: failed to create symbolic link 'F:/repos/endless-sky/build/compile_commands.json': A required privilege is not held by the client.

-- Configuring done (6.9s)
-- Generating done (0.5s)
-- Build files have been written to: F:/repos/endless-sky/build/mingw


In the end, I successfully built both the debug and release versions of the game and tested them.
I removed the added --abi-tools-use-exact-versions from branch and committed the mentioned changes

@TomGoodIdea
Copy link
Member

Looks like a newer version of libxcrypt requires additional dependencies. You probably need to add them to the rest of installed dependencies in workflows files in .github.

@TomGoodIdea
Copy link
Member

I've tried to test this locally on Windows with CMake 4.0.1, and it fails, with vcpkg-manifest-install.log saying that it's unable to launch the Powershell it just downloaded. When I tried to manually run the pwsh.exe, it crashed with BEX64.
Endless Sky master, while still fails because of incompatibility with CMake 4, at least passes this step.

@ciphell
Copy link
Contributor Author

ciphell commented Nov 5, 2025

I changed the vcpkg version to use the same powershell version as master. the vcpkg is just before they change the version of powershell. just before this PR microsoft/vcpkg#47326

Copy link
Member

@TomGoodIdea TomGoodIdea left a comment

Choose a reason for hiding this comment

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

Looks good now. Thanks for working on this!

@TomGoodIdea TomGoodIdea linked an issue Nov 5, 2025 that may be closed by this pull request
1 task
@TomGoodIdea TomGoodIdea merged commit faf7116 into endless-sky:master Nov 5, 2025
24 checks passed
@ciphell
Copy link
Contributor Author

ciphell commented Nov 5, 2025

Thank you for your instant feedback. I’m glad to be of help. Love your works

@ciphell ciphell deleted the fix/cmake4 branch November 5, 2025 23:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cd/ci/testing Issues and PRs relating to CD, CI, or unit testing.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Building with cmake 4 (on windows)

2 participants