-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
integrate qml-minimal-no-cmake into CMake build
- Loading branch information
Showing
3 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# SPDX-FileCopyrightText: 2022 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]> | ||
# SPDX-FileContributor: Be Wilson <[email protected]> | ||
# | ||
# SPDX-License-Identifier: MIT OR Apache-2.0 | ||
|
||
# This CMakeLists.txt does not build any C++ directly. It is only here to integrate building | ||
# this crate into the larger CMake build of this repository. For development and testing, you | ||
# can run | ||
# | ||
# cargo build -p qml-minimal-no-cmake | ||
# | ||
# from any directory in this repository to build this crate without using CMake at all. | ||
|
||
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Gui Qml QuickControls2 QmlImportScanner REQUIRED) | ||
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Qml QuickControls2 QmlImportScanner REQUIRED) | ||
get_target_property(QMAKE Qt${QT_VERSION_MAJOR}::qmake IMPORTED_LOCATION) | ||
|
||
# Use Corrosion to create a target for the crate that can be built without CMake. | ||
# This allows it to share built dependencies with the other crates in the workspace. | ||
find_package(Corrosion QUIET) | ||
if(NOT Corrosion_FOUND) | ||
include(FetchContent) | ||
FetchContent_Declare( | ||
Corrosion | ||
GIT_REPOSITORY https://github.com/corrosion-rs/corrosion.git | ||
GIT_TAG v0.2.1 | ||
) | ||
|
||
FetchContent_MakeAvailable(Corrosion) | ||
endif() | ||
|
||
set(CRATE qml-minimal-no-cmake) | ||
corrosion_import_crate(MANIFEST_PATH Cargo.toml CRATES ${CRATE}) | ||
corrosion_set_env_vars(${CRATE} "QMAKE=${QMAKE}") | ||
if(UNIX AND NOT APPLE) | ||
find_program(MOLD_EXECUTABLE mold) | ||
if(MOLD_EXECUTABLE) | ||
corrosion_add_target_rustflags(${CRATE} "-Clink-arg=-fuse-ld=mold") | ||
else() | ||
find_program(LLD_EXECUTABLE lld) | ||
if(LLD_EXECUTABLE) | ||
corrosion_add_target_rustflags(${CRATE} "-Clink-arg=-fuse-ld=lld") | ||
else() | ||
message(WARNING "Neither mold nor lld linkers were found. ${CRATE} will likely fail to link without using one of these.") | ||
endif() | ||
endif() | ||
endif() |