diff options
| author | crueter <crueter@eden-emu.dev> | 2026-01-14 19:29:13 +0100 |
|---|---|---|
| committer | crueter <crueter@eden-emu.dev> | 2026-01-14 19:29:13 +0100 |
| commit | 89f72d286a85504ccf997bb8124e32d1f76d6c81 (patch) | |
| tree | e71d20665bb7dd75c855d5caa2ee304d970f3215 /externals/cmake-modules | |
| parent | ecd01e13fd13b39bff0f2c7c7bc2387c3a2157f4 (diff) | |
[cmake, tools] update CPMUtil and add support for CPMUtil bundled Qt, module updates, cleanups (#3289)
Support for bundled Qt, not through aqtinstall but rather my CI. Multimedia is
implemented too, works on both Windows and Linux, though we don't
actually use it so it doesn't really matter. Contains Declarative and all that so the Quick frontend will work once it becomes a thing.
Some options have changed, notably w.r.t LTO and faster
linker, which are now handled directly in the modules.
CPMUtil also has support for custom dirs (`PackageName_CUSTOM_DIR`) now. Probably most useful for adding external fragment shaders and whatnot.
Signed-off-by: crueter <crueter@eden-emu.dev>
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3289
Diffstat (limited to 'externals/cmake-modules')
| -rw-r--r-- | externals/cmake-modules/DefaultConfig.cmake | 2 | ||||
| -rw-r--r-- | externals/cmake-modules/DetectArchitecture.cmake | 256 | ||||
| -rw-r--r-- | externals/cmake-modules/DetectPlatform.cmake | 5 | ||||
| -rw-r--r-- | externals/cmake-modules/FasterLinker.cmake | 72 | ||||
| -rw-r--r-- | externals/cmake-modules/GetSCMRev.cmake | 4 | ||||
| -rw-r--r-- | externals/cmake-modules/UseCcache.cmake | 2 | ||||
| -rw-r--r-- | externals/cmake-modules/UseLTO.cmake | 24 |
7 files changed, 183 insertions, 182 deletions
diff --git a/externals/cmake-modules/DefaultConfig.cmake b/externals/cmake-modules/DefaultConfig.cmake index eb5bb3cdef..81e93f6c2e 100644 --- a/externals/cmake-modules/DefaultConfig.cmake +++ b/externals/cmake-modules/DefaultConfig.cmake @@ -1,5 +1,5 @@ # SPDX-FileCopyrightText: Copyright 2025 crueter -# SPDX-License-Identifier: GPL-3.0-or-later +# SPDX-License-Identifier: LGPL-3.0-or-later ## DefaultConfig ## diff --git a/externals/cmake-modules/DetectArchitecture.cmake b/externals/cmake-modules/DetectArchitecture.cmake index 82dce31878..105963c8c2 100644 --- a/externals/cmake-modules/DetectArchitecture.cmake +++ b/externals/cmake-modules/DetectArchitecture.cmake @@ -1,5 +1,5 @@ # SPDX-FileCopyrightText: Copyright 2025 crueter -# SPDX-License-Identifier: GPL-3.0-or-later +# SPDX-License-Identifier: LGPL-3.0-or-later ## DetectArchitecture ## #[[ @@ -93,133 +93,129 @@ function(detect_architecture_symbols) endforeach() endfunction() -function(DetectArchitecture) - # arches here are put in a sane default order of importance - # notably, amd64, arm64, and riscv (in order) are BY FAR the most common - # mips is pretty popular in embedded - # ppc64 is pretty popular in supercomputing - # sparc is uh - # ia64 exists - # the rest exist, but are probably less popular than ia64 - - detect_architecture_symbols( - ARCH arm64 - SYMBOLS - "__ARM64__" - "__aarch64__" - "_M_ARM64") - - detect_architecture_symbols( - ARCH x86_64 - SYMBOLS - "__x86_64" - "__x86_64__" - "__amd64" - "_M_X64" - "_M_AMD64") - - # riscv is interesting since it generally does not define a riscv64-specific symbol - # We can, however, check for the rv32 zcf extension which is good enough of a heuristic on GCC - detect_architecture_symbols( - ARCH riscv - SYMBOLS - "__riscv_zcf") - - # if zcf doesn't exist we can safely assume it's riscv64 - detect_architecture_symbols( - ARCH riscv64 - SYMBOLS - "__riscv") - - detect_architecture_symbols( - ARCH x86 - SYMBOLS - "__i386" - "__i386__" - "_M_IX86") - - detect_architecture_symbols( - ARCH arm - SYMBOLS - "__arm__" - "__TARGET_ARCH_ARM" - "_M_ARM") - - detect_architecture_symbols( - ARCH ia64 - SYMBOLS - "__ia64" - "__ia64__" - "_M_IA64") - - # mips is probably the least fun to detect due to microMIPS - # Because microMIPS is such cancer I'm considering it out of scope for now - detect_architecture_symbols( - ARCH mips64 - SYMBOLS - "__mips64") - - detect_architecture_symbols( - ARCH mips - SYMBOLS - "__mips" - "__mips__" - "_M_MRX000") - - detect_architecture_symbols( - ARCH ppc64 - SYMBOLS - "__ppc64__" - "__powerpc64__" - "_ARCH_PPC64" - "_M_PPC64") - - detect_architecture_symbols( - ARCH ppc - SYMBOLS - "__ppc__" - "__ppc" - "__powerpc__" - "_ARCH_COM" - "_ARCH_PWR" - "_ARCH_PPC" - "_M_MPPC" - "_M_PPC") - - detect_architecture_symbols( - ARCH sparc64 - SYMBOLS - "__sparc_v9__") - - detect_architecture_symbols( - ARCH sparc - SYMBOLS - "__sparc__" - "__sparc") - - # I don't actually know about loongarch32 since crossdev does not support it, only 64 - detect_architecture_symbols( - ARCH loongarch64 - SYMBOLS - "__loongarch__" - "__loongarch64") - - detect_architecture_symbols( - ARCH wasm - SYMBOLS - "__EMSCRIPTEN__") - - # "generic" target - # If you have reached this point, you're on some as-of-yet unsupported architecture. - # See the docs up above for known unsupported architectures - # If you're not in the list... I think you know what you're doing. - if (NOT DEFINED ARCHITECTURE) - set(ARCHITECTURE "GENERIC") - set(ARCHITECTURE_GENERIC 1) - add_definitions(-DARCHITECTURE_GENERIC=1) - endif() +# arches here are put in a sane default order of importance +# notably, amd64, arm64, and riscv (in order) are BY FAR the most common +# mips is pretty popular in embedded +# ppc64 is pretty popular in supercomputing +# sparc is uh +# ia64 exists +# the rest exist, but are probably less popular than ia64 + +detect_architecture_symbols( + ARCH arm64 + SYMBOLS + "__ARM64__" + "__aarch64__" + "_M_ARM64") + +detect_architecture_symbols( + ARCH x86_64 + SYMBOLS + "__x86_64" + "__x86_64__" + "__amd64" + "_M_X64" + "_M_AMD64") + +# riscv is interesting since it generally does not define a riscv64-specific symbol +# We can, however, check for the rv32 zcf extension which is good enough of a heuristic on GCC +detect_architecture_symbols( + ARCH riscv + SYMBOLS + "__riscv_zcf") + +# if zcf doesn't exist we can safely assume it's riscv64 +detect_architecture_symbols( + ARCH riscv64 + SYMBOLS + "__riscv") + +detect_architecture_symbols( + ARCH x86 + SYMBOLS + "__i386" + "__i386__" + "_M_IX86") + +detect_architecture_symbols( + ARCH arm + SYMBOLS + "__arm__" + "__TARGET_ARCH_ARM" + "_M_ARM") + +detect_architecture_symbols( + ARCH ia64 + SYMBOLS + "__ia64" + "__ia64__" + "_M_IA64") + +# mips is probably the least fun to detect due to microMIPS +# Because microMIPS is such cancer I'm considering it out of scope for now +detect_architecture_symbols( + ARCH mips64 + SYMBOLS + "__mips64") + +detect_architecture_symbols( + ARCH mips + SYMBOLS + "__mips" + "__mips__" + "_M_MRX000") + +detect_architecture_symbols( + ARCH ppc64 + SYMBOLS + "__ppc64__" + "__powerpc64__" + "_ARCH_PPC64" + "_M_PPC64") + +detect_architecture_symbols( + ARCH ppc + SYMBOLS + "__ppc__" + "__ppc" + "__powerpc__" + "_ARCH_COM" + "_ARCH_PWR" + "_ARCH_PPC" + "_M_MPPC" + "_M_PPC") + +detect_architecture_symbols( + ARCH sparc64 + SYMBOLS + "__sparc_v9__") + +detect_architecture_symbols( + ARCH sparc + SYMBOLS + "__sparc__" + "__sparc") + +# I don't actually know about loongarch32 since crossdev does not support it, only 64 +detect_architecture_symbols( + ARCH loongarch64 + SYMBOLS + "__loongarch__" + "__loongarch64") + +detect_architecture_symbols( + ARCH wasm + SYMBOLS + "__EMSCRIPTEN__") + +# "generic" target +# If you have reached this point, you're on some as-of-yet unsupported architecture. +# See the docs up above for known unsupported architectures +# If you're not in the list... I think you know what you're doing. +if (NOT DEFINED ARCHITECTURE) + set(ARCHITECTURE "GENERIC") + set(ARCHITECTURE_GENERIC 1) + add_definitions(-DARCHITECTURE_GENERIC=1) +endif() - message(STATUS "[DetectArchitecture] Target architecture: ${ARCHITECTURE}") - set(ARCHITECTURE "${ARCHITECTURE}" PARENT_SCOPE) - set(ARCHITECTURE_${ARCHITECTURE} 1 PARENT_SCOPE) -endfunction() +message(STATUS "[DetectArchitecture] Target architecture: ${ARCHITECTURE}")
\ No newline at end of file diff --git a/externals/cmake-modules/DetectPlatform.cmake b/externals/cmake-modules/DetectPlatform.cmake index 25b324a674..0ad695066b 100644 --- a/externals/cmake-modules/DetectPlatform.cmake +++ b/externals/cmake-modules/DetectPlatform.cmake @@ -1,5 +1,5 @@ # SPDX-FileCopyrightText: Copyright 2025 crueter -# SPDX-License-Identifier: GPL-3.0-or-later +# SPDX-License-Identifier: LGPL-3.0-or-later ## DetectPlatform ## @@ -147,5 +147,6 @@ endif() # awesome if (PLATFORM_FREEBSD OR PLATFORM_DRAGONFLYBSD) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${CMAKE_SYSROOT}/usr/local/lib") + set(CMAKE_EXE_LINKER_FLAGS + "${CMAKE_EXE_LINKER_FLAGS} -L${CMAKE_SYSROOT}/usr/local/lib") endif()
\ No newline at end of file diff --git a/externals/cmake-modules/FasterLinker.cmake b/externals/cmake-modules/FasterLinker.cmake index 6b472a4f0f..37d8bca33b 100644 --- a/externals/cmake-modules/FasterLinker.cmake +++ b/externals/cmake-modules/FasterLinker.cmake @@ -1,5 +1,5 @@ # SPDX-FileCopyrightText: Copyright 2025 crueter -# SPDX-License-Identifier: GPL-3.0-or-later +# SPDX-License-Identifier: LGPL-3.0-or-later ## FasterLinker ## @@ -12,47 +12,45 @@ - mold (GCC only) - generally does well on GCC - lld - preferred on clang - bfd - the final fallback - - If none are found (macOS uses ld.prime, etc) just use the default linker + - If none are found just use the default linker ]] # This module is based on the work of Yuzu, specifically Liam White, # and later extended by crueter. -if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - set(CXX_GCC ON) -endif() - -find_program(LINKER_BFD bfd) -if (LINKER_BFD) - set(LINKER bfd) -endif() - -find_program(LINKER_LLD lld) -if (LINKER_LLD) - set(LINKER lld) -endif() - -if (CXX_GCC) - find_program(LINKER_MOLD mold) - if (LINKER_MOLD AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "12.1") - set(LINKER mold) +option(USE_FASTER_LINKER "Attempt to use a faster linker program" OFF) + +if (USE_FASTER_LINKER) + macro(find_linker ld) + find_program(LINKER_${ld} ld.${ld}) + if (LINKER_${ld}) + set(LINKER ${ld}) + endif() + endmacro() + + find_linker(bfd) + find_linker(lld) + + if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + find_program(LINKER_MOLD mold) + if (LINKER_MOLD AND + CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "12.1") + set(LINKER mold) + endif() + + find_linker(gold) + + if (LINKER STREQUAL "lld") + message(WARNING + "[FasterLinker] Using lld on GCC may cause issues.\ + Install mold, gold, or disable USE_FASTER_LINKER.") + endif() endif() - find_program(LINKER_GOLD gold) - if (LINKER_GOLD) - set(LINKER gold) + if (LINKER) + message(NOTICE "[FasterLinker] Selecting ${LINKER} as linker") + add_link_options("-fuse-ld=${LINKER}") + else() + message(WARNING "[FasterLinker] No faster linker found--using default") endif() -endif() - -if (LINKER) - message(NOTICE "[FasterLinker] Selecting ${LINKER} as linker") - add_link_options("-fuse-ld=${LINKER}") -else() - message(WARNING "[FasterLinker] No faster linker found--using default") -endif() - -if (LINKER STREQUAL "lld" AND CXX_GCC) - message(WARNING - "[FasterLinker] Using lld on GCC may cause issues " - "with certain LTO settings.") -endif() +endif()
\ No newline at end of file diff --git a/externals/cmake-modules/GetSCMRev.cmake b/externals/cmake-modules/GetSCMRev.cmake index 4b144584e8..74c32097da 100644 --- a/externals/cmake-modules/GetSCMRev.cmake +++ b/externals/cmake-modules/GetSCMRev.cmake @@ -1,5 +1,5 @@ # SPDX-FileCopyrightText: Copyright 2025 crueter -# SPDX-License-Identifier: GPL-3.0-or-later +# SPDX-License-Identifier: LGPL-3.0-or-later ## GetSCMRev ## # Name is self explanatory. Gets revision information from files, OR from git. @@ -13,6 +13,8 @@ find_package(Git QUIET) # tag: git describe --tags --abbrev=0 # branch: git rev-parse --abbrev-ref=HEAD +# TODO: string overrides + function(run_git_command variable) if(NOT GIT_FOUND) set(${variable} "GIT-NOTFOUND" PARENT_SCOPE) diff --git a/externals/cmake-modules/UseCcache.cmake b/externals/cmake-modules/UseCcache.cmake index 8caea18fe0..34a9de3cf2 100644 --- a/externals/cmake-modules/UseCcache.cmake +++ b/externals/cmake-modules/UseCcache.cmake @@ -1,5 +1,5 @@ # SPDX-FileCopyrightText: Copyright 2025 crueter -# SPDX-License-Identifier: GPL-3.0-or-later +# SPDX-License-Identifier: LGPL-3.0-or-later ## UseCcache ## diff --git a/externals/cmake-modules/UseLTO.cmake b/externals/cmake-modules/UseLTO.cmake index d1603aba1c..b364ef22d8 100644 --- a/externals/cmake-modules/UseLTO.cmake +++ b/externals/cmake-modules/UseLTO.cmake @@ -1,17 +1,21 @@ # SPDX-FileCopyrightText: Copyright 2025 crueter -# SPDX-License-Identifier: GPL-3.0-or-later +# SPDX-License-Identifier: LGPL-3.0-or-later ## UseLTO ## # Enable Interprocedural Optimization (IPO). # Self-explanatory. -include(CheckIPOSupported) -check_ipo_supported(RESULT COMPILER_SUPPORTS_LTO) -if(NOT COMPILER_SUPPORTS_LTO) - message(FATAL_ERROR - "Your compiler does not support interprocedural optimization" - " (IPO).") -endif() -set(CMAKE_POLICY_DEFAULT_CMP0069 NEW) -set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ${COMPILER_SUPPORTS_LTO}) +option(ENABLE_LTO "Enable Link-Time Optimization (LTO)" OFF) + +if (ENABLE_LTO) + include(CheckIPOSupported) + check_ipo_supported(RESULT COMPILER_SUPPORTS_LTO) + if(NOT COMPILER_SUPPORTS_LTO) + message(FATAL_ERROR + "Your compiler does not support interprocedural optimization" + " (IPO). Disable ENABLE_LTO and try again.") + endif() + set(CMAKE_POLICY_DEFAULT_CMP0069 NEW) + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ${COMPILER_SUPPORTS_LTO}) +endif()
\ No newline at end of file |
