aboutsummaryrefslogtreecommitdiff
path: root/externals
diff options
context:
space:
mode:
authorcrueter <crueter@eden-emu.dev>2026-08-10 04:57:38 +0200
committercrueter <crueter@eden-emu.dev>2026-08-10 04:57:38 +0200
commit8648c27cbb4c17b176076b09ac245271829cbd9f (patch)
treef3607735dbd240e9fedf6d10d1b910de81d7bcda /externals
parentdef76946f06dca0faecef4d33f308e2ed357f501 (diff)
[cmake] Simplify DetectPlatform and normalize platform names (#4183)
Since 3.25 introduced `LINUX` and `BSD`, use them, and standardize other platforms to that style Signed-off-by: crueter <crueter@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4183 Reviewed-by: Samuel <lizzie@eden-emu.dev> Reviewed-by: CamilleLaVey <camillelavey99@gmail.com>
Diffstat (limited to 'externals')
-rw-r--r--externals/CMakeLists.txt2
-rw-r--r--externals/cmake-modules/DetectPlatform.cmake103
-rw-r--r--externals/ffmpeg/CMakeLists.txt10
-rw-r--r--externals/libusb/CMakeLists.txt2
4 files changed, 30 insertions, 87 deletions
diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt
index aafa518ed2..f190f68b9d 100644
--- a/externals/CMakeLists.txt
+++ b/externals/CMakeLists.txt
@@ -164,7 +164,7 @@ if (NOT ANDROID)
AddJsonPackage(sdl3)
else()
message(STATUS "Using bundled SDL3")
- if (PLATFORM_FREEBSD)
+ if (FREEBSD)
set(BUILD_SHARED_LIBS ON)
endif()
AddJsonPackage(sdl3-ci)
diff --git a/externals/cmake-modules/DetectPlatform.cmake b/externals/cmake-modules/DetectPlatform.cmake
index de1a85b793..0f7cdfcf46 100644
--- a/externals/cmake-modules/DetectPlatform.cmake
+++ b/externals/cmake-modules/DetectPlatform.cmake
@@ -1,45 +1,46 @@
-# SPDX-FileCopyrightText: Copyright 2025 crueter
+# SPDX-FileCopyrightText: Copyright 2026 crueter
# SPDX-License-Identifier: LGPL-3.0-or-later
## DetectPlatform ##
-# This is a small helper that sets PLATFORM_<platform> variables for various
+# This is a small helper that sets platform variables for various
# operating systems and distributions. Note that Apple, Windows, Android, etc.
# are not covered, as CMake already does that for us.
# It also sets CXX_<compiler> for the C++ compiler.
-# Furthermore, some platforms have really silly requirements/quirks, so this
-# also does a few of those.
-
# This module contains contributions from the Eden Emulator Project,
# notably from crueter and Lizzie.
if (${CMAKE_SYSTEM_NAME} STREQUAL "SunOS")
- set(PLATFORM_SUN ON)
+ set(SOLARIS ON)
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "OpenOrbis")
- set(PLATFORM_PS4 ON)
+ set(OPENORBIS ON)
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "managarm")
- set(PLATFORM_MANAGARM ON)
-elseif (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
- set(PLATFORM_FREEBSD ON)
-elseif (${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD")
- set(PLATFORM_OPENBSD ON)
-elseif (${CMAKE_SYSTEM_NAME} STREQUAL "NetBSD")
- set(PLATFORM_NETBSD ON)
-elseif (${CMAKE_SYSTEM_NAME} STREQUAL "DragonFly")
- set(PLATFORM_DRAGONFLYBSD ON)
+ set(MANAGARM ON)
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Haiku")
- set(PLATFORM_HAIKU ON)
-elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
- set(PLATFORM_LINUX ON)
+ set(HAIKUOS ON)
+endif()
+
+# BSD
+if (DEFINED BSD)
+ if ("${BSD}" STREQUAL "DragonFlyBSD")
+ set(DRAGONFLYBSD ON)
+ elseif ("${BSD}" STREQUAL "FreeBSD")
+ set(FREEBSD ON)
+ elseif ("${BSD}" STREQUAL "OpenBSD")
+ set(OPENBSD ON)
+ elseif ("${BSD}" STREQUAL "NetBSD")
+ set(NETBSD ON)
+ endif()
endif()
# dumb heuristic to detect msys2
if (CMAKE_COMMAND MATCHES "msys64")
- set(PLATFORM_MSYS ON)
+ set(MSYS2 ON)
endif()
+# compiler checks
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CXX_CLANG ON)
if (MSVC)
@@ -47,8 +48,6 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
endif()
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CXX_GCC ON)
-elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
- set(CXX_CL ON)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
set(CXX_ICC ON)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
@@ -61,37 +60,13 @@ if(MINGW AND CXX_CLANG)
set(CMAKE_SYSTEM_VERSION 10.0.0)
endif()
-# NB: this does not account for SPARC
-if (PLATFORM_SUN)
- # Terrific OpenIndiana pkg shenanigans
- list(APPEND CMAKE_PREFIX_PATH
- "${CMAKE_SYSROOT}/usr/lib/qt/6.6/lib/amd64/cmake")
- list(APPEND CMAKE_MODULE_PATH
- "${CMAKE_SYSROOT}/usr/lib/qt/6.6/lib/amd64/cmake")
-
- # Amazing - absolutely incredible
- list(APPEND CMAKE_PREFIX_PATH "${CMAKE_SYSROOT}/usr/lib/amd64/cmake")
- list(APPEND CMAKE_MODULE_PATH "${CMAKE_SYSROOT}/usr/lib/amd64/cmake")
-
- # For some mighty reason, doing a normal release build sometimes
- # may not trigger the proper -O3 switch to materialize
- if (CMAKE_BUILD_TYPE MATCHES "Release")
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
- endif()
- if (CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo")
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
- endif()
-endif()
-
# MSYS2 utilities
# Sometimes, PkgConfig modules will incorrectly reference / when CMake
# wants you to reference it as C:/msys64/. This function corrects that.
# Example in a Find module:
#[[
- if (PLATFORM_MSYS)
+ if (MSYS2)
FixMsysPath(PkgConfig::OPUS)
endif()
]]
@@ -116,41 +91,9 @@ function(FixMsysPath target)
INTERFACE_INCLUDE_DIRECTORIES ${include_dir})
endfunction()
-# MSYSTEM handling + program_path
-if (PLATFORM_MSYS)
- # really, really dumb heuristic to detect what environment we are in
- macro(system var)
- if (CMAKE_COMMAND MATCHES ${var})
- set(MSYSTEM ${var})
- endif()
- endmacro()
-
- system(mingw64)
- system(clang64)
- system(clangarm64)
- system(ucrt64)
-
- if (NOT DEFINED MSYSTEM)
- set(MSYSTEM msys2)
- endif()
-
- # We generally want to prioritize environment-specific binaries if possible
- # some, like autoconf, are not present on environments besides msys2 though
- set(CMAKE_PROGRAM_PATH C:/msys64/${MSYSTEM}/bin C:/msys64/usr/bin)
- set(ENV{PKG_CONFIG_PATH} C:/msys64/${MSYSTEM}/lib/pkgconfig)
-endif()
-
-# This saves a truly ridiculous amount of time during linking
-# In my tests, without this, Eden takes 2 mins, with this, it takes 3-5 seconds
-# or on GitHub Actions, 10 minutes -> 3 seconds
+# Saves linking time
if (MINGW)
set(MINGW_FLAGS "-Wl,--strip-all -Wl,--gc-sections")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE
"${CMAKE_EXE_LINKER_FLAGS_RELEASE} ${MINGW_FLAGS}")
endif()
-
-# awesome
-if (PLATFORM_FREEBSD OR PLATFORM_DRAGONFLYBSD)
- set(CMAKE_EXE_LINKER_FLAGS
- "${CMAKE_EXE_LINKER_FLAGS} -L${CMAKE_SYSROOT}/usr/local/lib")
-endif()
diff --git a/externals/ffmpeg/CMakeLists.txt b/externals/ffmpeg/CMakeLists.txt
index 0baff02c84..6e3f675f2b 100644
--- a/externals/ffmpeg/CMakeLists.txt
+++ b/externals/ffmpeg/CMakeLists.txt
@@ -56,7 +56,7 @@ if (NOT YUZU_USE_BUNDLED_FFMPEG)
endif()
endif()
-if (PLATFORM_PS4 OR PLATFORM_MANAGARM)
+if (OPENORBIS OR MANAGARM)
# Doesn't support VA-API, don't go thru the embarrassment of trying to enable it
list(APPEND FFmpeg_HWACCEL_FLAGS --disable-vaapi)
elseif (ANDROID)
@@ -75,7 +75,7 @@ elseif (UNIX AND NOT DEFINED FFmpeg_IS_CROSS_COMPILING AND NOT ANDROID)
if(X11_FOUND)
if (NOT APPLE)
# In Solaris needs explicit linking for ffmpeg which links to /lib/amd64/libX11.so
- if(PLATFORM_SUN)
+ if(SOLARIS)
list(APPEND FFmpeg_HWACCEL_LIBRARIES
X11
"${CMAKE_SYSROOT}/usr/lib/xorg/amd64/libdrm.so")
@@ -158,7 +158,7 @@ elseif (UNIX AND NOT DEFINED FFmpeg_IS_CROSS_COMPILING AND NOT ANDROID)
endif()
endif()
-if (PLATFORM_PS4)
+if (OPENORBIS)
list(APPEND FFmpeg_CROSS_COMPILE_LIBS
-lkernel
-lSceUserService
@@ -172,7 +172,7 @@ if (PLATFORM_PS4)
--extra-cxxflags=${CMAKE_SYSROOT}/usr/include
--extra-libs="${FFmpeg_CROSS_COMPILE_LIBS}"
)
-elseif (PLATFORM_MANAGARM)
+elseif (MANAGARM)
# Required for proper stuff
list(APPEND FFmpeg_CROSS_COMPILE_FLAGS
--disable-pthreads
@@ -299,7 +299,7 @@ else()
set(FFmpeg_BUILD_LIBRARIES ${FFmpeg_LIBRARIES})
# BSD make or Solaris make don't support ffmpeg make-j8
- if (PLATFORM_LINUX OR ANDROID OR APPLE OR WIN32 OR PLATFORM_FREEBSD)
+ if (LINUX OR ANDROID OR APPLE OR WIN32 OR FREEBSD)
set(FFmpeg_MAKE_ARGS -j${SYSTEM_THREADS})
else()
set(FFmpeg_MAKE_ARGS "")
diff --git a/externals/libusb/CMakeLists.txt b/externals/libusb/CMakeLists.txt
index 47b54f43cc..f33b5d1646 100644
--- a/externals/libusb/CMakeLists.txt
+++ b/externals/libusb/CMakeLists.txt
@@ -11,7 +11,7 @@ if (NOT libusb_ADDED)
endif()
# TODO: *BSD fails to compile--may need different configs/symbols
-if (MINGW OR PLATFORM_LINUX OR APPLE)
+if (MINGW OR LINUX OR APPLE)
set(LIBUSB_FOUND ON CACHE BOOL "libusb is present" FORCE)
set(LIBUSB_VERSION "1.0.24" CACHE STRING "libusb version string" FORCE)