lukka / run-cmake

GitHub Action to build C++ applications with CMake (CMakePresets.json), Ninja and vcpkg on GitHub.
MIT License
171 stars 19 forks source link

vcpkg install fails due to `CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS-NOTFOUND` #138

Closed BurningEnlightenment closed 4 months ago

BurningEnlightenment commented 4 months ago

I'm unsure whether this action is at fault or the Problem is caused by get-cmake. However, I encountered a very weird situation with the following workflow setup while targetting clang-16 on Ubuntu 22.04:

      - uses: lukka/get-cmake@latest
        with:
          cmakeVersion: 3.22.6

      - name: Initialize vcpkg
        uses: lukka/run-vcpkg@v11
        with:
          vcpkgDirectory: ${{ github.workspace }}/build/vcpkg

      - name: Build ${{ matrix.triplet }}-${{ matrix.compiler }} preset
        uses: lukka/run-cmake@v10
        with:
          configurePreset: ${{ matrix.triplet }}-${{ matrix.compiler }}
          buildPreset: ${{ matrix.triplet }}-${{ matrix.compiler }}
          testPreset: ${{ matrix.triplet }}-${{ matrix.compiler }}

The pipeline fails with the output:

  Running command '/home/runner/work/_temp/1334830730/cmake-3.22.6-linux-x86_64/bin/cmake' with args '--preset,x64-linux-clang' in current directory '/home/runner/work/libvefs/libvefs'.
  Preset CMake variables:

    BUILD_CLI:BOOL="TRUE"
    BUILD_TESTING:BOOL="TRUE"
    CMAKE_DEBUG_POSTFIX="-dbg"
    CMAKE_INSTALL_PREFIX="/home/runner/work/libvefs/libvefs/build/zinstall"
    CMAKE_TOOLCHAIN_FILE:FILEPATH="/home/runner/work/libvefs/libvefs/build/vcpkg/scripts/buildsystems/vcpkg.cmake"
    VCPKG_CHAINLOAD_TOOLCHAIN_FILE="/home/runner/work/libvefs/libvefs/tools/toolchains/x64-linux-clang-16.cmake"
    VCPKG_TARGET_TRIPLET="x64-linux-clang-16"
    WARNINGS_AS_ERRORS:BOOL="TRUE"

  -- Running vcpkg install
[...]
  -- Check for working CXX compiler: /usr/bin/clang++-16
  -- Check for working CXX compiler: /usr/bin/clang++-16 - broken
  -- Configuring incomplete, errors occurred!

  [LogCollection][End]File:'/home/runner/work/libvefs/libvefs/build/vcpkg/buildtrees/detect_compiler/config-x64-linux-clang-16-rel-out.log'.
  [LogCollection][Start]File:'/home/runner/work/libvefs/libvefs/build/vcpkg/buildtrees/detect_compiler/config-x64-linux-clang-16-rel-err.log':
  CMake Error at /usr/local/share/cmake-3.28/Modules/CMakeTestCXXCompiler.cmake:60 (message):
  Error:   The C++ compiler

      "/usr/bin/clang++-16"

    is not able to compile a simple test program.

    It fails with the following output:

      Change Dir: '/home/runner/work/libvefs/libvefs/build/vcpkg/buildtrees/detect_compiler/x64-linux-clang-16-rel/CMakeFiles/CMakeScratch/TryCompile-uqfV8L'

      Run Build Command(s): /home/runner/work/_temp/1334830730/ninja-1.11.1.g95dee.kitware.jobserver-1_x86_64-linux-gnu/ninja -v cmTC_2b440
      [1/4] "CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS-NOTFOUND" -format=p1689 -- /usr/bin/clang++-16   -fsized-deallocation  -std=gnu++20 -x c++ /home/runner/work/libvefs/libvefs/build/vcpkg/buildtrees/detect_compiler/x64-linux-clang-16-rel/CMakeFiles/CMakeScratch/TryCompile-uqfV8L/testCXXCompiler.cxx -c -o CMakeFiles/cmTC_2b440.dir/testCXXCompiler.cxx.o -MT CMakeFiles/cmTC_2b440.dir/testCXXCompiler.cxx.o.ddi -MD -MF CMakeFiles/cmTC_2b440.dir/testCXXCompiler.cxx.o.ddi.d > CMakeFiles/cmTC_2b440.dir/testCXXCompiler.cxx.o.ddi.tmp && mv CMakeFiles/cmTC_2b440.dir/testCXXCompiler.cxx.o.ddi.tmp CMakeFiles/cmTC_2b440.dir/testCXXCompiler.cxx.o.ddi

Note how the command (correctly) invokes /home/runner/work/_temp/1334830730/cmake-3.22.6-linux-x86_64/bin/cmake, but CMake uses the module /usr/local/share/cmake-3.28/Modules/CMakeTestCXXCompiler.cmake.

I have no idea how this can even happen 😅

BurningEnlightenment commented 4 months ago

Oh my god. I didn't realize that the error comes from within vcpkg install. The only possible fix without upgrading to clang-17 is to add set(CMAKE_CXX_SCAN_FOR_MODULES 0) to a CMake toolchain file and use that from a custom vcpkg triplet. blergh.