Skip to content

Commit

Permalink
break
Browse files Browse the repository at this point in the history
  • Loading branch information
Be-ing committed Jan 30, 2024
1 parent 77f263e commit 45a8728
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
2 changes: 0 additions & 2 deletions crates/cxx-qt-build/src/broken.cpp

This file was deleted.

1 change: 0 additions & 1 deletion crates/cxx-qt-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,6 @@ impl CxxQtBuilder {
builder.flag_if_supported("-Wa,-mbig-obj");
// macOS
builder.flag_if_supported(&format!("-mmacosx-version-min={}", macos_deployment_target));
builder.file(&format!("{}/broken.cpp", env!("CARGO_MANIFEST_DIR")));
// Enable Qt Gui in C++ if the feature is enabled
#[cfg(feature = "qt_gui")]
builder.define("CXX_QT_GUI_FEATURE", None);
Expand Down
1 change: 1 addition & 0 deletions crates/cxx-qt-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ url = { version = "2.3", optional = true }
cxx-build.workspace = true
cxx-qt-lib-headers.workspace = true
qt-build-utils.workspace = true
versions.workspace = true

[features]
default = ["qt_gui", "qt_qml"]
Expand Down
30 changes: 30 additions & 0 deletions crates/cxx-qt-lib/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
//
// SPDX-License-Identifier: MIT OR Apache-2.0

use std::env;
use versions::SemVer;

fn main() {
let feature_qt_gui_enabled = std::env::var("CARGO_FEATURE_QT_GUI").is_ok();
let feature_qt_qml_enabled = std::env::var("CARGO_FEATURE_QT_QML").is_ok();
Expand Down Expand Up @@ -280,6 +283,30 @@ fn main() {
builder.define("CXX_QT_QML_FEATURE", None);
}

// With macOS we need
// - std::filesystem::path from 10.15
// - std::shared_mutex from 10.12
static MACOS_DEPLOYMENT_TARGET_MINIMUM: &str = "10.15";
let macos_deployment_target = match env::var("MACOSX_DEPLOYMENT_TARGET") {
Ok(v) => {
let version = if v.is_empty() {
SemVer::new(MACOS_DEPLOYMENT_TARGET_MINIMUM).unwrap()
} else {
SemVer::new(&v).expect(
"MACOSX_DEPLOYMENT_TARGET environment variable set but could not parse it as a version.",
)
};

if version < SemVer::new(MACOS_DEPLOYMENT_TARGET_MINIMUM).unwrap() {
println!("cargo:warning=CXX-Qt requires MACOSX_DEPLOYMENT_TARGET >= 10.15, using 10.15.");
MACOS_DEPLOYMENT_TARGET_MINIMUM.to_owned()
} else {
v
}
}
Err(_) => MACOS_DEPLOYMENT_TARGET_MINIMUM.to_owned(),
};

// Note, ensure our settings stay in sync across cxx-qt-build and cxx-qt-lib
builder.cpp(true);
// MSVC
Expand All @@ -289,6 +316,9 @@ fn main() {
builder.flag_if_supported("/bigobj");
// GCC + Clang
builder.flag_if_supported("-std=c++17");
// macOS
builder.flag_if_supported(&format!("-mmacosx-version-min={}", macos_deployment_target));
builder.file(&format!("{}/src/broken.cpp", env!("CARGO_MANIFEST_DIR")));
// MinGW requires big-obj otherwise debug builds fail
builder.flag_if_supported("-Wa,-mbig-obj");

Expand Down

0 comments on commit 45a8728

Please sign in to comment.