[cmake] enable clang-cl and WoA builds (#348)

Compilation and CMake fixes for both Windows on ARM and clang-cl, meaning Windows can now be built on both MSVC and clang on both amd64 and aarch64.

Compiling on clang is *dramatically* faster so this should be useful for CI.

Co-authored-by: crueter <crueter@eden-emu.dev>
Co-authored-by: crueter <crueter@crueter.xyz>
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/348
Reviewed-by: CamilleLaVey <camillelavey99@gmail.com>
Reviewed-by: crueter <crueter@eden-emu.dev>
Co-authored-by: lizzie <lizzie@eden-emu.dev>
Co-committed-by: lizzie <lizzie@eden-emu.dev>
This commit is contained in:
lizzie 2025-09-09 20:47:49 +02:00 committed by crueter
parent fe32891c9d
commit dfaecdf68c
No known key found for this signature in database
GPG key ID: 425ACD2D4830EBC6
276 changed files with 973 additions and 1010 deletions

View file

@ -256,7 +256,7 @@ if (YUZU_CRASH_DUMPS)
target_compile_definitions(yuzu PRIVATE YUZU_CRASH_DUMPS)
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if (CXX_CLANG)
target_compile_definitions(yuzu PRIVATE
$<$<VERSION_LESS:$<CXX_COMPILER_VERSION>,15>:CANNOT_EXPLICITLY_INSTANTIATE>
)

View file

@ -11,14 +11,15 @@ AboutDialog::AboutDialog(QWidget* parent)
: QDialog(parent)
, ui{std::make_unique<Ui::AboutDialog>()}
{
const auto description = std::string(Common::g_build_version);
const auto build_id = std::string(Common::g_build_id);
static const std::string description = std::string(Common::g_build_version);
static const std::string build_id = std::string(Common::g_build_id);
static const std::string compiler = std::string(Common::g_compiler_id);
std::string yuzu_build;
if (Common::g_is_dev_build) {
yuzu_build = fmt::format("Eden Nightly | {}-{}", description, build_id);
yuzu_build = fmt::format("Eden Nightly | {}-{} | {}", description, build_id, compiler);
} else {
yuzu_build = fmt::format("Eden | {}", description);
yuzu_build = fmt::format("Eden | {} | {}", description, compiler);
}
const auto override_build = fmt::format(fmt::runtime(

View file

@ -381,8 +381,8 @@ qreal GRenderWindow::windowPixelRatio() const {
std::pair<u32, u32> GRenderWindow::ScaleTouch(const QPointF& pos) const {
const qreal pixel_ratio = windowPixelRatio();
return {static_cast<u32>(std::max(std::round(pos.x() * pixel_ratio), qreal{0.0})),
static_cast<u32>(std::max(std::round(pos.y() * pixel_ratio), qreal{0.0}))};
return {static_cast<u32>((std::max)(std::round(pos.x() * pixel_ratio), qreal{0.0})),
static_cast<u32>((std::max)(std::round(pos.y() * pixel_ratio), qreal{0.0}))};
}
void GRenderWindow::closeEvent(QCloseEvent* event) {

View file

@ -484,8 +484,8 @@ void TouchScreenPreview::resizeEvent(QResizeEvent* event) {
return;
}
const int target_width = std::min(width(), height() * 4 / 3);
const int target_height = std::min(height(), width() * 3 / 4);
const int target_width = (std::min)(width(), height() * 4 / 3);
const int target_height = (std::min)(height(), width() * 3 / 4);
if (target_width == width() && target_height == height()) {
return;
}

View file

@ -490,7 +490,7 @@ void GameList::DonePopulating(const QStringList& watch_list) {
// Also artificially caps the watcher to a certain number of directories
constexpr int LIMIT_WATCH_DIRECTORIES = 5000;
constexpr int SLICE_SIZE = 25;
int len = std::min(static_cast<int>(watch_list.size()), LIMIT_WATCH_DIRECTORIES);
int len = (std::min)(static_cast<int>(watch_list.size()), LIMIT_WATCH_DIRECTORIES);
for (int i = 0; i < len; i += SLICE_SIZE) {
watcher->addPaths(watch_list.mid(i, i + SLICE_SIZE));
QCoreApplication::processEvents();

View file

@ -386,6 +386,7 @@ static void OverrideWindowsFont() {
}
#endif
#ifndef _WIN32
inline static bool isDarkMode() {
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
const auto scheme = QGuiApplication::styleHints()->colorScheme();
@ -397,6 +398,7 @@ inline static bool isDarkMode() {
return text.lightness() > window.lightness();
#endif // QT_VERSION
}
#endif // _WIN32
GMainWindow::GMainWindow(bool has_broken_vulkan)
: ui{std::make_unique<Ui::MainWindow>()}, system{std::make_unique<Core::System>()},
@ -2473,7 +2475,7 @@ void GMainWindow::StoreRecentFile(const QString& filename) {
void GMainWindow::UpdateRecentFiles() {
const int num_recent_files =
std::min(static_cast<int>(UISettings::values.recent_files.size()), max_recent_files_item);
(std::min)(static_cast<int>(UISettings::values.recent_files.size()), max_recent_files_item);
for (int i = 0; i < num_recent_files; i++) {
const QString text = QStringLiteral("&%1. %2").arg(i + 1).arg(
@ -2652,7 +2654,7 @@ static bool RomFSRawCopy(size_t total_size, size_t& read_size, QProgressDialog&
if ((new_timestamp - last_timestamp) > 33ms) {
last_timestamp = new_timestamp;
dialog.setValue(
static_cast<int>(std::min(read_size, total_size) * 100 / total_size));
static_cast<int>((std::min)(read_size, total_size) * 100 / total_size));
QCoreApplication::processEvents();
}
@ -4115,7 +4117,7 @@ void GMainWindow::OnDecreaseVolume() {
if (current_volume <= 6) {
step = 1;
}
Settings::values.volume.SetValue(std::max(current_volume - step, 0));
Settings::values.volume.SetValue((std::max)(current_volume - step, 0));
UpdateVolumeUI();
}
@ -5020,14 +5022,15 @@ void GMainWindow::OnEmulatorUpdateAvailable() {
void GMainWindow::UpdateWindowTitle(std::string_view title_name, std::string_view title_version,
std::string_view gpu_vendor) {
const auto description = std::string(Common::g_build_version);
const auto build_id = std::string(Common::g_build_id);
static const std::string description = std::string(Common::g_build_version);
static const std::string build_id = std::string(Common::g_build_id);
static const std::string compiler = std::string(Common::g_compiler_id);
std::string yuzu_title;
if (Common::g_is_dev_build) {
yuzu_title = fmt::format("Eden Nightly | {}-{}", description, build_id);
yuzu_title = fmt::format("Eden Nightly | {}-{} | {}", description, build_id, compiler);
} else {
yuzu_title = fmt::format("Eden | {}", description);
yuzu_title = fmt::format("Eden | {} | {}", description, compiler);
}
const auto override_title =
@ -5674,13 +5677,13 @@ void VolumeButton::wheelEvent(QWheelEvent* event) {
if (num_steps > 0) {
Settings::values.volume.SetValue(
std::min(200, Settings::values.volume.GetValue() + num_steps));
(std::min)(200, Settings::values.volume.GetValue() + num_steps));
} else {
Settings::values.volume.SetValue(
std::max(0, Settings::values.volume.GetValue() + num_steps));
(std::max)(0, Settings::values.volume.GetValue() + num_steps));
}
scroll_multiplier = std::min(MaxMultiplier, scroll_multiplier * 2);
scroll_multiplier = (std::min)(MaxMultiplier, scroll_multiplier * 2);
scroll_timer.start(100); // reset the multiplier if no scroll event occurs within 100 ms
emit VolumeChanged();
@ -5721,11 +5724,11 @@ static void SetHighDPIAttributes() {
constexpr float minimum_width = 1350.0f;
constexpr float minimum_height = 900.0f;
const float width_ratio = std::max(1.0f, real_width / minimum_width);
const float height_ratio = std::max(1.0f, real_height / minimum_height);
const float width_ratio = (std::max)(1.0f, real_width / minimum_width);
const float height_ratio = (std::max)(1.0f, real_height / minimum_height);
// Get the lower of the 2 ratios and truncate, this is the maximum integer scale.
const float max_ratio = std::trunc(std::min(width_ratio, height_ratio));
const float max_ratio = std::trunc((std::min)(width_ratio, height_ratio));
if (max_ratio > real_ratio) {
QApplication::setHighDpiScaleFactorRoundingPolicy(

View file

@ -168,7 +168,7 @@ QString ReadablePlayTime(qulonglong time_seconds) {
if (time_seconds == 0) {
return {};
}
const auto time_minutes = std::max(static_cast<double>(time_seconds) / 60, 1.0);
const auto time_minutes = (std::max)(static_cast<double>(time_seconds) / 60, 1.0);
const auto time_hours = static_cast<double>(time_seconds) / 3600;
const bool is_minutes = time_minutes < 60;
const char* unit = is_minutes ? "m" : "h";

View file

@ -30,7 +30,7 @@ QString ReadableByteSize(qulonglong size) {
return QStringLiteral("0");
}
const int digit_groups = std::min(static_cast<int>(std::log10(size) / std::log10(1024)),
const int digit_groups = (std::min)(static_cast<int>(std::log10(size) / std::log10(1024)),
static_cast<int>(units.size()));
return QStringLiteral("%L1 %2")
.arg(size / std::pow(1024, digit_groups), 0, 'f', 1)