From 8915fa92631331a3ab29456525876c39b29ded3b Mon Sep 17 00:00:00 2001 From: Alexander Babikov Date: Sat, 26 Jul 2025 03:09:05 +0500 Subject: [PATCH 1/3] CMake: Only find and link to SDL when needed --- src/CMakeLists.txt | 10 ---------- src/qt/CMakeLists.txt | 9 +++++++++ src/unix/CMakeLists.txt | 10 ++++++++++ 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 27db529f5..c77af8256 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -149,16 +149,6 @@ if(APPLE) target_link_libraries(86Box Freetype::Freetype) endif() -find_package(SDL2 REQUIRED) -include_directories(${SDL2_INCLUDE_DIRS}) -if(STATIC_BUILD AND TARGET SDL2::SDL2-static) - target_link_libraries(86Box SDL2::SDL2-static) -elseif(TARGET SDL2::SDL2) - target_link_libraries(86Box SDL2::SDL2) -else() - target_link_libraries(86Box ${SDL2_LIBRARIES}) -endif() - find_package(PNG REQUIRED) include_directories(${PNG_INCLUDE_DIRS}) target_link_libraries(86Box PNG::PNG) diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt index c71273af8..3fb2471a5 100644 --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -284,6 +284,15 @@ if(WIN32 AND NOT SDL_JOYSTICK) target_sources(plat PRIVATE win_joystick_rawinput.c) target_link_libraries(86Box hid) else() + find_package(SDL2 REQUIRED) + include_directories(${SDL2_INCLUDE_DIRS}) + if(STATIC_BUILD AND TARGET SDL2::SDL2-static) + target_link_libraries(86Box SDL2::SDL2-static) + elseif(TARGET SDL2::SDL2) + target_link_libraries(86Box SDL2::SDL2) + else() + target_link_libraries(86Box ${SDL2_LIBRARIES}) + endif() target_sources(plat PRIVATE sdl_joystick.c) endif() diff --git a/src/unix/CMakeLists.txt b/src/unix/CMakeLists.txt index 91fa25f39..724ab041f 100644 --- a/src/unix/CMakeLists.txt +++ b/src/unix/CMakeLists.txt @@ -32,6 +32,16 @@ set(THREADS_PREFER_PTHREAD_FLAG TRUE) find_package(Threads REQUIRED) target_link_libraries(86Box Threads::Threads) +find_package(SDL2 REQUIRED) +include_directories(${SDL2_INCLUDE_DIRS}) +if(STATIC_BUILD AND TARGET SDL2::SDL2-static) + target_link_libraries(86Box SDL2::SDL2-static) +elseif(TARGET SDL2::SDL2) + target_link_libraries(86Box SDL2::SDL2) +else() + target_link_libraries(86Box ${SDL2_LIBRARIES}) +endif() + add_library(ui OBJECT unix_sdl.c unix_cdrom.c From 37481032ed38afeea58a435dab689638d6142244 Mon Sep 17 00:00:00 2001 From: Alexander Babikov Date: Wed, 30 Jul 2025 23:50:48 +0500 Subject: [PATCH 2/3] Manager/CMake: More thoroughly disable the update checker when no build number is present --- src/qt/CMakeLists.txt | 21 +++++++++++++-------- src/qt/qt_vmmanager_main.hpp | 5 +++-- src/qt/qt_vmmanager_mainwindow.cpp | 10 +++++++--- src/qt/qt_vmmanager_mainwindow.hpp | 2 ++ 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt index 3fb2471a5..aee0e2864 100644 --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -187,14 +187,6 @@ add_library(ui STATIC qt_mediahistorymanager.cpp qt_mediahistorymanager.hpp - qt_updatecheck.cpp - qt_updatecheck.hpp - qt_updatecheckdialog.cpp - qt_updatecheckdialog.hpp - qt_updatecheckdialog.ui - qt_updatedetails.cpp - qt_updatedetails.hpp - qt_updatedetails.ui qt_downloader.cpp qt_downloader.hpp @@ -245,6 +237,19 @@ add_library(ui STATIC qt_iconindicators.cpp ) +if(EMU_BUILD_NUM) + target_sources(ui PRIVATE + qt_updatecheck.cpp + qt_updatecheck.hpp + qt_updatecheckdialog.cpp + qt_updatecheckdialog.hpp + qt_updatecheckdialog.ui + qt_updatedetails.cpp + qt_updatedetails.hpp + qt_updatedetails.ui + ) +endif() + if(RTMIDI) target_compile_definitions(ui PRIVATE USE_RTMIDI) endif() diff --git a/src/qt/qt_vmmanager_main.hpp b/src/qt/qt_vmmanager_main.hpp index fecee2009..075af76f1 100644 --- a/src/qt/qt_vmmanager_main.hpp +++ b/src/qt/qt_vmmanager_main.hpp @@ -18,8 +18,6 @@ #ifndef QT_VMMANAGER_MAIN_H #define QT_VMMANAGER_MAIN_H -#include "qt_updatecheck.hpp" - #include #include "qt_vmmanager_model.hpp" #include "qt_vmmanager_details.hpp" @@ -31,6 +29,9 @@ extern "C" { #include <86box/86box.h> // for vmm_path } +#if EMU_BUILD_NUM != 0 +# include "qt_updatecheck.hpp" +#endif QT_BEGIN_NAMESPACE namespace Ui { class VMManagerMain; } diff --git a/src/qt/qt_vmmanager_mainwindow.cpp b/src/qt/qt_vmmanager_mainwindow.cpp index d3533482b..a349740e7 100644 --- a/src/qt/qt_vmmanager_mainwindow.cpp +++ b/src/qt/qt_vmmanager_mainwindow.cpp @@ -19,7 +19,9 @@ #include "qt_vmmanager_main.hpp" #include "qt_vmmanager_preferences.hpp" #include "ui_qt_vmmanager_mainwindow.h" -#include "qt_updatecheckdialog.hpp" +#if EMU_BUILD_NUM != 0 +# include "qt_updatecheckdialog.hpp" +#endif #include #include @@ -171,16 +173,18 @@ VMManagerMainWindow::setStatusRight(const QString &text) const statusRight->setText(text); } +#if EMU_BUILD_NUM != 0 void VMManagerMainWindow::checkForUpdatesTriggered() { auto updateChannel = UpdateCheck::UpdateChannel::CI; -#ifdef RELEASE_BUILD +# ifdef RELEASE_BUILD updateChannel = UpdateCheck::UpdateChannel::Stable; -#endif +# endif const auto updateCheck = new UpdateCheckDialog(updateChannel); updateCheck->exec(); } +#endif void VMManagerMainWindow::on_actionExit_triggered() { diff --git a/src/qt/qt_vmmanager_mainwindow.hpp b/src/qt/qt_vmmanager_mainwindow.hpp index 12ac5afb1..7a38750c4 100644 --- a/src/qt/qt_vmmanager_mainwindow.hpp +++ b/src/qt/qt_vmmanager_mainwindow.hpp @@ -50,7 +50,9 @@ public slots: private slots: void vmmSelectionChanged(const QModelIndex ¤tSelection, QProcess::ProcessState processState) const; void preferencesTriggered(); +#if EMU_BUILD_NUM != 0 static void checkForUpdatesTriggered(); +#endif void on_actionExit_triggered(); From c76a6820696f94d49dca171334745de12cb6666e Mon Sep 17 00:00:00 2001 From: Alexander Babikov Date: Thu, 31 Jul 2025 01:57:36 +0500 Subject: [PATCH 3/3] CMake: Error out if source directory if `src/` instead of top-level dir --- CMakeLists.txt | 4 +++- src/CMakeLists.txt | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4dd83523f..5cffe031f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -221,7 +221,7 @@ if(NOT EMU_BUILD_NUM) set(EMU_BUILD_NUM 0) endif() if(NOT EMU_COPYRIGHT_YEAR) - set(EMU_COPYRIGHT_YEAR 2024) + set(EMU_COPYRIGHT_YEAR 2025) endif() # Libasan @@ -230,4 +230,6 @@ if(LIBASAN) add_link_options(-fsanitize=address) endif() +set(CMAKE_TOP_LEVEL_PROCESSED TRUE) + add_subdirectory(src) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c77af8256..724e1fda6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -16,6 +16,10 @@ # Copyright 2024 Jasmine Iwanek. # +if(NOT CMAKE_TOP_LEVEL_PROCESSED) + message(FATAL_ERROR "Incorrect source directory specified. Delete your build directory and retry with the top-level directory instead") +endif() + if(APPLE) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) endif()