Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@ set(CARGO_TARGET_DIR "${CMAKE_BINARY_DIR}/${BUILD_DIR}/cargo/build")

if(BUILD_TESTING)
# Add CMake tests for `cargo test/clippy/fmt/doc`.
add_test(NAME cargo_tests COMMAND cargo test --release --all-features --target-dir ${CARGO_TARGET_DIR})
add_test(NAME cargo_doc COMMAND cargo doc --release --all-features --target-dir ${CARGO_TARGET_DIR})
add_test(NAME cargo_tests COMMAND cargo test --locked --release --all-features --target-dir ${CARGO_TARGET_DIR})
add_test(NAME cargo_doc COMMAND cargo doc --locked --release --all-features --target-dir ${CARGO_TARGET_DIR})
# Minimum clippy version for the incompatible_msrv lint is 1.78.0
add_test(NAME cargo_clippy COMMAND cargo +1.78.0 clippy --release --all-features --target-dir ${CARGO_TARGET_DIR} -- -D warnings)
add_test(NAME cargo_clippy COMMAND cargo +1.78.0 clippy --locked --release --all-features --target-dir ${CARGO_TARGET_DIR} -- -D warnings)

set_tests_properties(cargo_tests cargo_clippy PROPERTIES
ENVIRONMENT_MODIFICATION "${CARGO_ENV}"
Expand All @@ -168,7 +168,7 @@ if(BUILD_TESTING)
add_test(NAME cxx_qt_gen_test_outputs_gen COMMAND rustfmt --check ${CXX_QT_GEN_TEST_OUTPUTS})

# Add test which checks that a build rerun doesn't recompile and uses caches instead
add_test(NAME cargo_build_rerun COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/scripts/check_cargo_build_rerun.sh" "${CMAKE_CURRENT_SOURCE_DIR}")
add_test(NAME cargo_build_rerun COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/scripts/check_cargo_build_rerun.sh" "${CMAKE_CURRENT_SOURCE_DIR}" "${CARGO_TARGET_DIR}")

# Ensure that cargo_build_rerun doesn't run while we are already building
set_tests_properties(cargo_build_rerun PROPERTIES RUN_SERIAL TRUE)
Expand Down
4 changes: 3 additions & 1 deletion examples/demo_threading/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ set(CRATE cxx_qt_demo_threading)
cxx_qt_import_crate(
MANIFEST_PATH rust/Cargo.toml
CRATES ${CRATE}
QT_MODULES Qt::Core)
LOCKED
QT_MODULES Qt::Core
)
cxx_qt_import_qml_module(${CRATE}_qml
URI "com.kdab.energy"
SOURCE_CRATE ${CRATE})
Expand Down
1 change: 1 addition & 0 deletions examples/qml_features/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ set(CRATE qml_features)
cxx_qt_import_crate(
MANIFEST_PATH rust/Cargo.toml
CRATES ${CRATE}
LOCKED
QT_MODULES Qt::Core Qt::Gui Qt::Qml Qt::Quick
)
cxx_qt_import_qml_module(${CRATE}_qml
Expand Down
4 changes: 3 additions & 1 deletion examples/qml_minimal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ endif()
cxx_qt_import_crate(
MANIFEST_PATH rust/Cargo.toml
CRATES qml_minimal
QT_MODULES Qt::Core Qt::Gui Qt::Qml Qt::QuickControls2)
LOCKED
QT_MODULES Qt::Core Qt::Gui Qt::Qml Qt::QuickControls2
)

cxx_qt_import_qml_module(qml_minimal_qml_module
URI "com.kdab.cxx_qt.demo"
Expand Down
4 changes: 3 additions & 1 deletion examples/qml_multi_crates/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ endif()
cxx_qt_import_crate(MANIFEST_PATH rust/main/Cargo.toml
CRATES qml_multi_crates
CRATE_TYPES staticlib
QT_MODULES Qt::Core Qt::Gui Qt::Qml Qt::QuickControls2 Qt::Network)
LOCKED
QT_MODULES Qt::Core Qt::Gui Qt::Qml Qt::QuickControls2 Qt::Network
)

cxx_qt_import_qml_module(qml_multi_crates_main
URI "com.kdab.cxx_qt.demo"
Expand Down
17 changes: 9 additions & 8 deletions scripts/check_cargo_build_rerun.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@

set -ex

SOURCE_FOLDER=$1
BUILD_FOLDER=$2

# Ensure we are in the right directory
SCRIPT=$(realpath "$0")
SCRIPTPATH=$(dirname "$SCRIPT")
cd "$SCRIPTPATH/../"
cd "$SOURCE_FOLDER"

# Ensure that we do see a "Compiling" in the output
# as if we do it means we have a cargo::rerun-if-changed incorrectly
function check_build_contains_compiling() {
BUILD=$(cargo build -p qml-minimal-no-cmake 2>&1)
BUILD=$(cargo build --locked --release --target-dir="$BUILD_FOLDER" -p qml-minimal-no-cmake 2>&1)

if ! echo "$BUILD" | grep -q Compiling; then
echo "cargo build is missing text 'Compiling', likely an incorrect cargo::rerun-if-changed in a build script."
Expand All @@ -26,7 +27,7 @@ function check_build_contains_compiling() {
# Ensure that we don't see any "Compiling" in the output
# as if we do it means we have a cargo::rerun-if-changed incorrectly
function check_build_no_compiling() {
BUILD=$(cargo build -p qml-minimal-no-cmake 2>&1)
BUILD=$(cargo build --locked --release --target-dir="$BUILD_FOLDER" -p qml-minimal-no-cmake 2>&1)

if echo "$BUILD" | grep -q Compiling; then
echo "cargo build contained text 'Compiling', likely an incorrect cargo::rerun-if-changed in a build script."
Expand All @@ -35,20 +36,20 @@ function check_build_no_compiling() {
}

# Build once
cargo build -p qml-minimal-no-cmake
cargo build --locked --release --target-dir="$BUILD_FOLDER" -p qml-minimal-no-cmake

# Build a second time
check_build_no_compiling

# Modify a qml file
touch "$SCRIPTPATH/../examples/cargo_without_cmake/qml/main.qml"
touch "$SOURCE_FOLDER/examples/cargo_without_cmake/qml/main.qml"

# Build a third and fourth time
check_build_contains_compiling
check_build_no_compiling

# Modify a Rust file
touch "$SCRIPTPATH/../examples/cargo_without_cmake/src/cxxqt_object.rs"
touch "$SOURCE_FOLDER/examples/cargo_without_cmake/src/cxxqt_object.rs"

# Build a fifth and sixth time
check_build_contains_compiling
Expand Down
2 changes: 1 addition & 1 deletion tests/basic_cxx_only/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ if(NOT CxxQt_FOUND)
endif()

set(CRATE basic_cxx_only)
cxx_qt_import_crate(MANIFEST_PATH rust/Cargo.toml CRATES ${CRATE} QT_MODULES Qt::Core)
cxx_qt_import_crate(MANIFEST_PATH rust/Cargo.toml CRATES ${CRATE} LOCKED QT_MODULES Qt::Core)

if(BUILD_WASN)
# Add -DRUST_CXX_NO_EXCEPTIONS to CXXFLAGS, as WASM does not support exceptions
Expand Down
2 changes: 1 addition & 1 deletion tests/basic_cxx_qt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ if(NOT CxxQt_FOUND)
endif()

set(CRATE basic_cxx_qt)
cxx_qt_import_crate(MANIFEST_PATH rust/Cargo.toml CRATES ${CRATE} QT_MODULES Qt::Core)
cxx_qt_import_crate(MANIFEST_PATH rust/Cargo.toml CRATES ${CRATE} LOCKED QT_MODULES Qt::Core)

if(BUILD_WASN)
# Add -DRUST_CXX_NO_EXCEPTIONS to CXXFLAGS, as WASM does not support exceptions
Expand Down
1 change: 1 addition & 0 deletions tests/qt_types_standalone/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ set(CRATE qt_types_standalone)
cxx_qt_import_crate(
MANIFEST_PATH rust/Cargo.toml
CRATES ${CRATE}
LOCKED
QT_MODULES Qt::Core Qt::Gui Qt::Qml
)

Expand Down
Loading