run-cmake icon indicating copy to clipboard operation
run-cmake copied to clipboard

How do I just do `vcpkg install packages && cmake -DCMAKE_TOOLCHAIN_FILE=%vcpkg%\scripts\buildsystems\vcpkg.cmake"`?

Open SamuelMarks opened this issue 4 years ago • 5 comments

Maybe I'm overcomplicating things, but I want to do:

  build_windows:
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v2
      - name: install dependencies
        run: |
          git clone --depth=1 https://github.com/Microsoft/vcpkg.git
          .\vcpkg\bootstrap-vcpkg.bat
          .\vcpkg\vcpkg install libarchive
      - name: build
        run: |
          md cmake-build-debug
          cd cmake-build-debug
          cmake .. -DCMAKE_TOOLCHAIN_FILE="..\vcpkg\scripts\buildsystems\vcpkg.cmake"
          cmake --build .
        shell: cmd
      - name: test
        run: ctest .
        working-directory: cmake-build-debug

Except I want to cache everything vcpkg related. Happy to pin https://github.com/Microsoft/vcpkg to a specific commit hash.

How do I do this with run-cmake, without introducing vcpkg as a submodule?

(also preferably without a vcpkg.json)

Thanks,

PS: I tried one the examples with submodule ❌'d on https://github.com/marketplace/actions/run-vcpkg#samples… but it still required a submodule

SamuelMarks avatar Nov 23 '21 00:11 SamuelMarks

@SamuelMarks if i get this right, this is the question: "how can I implement a pure workflow without using run-vcpkg (with or without run-cmake) and without having vcpkg as a submodule?"

I think the generic answer is to leverage actions/checkout. A concrete example is in the pure workflow at lukka/CppCMakeVcpkgTemplate: note that this workflow is using vcpkg as a submodule, hence all you have to do in addition to that is to ensure the sources are on disk before they are going to be used (which is already nicely done in the workflow you shown in the question).

lukka avatar Nov 23 '21 15:11 lukka

@lukka Yeah I'm trying to put it together https://github.com/offscale/libacquire/blob/1cc1da3/.github/workflows/github-actions.yml#L47-L99 (previous commit I tried using checkout)

Happy to use run-vcpkg, but I don't want vcpkg as a submodule. Also would prefer not to have a vcpkg.json.

SamuelMarks avatar Nov 23 '21 18:11 SamuelMarks

@SamuelMarks closing stale issues. Feel free to continue discussion if needed.

lukka avatar Feb 13 '22 14:02 lukka

@lukka My question remains, how do I replace my vcpkg cache hack with your run-cmake without adding a submodule?

(for bonus points: manifest mode caching)

SamuelMarks avatar Feb 14 '22 01:02 SamuelMarks

@SamuelMarks you can use run-vcpkg with an explicit value for vcpkgDirectory input that points to the file system location where you want vcpkg to be checked out. If it is not a submodule, it will be automatically checked out in that location.

You also need to specify the Git commit id in vcpkgGitCommitId, which would not be needed if vcpkg was a submodule.

Guess other details are missing that depends on your requirements, but to give an idea:

  • if vcpkg is going to be launched by CMake (e.g. by run-cmake or by plain invocation to cmake -DVCPKGTOOLCHAIN), everything should be working fine, but you need to double check the right locations are automatically cached.
  • if vcpkg is run by run-vcpkg itself (i.e. runVcpkgInstall input is true), then something else (not sure what) must be done that needs to be figure out.

Glad to help further if you have a workflow to reason on.

lukka avatar Feb 14 '22 11:02 lukka

Closing this issue as stale since long time, let me know if you need any support @SamuelMarks, thanks!

lukka avatar Oct 17 '22 03:10 lukka