Skip to content

Commit

Permalink
move build directory outside of repository
Browse files Browse the repository at this point in the history
to hack around rust-lang/cargo#12360
and fix Windows build with Rust 1.71
  • Loading branch information
Be-ing committed Jul 14, 2023
1 parent 26cb666 commit 47999bf
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 19 deletions.
44 changes: 27 additions & 17 deletions .github/workflows/github-cxx-qt-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ jobs:
qml-module-qtquick2
qml-module-qtquick-controls2
qml-module-qttest
workspace: /home/runner/cxx-qt
repository: /home/runner/cxx-qt
build_dir: /home/runner/cxx-qt/build
- name: Ubuntu 22.04 (gcc) Qt6
os: ubuntu-22.04
qt_version: 6
Expand All @@ -53,7 +54,8 @@ jobs:
libgl1-mesa-dev
libvulkan-dev
libxkbcommon-dev
workspace: /home/runner/cxx-qt
repository: /home/runner/cxx-qt
build_dir: /home/runner/cxx-qt/build

- name: macOS 11 (clang) Qt5
os: macos-11
Expand All @@ -69,7 +71,8 @@ jobs:
qt_qpa_platform: cocoa
compiler_cache_path: /Users/runner/Library/Caches/Mozilla.sccache
cargo_dir: ~/.cargo
workspace: /Users/runner/cxx-qt
repository: /Users/runner/cxx-qt
build_dir: /Users/runner/cxx-qt/build
cc: clang
cxx: clang++
- name: macOS 11 (clang) Qt6
Expand All @@ -81,7 +84,8 @@ jobs:
qt_qpa_platform: cocoa
compiler_cache_path: /Users/runner/Library/Caches/Mozilla.sccache
cargo_dir: ~/.cargo
workspace: /Users/runner/cxx-qt
repository: /Users/runner/cxx-qt
build_dir: /Users/runner/cxx-qt/build
cc: clang
cxx: clang++

Expand All @@ -96,7 +100,10 @@ jobs:
cc: cl
cxx: cl
# The D drive runs out of space when building dependencies with vcpkg.
workspace: C:\cxx-qt
repository: C:\cxx-qt
# The build directory needs to be outside of the repository to workaround
# https://github.com/rust-lang/cargo/issues/12360
build_dir: C:\build
- name: Windows 2022 (MSVC) Qt6
os: windows-2022
qt_version: 6
Expand All @@ -108,7 +115,10 @@ jobs:
cc: cl
cxx: cl
# The D drive runs out of space when building dependencies with vcpkg.
workspace: C:\cxx-qt
repository: C:\cxx-qt
# The build directory needs to be outside of the repository to workaround
# https://github.com/rust-lang/cargo/issues/12360
build_dir: C:\build

runs-on: ${{ matrix.os }}
name: ${{ matrix.name }}
Expand All @@ -119,14 +129,14 @@ jobs:
SCCACHE_CACHE_SIZE: 600M

steps:
# On Windows, the D drive that the workspace is on by default runs out of space when
# On Windows, the D drive that the repository is on by default runs out of space when
# vcpkg builds Qt, so the repo needs to be cloned to the C drive. GitHub's checkout
# action does not support cloning to a path outside GITHUB_WORKSPACE:
# https://github.com/actions/checkout/issues/197
- name: "Clone Git repository"
uses: LebedevRI/checkout@issue197
with:
path: ${{ matrix.workspace }}
path: ${{ matrix.repository }}
- name: "Install Rust toolchain"
uses: actions-rs/toolchain@v1
with:
Expand Down Expand Up @@ -206,20 +216,20 @@ jobs:
-D USE_QT5=${{ matrix.qt_version == 5 }}
-D CMAKE_BUILD_TYPE=Release
-G Ninja
-S . -B build
working-directory: ${{ matrix.workspace }}
-S . -B ${{ matrix.build_dir }}
working-directory: ${{ matrix.repository }}
env:
RUSTC_WRAPPER: sccache
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
- name: "Build"
run: cmake --build build --config Release --parallel 2
working-directory: ${{ matrix.workspace }}
run: cmake --build ${{ matrix.build_dir }} --config Release --parallel 2
working-directory: ${{ matrix.repository }}
env:
RUSTC_WRAPPER: sccache
- name: "Test"
run: ctest ${{ matrix.ctest_args }} -C Release -T test --output-on-failure --parallel 2
working-directory: ${{ matrix.workspace }}/build
working-directory: ${{ matrix.build_dir }}
env:
RUSTC_WRAPPER: sccache
QT_QPA_PLATFORM: ${{ matrix.qt_qpa_platform }}
Expand All @@ -234,8 +244,8 @@ jobs:
with:
name: vcpkg-logs-${{ matrix.name }}
path: |
${{ matrix.workspace }}/vcpkg/buildtrees/**/*.log
${{ matrix.workspace }}/build/vcpkg-bootstrap.log
${{ matrix.workspace }}/build/vcpkg-manifest-install.log
${{ matrix.workspace }}/build/vcpkg_installed/vcpkg/issue_body.md
${{ matrix.repository }}/vcpkg/buildtrees/**/*.log
${{ matrix.repository }}/build/vcpkg-bootstrap.log
${{ matrix.repository }}/build/vcpkg-manifest-install.log
${{ matrix.repository }}/build/vcpkg_installed/vcpkg/issue_body.md
if-no-files-found: ignore
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,11 @@ add_test(NAME cargo_fmt COMMAND cargo fmt --all --check WORKING_DIRECTORY ${CMAK

set_tests_properties(cargo_tests cargo_doc_tests cargo_clippy cargo_fmt PROPERTIES
ENVIRONMENT_MODIFICATION "${CARGO_ENV}"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
)
set_tests_properties(cargo_doc PROPERTIES
ENVIRONMENT_MODIFICATION "${CARGO_ENV};RUSTDOCFLAGS=set:--deny=warnings"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
)

# Ensure test inputs and outputs are formatted
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,12 @@ you run CMake). If you already have Qt installed, you can disable this by adding
CXX-Qt defaults to building with Qt6. If you want to build with Qt5 when both are installed,
or you want to tell vcpkg to use Qt5, add `-D USE_QT5=ON` to the CMake configure step.

On Windows, the CMake build directory needs to be outside of the code repository to work
around a [Cargo bug](https://github.com/rust-lang/cargo/issues/12360).

```bash
cmake -S . -B build
cmake --build build
cmake -S . -B path/to/build/dir/of/your/choice
cmake --build path/to/build/dir/of/your/choice
```

### Run the basic QML example
Expand Down

0 comments on commit 47999bf

Please sign in to comment.