lukka / run-cmake

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

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

Closed SamuelMarks closed 1 year ago

SamuelMarks commented 2 years ago

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

lukka commented 2 years ago

@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).

SamuelMarks commented 2 years ago

@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.

lukka commented 2 years ago

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

SamuelMarks commented 2 years ago

@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)

lukka commented 2 years ago

@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:

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

lukka commented 1 year ago

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