Skip to content

Commit fd77bcb

Browse files
cmake: Use cxx-qt-cmake repo for CMake code
This allows us to download a lot less data with FetchContent for quickier deployment.
1 parent 2c319ec commit fd77bcb

File tree

11 files changed

+82
-134
lines changed

11 files changed

+82
-134
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4444
- Dependencies are now automatically detected and configured by cxx-qt-build
4545
- Libraries can pass build information to cxx-qt-build in the form of a `cxx_qt_build::Interface`
4646
- Add CMake wrappers around corrosion to simplify importing crates and qml modules that were built with cxx-qt-build
47+
- CMake code has been extracted into a separate repository for faster downloads (kdab/cxx-qt-cmake)
4748

4849
### Removed
4950

CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ set(CMAKE_CXX_STANDARD 17)
107107
set(CMAKE_CXX_STANDARD_REQUIRED ON)
108108

109109
include(CompilerCaching)
110-
include(CxxQt)
111110

112111
# Enable extra Qt definitions for all projects
113112
add_compile_definitions(

book/src/getting-started/5-cmake-integration.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ For this example, we are [supporting both Qt5 and Qt6 with CMake](https://doc.qt
135135
Download CXX-Qts CMake code with FetchContent:
136136

137137
```cmake,ignore
138-
{{#include ../../../examples/qml_minimal/CMakeLists.txt:book_cmake_find_cxx_qt}}
138+
{{#include ../../../examples/qml_minimal/CMakeLists.txt:book_cmake_find_cxx_qt_start}}
139+
GIT_TAG v0.7.0
140+
{{#include ../../../examples/qml_minimal/CMakeLists.txt:book_cmake_find_cxx_qt_end}}
139141
```
140142

141143
This provides you with a few wrappers around [Corrosion](https://github.com/corrosion-rs/corrosion), a tool for integrating Rust libraries into CMake:

cmake/CxxQt.cmake

-123
This file was deleted.

examples/demo_threading/CMakeLists.txt

+12
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ if(NOT Qt6_FOUND)
2828
find_package(Qt5 5.15 COMPONENTS Core Gui Qml QuickControls2 QmlImportScanner REQUIRED)
2929
endif()
3030

31+
find_package(CxxQt QUIET)
32+
if(NOT CxxQt_FOUND)
33+
include(FetchContent)
34+
FetchContent_Declare(
35+
CxxQt
36+
GIT_REPOSITORY https://github.com/kdab/cxx-qt-cmake.git
37+
GIT_TAG main
38+
)
39+
40+
FetchContent_MakeAvailable(CxxQt)
41+
endif()
42+
3143
set(CRATE cxx_qt_demo_threading)
3244
cxx_qt_import_crate(MANIFEST_PATH rust/Cargo.toml CRATES ${CRATE})
3345
cxx_qt_import_qml_module(${CRATE}_qml

examples/qml_features/CMakeLists.txt

+12
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ if(NOT Qt6_FOUND)
2828
find_package(Qt5 5.15 COMPONENTS Core Gui Qml Quick QuickControls2 QmlImportScanner QuickTest Test REQUIRED)
2929
endif()
3030

31+
find_package(CxxQt QUIET)
32+
if(NOT CxxQt_FOUND)
33+
include(FetchContent)
34+
FetchContent_Declare(
35+
CxxQt
36+
GIT_REPOSITORY https://github.com/kdab/cxx-qt-cmake.git
37+
GIT_TAG main
38+
)
39+
40+
FetchContent_MakeAvailable(CxxQt)
41+
endif()
42+
3143
set(CRATE qml_features)
3244
cxx_qt_import_crate(MANIFEST_PATH rust/Cargo.toml CRATES ${CRATE})
3345
cxx_qt_import_qml_module(${CRATE}_qml

examples/qml_minimal/CMakeLists.txt

+15-9
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,21 @@ if(NOT Qt6_FOUND)
2929
endif()
3030
# ANCHOR_END: book_cmake_setup
3131

32-
# ANCHOR: book_cmake_find_qmake
33-
# The path to the qmake executable path needs to be passed to the Rust
34-
# library's build script to ensure it uses the same installation of Qt as CMake.
35-
# TODO: This has been removed, document it
36-
# ANCHOR_END: book_cmake_find_qmake
37-
38-
# ANCHOR: book_cmake_find_cxx_qt
39-
# TODO: Replace with fetch-content co cxx-qt-cmake
40-
# ANCHOR_END: book_cmake_find_cxx_qt
32+
# ANCHOR: book_cmake_find_cxx_qt_start
33+
find_package(CxxQt QUIET)
34+
if(NOT CxxQt_FOUND)
35+
include(FetchContent)
36+
FetchContent_Declare(
37+
CxxQt
38+
GIT_REPOSITORY https://github.com/kdab/cxx-qt-cmake.git
39+
# ANCHOR_END: book_cmake_find_cxx_qt_start
40+
GIT_TAG main
41+
# ANCHOR: book_cmake_find_cxx_qt_end
42+
)
43+
44+
FetchContent_MakeAvailable(CxxQt)
45+
endif()
46+
# ANCHOR_END: book_cmake_find_cxx_qt_end
4147

4248
# ANCHOR: book_cmake_use_cxx_qt
4349
# CXX-Qt (using Corrosion) creates a CMake target with the same name as the crate.

scripts/release_crates.sh

+3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ function release_crate() {
4646
# Remind about cargo login
4747
question_yesno "Have you run cargo login before and setup credentials"
4848

49+
# cxx-qt-cmake (no dependencies)
50+
question_yesno "Have you created a new tag in the cxx-qt-cmake repo"
51+
4952
# No other dependencies
5053
release_crate "qt-build-utils"
5154

tests/basic_cxx_only/CMakeLists.txt

+12
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ if(NOT Qt6_FOUND)
3030
find_package(Qt5 5.15 COMPONENTS Core Gui Qml Test REQUIRED)
3131
endif()
3232

33+
find_package(CxxQt QUIET)
34+
if(NOT CxxQt_FOUND)
35+
include(FetchContent)
36+
FetchContent_Declare(
37+
CxxQt
38+
GIT_REPOSITORY https://github.com/kdab/cxx-qt-cmake.git
39+
GIT_TAG main
40+
)
41+
42+
FetchContent_MakeAvailable(CxxQt)
43+
endif()
44+
3345
set(CRATE basic_cxx_only)
3446
cxx_qt_import_crate(MANIFEST_PATH rust/Cargo.toml CRATES ${CRATE})
3547

tests/basic_cxx_qt/CMakeLists.txt

+12
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ if(NOT Qt6_FOUND)
3030
find_package(Qt5 5.15 COMPONENTS Core Gui Qml Test REQUIRED)
3131
endif()
3232

33+
find_package(CxxQt QUIET)
34+
if(NOT CxxQt_FOUND)
35+
include(FetchContent)
36+
FetchContent_Declare(
37+
CxxQt
38+
GIT_REPOSITORY https://github.com/kdab/cxx-qt-cmake.git
39+
GIT_TAG main
40+
)
41+
42+
FetchContent_MakeAvailable(CxxQt)
43+
endif()
44+
3345
set(CRATE basic_cxx_qt)
3446
cxx_qt_import_crate(MANIFEST_PATH rust/Cargo.toml CRATES ${CRATE})
3547

tests/qt_types_standalone/CMakeLists.txt

+12
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ if(NOT Qt6_FOUND)
3030
find_package(Qt5 5.15 COMPONENTS Core Gui Qml Test REQUIRED)
3131
endif()
3232

33+
find_package(CxxQt QUIET)
34+
if(NOT CxxQt_FOUND)
35+
include(FetchContent)
36+
FetchContent_Declare(
37+
CxxQt
38+
GIT_REPOSITORY https://github.com/kdab/cxx-qt-cmake.git
39+
GIT_TAG main
40+
)
41+
42+
FetchContent_MakeAvailable(CxxQt)
43+
endif()
44+
3345
set(CRATE qt_types_standalone)
3446
cxx_qt_import_crate(MANIFEST_PATH rust/Cargo.toml CRATES ${CRATE})
3547

0 commit comments

Comments
 (0)