Building Swift with custom cmake toolchain?

Hi:
In our downstream implementation, we use package managers like vcpkg or Conan, that provides its own cmake toolchain file, that we pass into the build with:

extra-cmake-options=
  -DCMAKE_TOOLCHAIN_FILE=/PATH/TO/FILE

However, starting from 5.9.0, we noticed that swift-syntax start to break, and digging into the build logs reveals that it's missing CMAKE_Swift_COMPILER_TARGET, which is supposed to be set by the CMake toolchain generated by Swift's buildsystem, yet unfortunately get overridden by our custom cmake toolchain options.

Workarounds?

1 Like

For now, I workaround this issue locally by applying:

  -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE="Build/AppleLLVM/5.9.0/BuildScriptToolchain.cmake"

However a method to programmatically obtain the path of BuildScriptToolchain.cmake is required

1 Like