mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-04-10 03:18:55 +02:00
[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
This commit is contained in:
parent
ecd01e13fd
commit
89f72d286a
48 changed files with 618 additions and 929 deletions
2
externals/cmake-modules/DefaultConfig.cmake
vendored
2
externals/cmake-modules/DefaultConfig.cmake
vendored
|
|
@ -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 ##
|
||||
|
||||
|
|
|
|||
224
externals/cmake-modules/DetectArchitecture.cmake
vendored
224
externals/cmake-modules/DetectArchitecture.cmake
vendored
|
|
@ -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
|
||||
# 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 arm64
|
||||
SYMBOLS
|
||||
"__ARM64__"
|
||||
"__aarch64__"
|
||||
"_M_ARM64")
|
||||
|
||||
detect_architecture_symbols(
|
||||
ARCH x86_64
|
||||
SYMBOLS
|
||||
"__x86_64"
|
||||
"__x86_64__"
|
||||
"__amd64"
|
||||
"_M_X64"
|
||||
"_M_AMD64")
|
||||
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")
|
||||
# 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")
|
||||
# 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 x86
|
||||
SYMBOLS
|
||||
"__i386"
|
||||
"__i386__"
|
||||
"_M_IX86")
|
||||
|
||||
detect_architecture_symbols(
|
||||
ARCH arm
|
||||
SYMBOLS
|
||||
"__arm__"
|
||||
"__TARGET_ARCH_ARM"
|
||||
"_M_ARM")
|
||||
detect_architecture_symbols(
|
||||
ARCH arm
|
||||
SYMBOLS
|
||||
"__arm__"
|
||||
"__TARGET_ARCH_ARM"
|
||||
"_M_ARM")
|
||||
|
||||
detect_architecture_symbols(
|
||||
ARCH ia64
|
||||
SYMBOLS
|
||||
"__ia64"
|
||||
"__ia64__"
|
||||
"_M_IA64")
|
||||
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")
|
||||
# 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 mips
|
||||
SYMBOLS
|
||||
"__mips"
|
||||
"__mips__"
|
||||
"_M_MRX000")
|
||||
|
||||
detect_architecture_symbols(
|
||||
ARCH ppc64
|
||||
SYMBOLS
|
||||
"__ppc64__"
|
||||
"__powerpc64__"
|
||||
"_ARCH_PPC64"
|
||||
"_M_PPC64")
|
||||
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 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 sparc64
|
||||
SYMBOLS
|
||||
"__sparc_v9__")
|
||||
|
||||
detect_architecture_symbols(
|
||||
ARCH sparc
|
||||
SYMBOLS
|
||||
"__sparc__"
|
||||
"__sparc")
|
||||
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")
|
||||
# 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__")
|
||||
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()
|
||||
# "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}")
|
||||
5
externals/cmake-modules/DetectPlatform.cmake
vendored
5
externals/cmake-modules/DetectPlatform.cmake
vendored
|
|
@ -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()
|
||||
66
externals/cmake-modules/FasterLinker.cmake
vendored
66
externals/cmake-modules/FasterLinker.cmake
vendored
|
|
@ -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()
|
||||
option(USE_FASTER_LINKER "Attempt to use a faster linker program" OFF)
|
||||
|
||||
find_program(LINKER_BFD bfd)
|
||||
if (LINKER_BFD)
|
||||
set(LINKER bfd)
|
||||
endif()
|
||||
if (USE_FASTER_LINKER)
|
||||
macro(find_linker ld)
|
||||
find_program(LINKER_${ld} ld.${ld})
|
||||
if (LINKER_${ld})
|
||||
set(LINKER ${ld})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
find_program(LINKER_LLD lld)
|
||||
if (LINKER_LLD)
|
||||
set(LINKER lld)
|
||||
endif()
|
||||
find_linker(bfd)
|
||||
find_linker(lld)
|
||||
|
||||
if (CXX_GCC)
|
||||
find_program(LINKER_MOLD mold)
|
||||
if (LINKER_MOLD AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "12.1")
|
||||
set(LINKER mold)
|
||||
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()
|
||||
4
externals/cmake-modules/GetSCMRev.cmake
vendored
4
externals/cmake-modules/GetSCMRev.cmake
vendored
|
|
@ -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)
|
||||
|
|
|
|||
2
externals/cmake-modules/UseCcache.cmake
vendored
2
externals/cmake-modules/UseCcache.cmake
vendored
|
|
@ -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 ##
|
||||
|
||||
|
|
|
|||
24
externals/cmake-modules/UseLTO.cmake
vendored
24
externals/cmake-modules/UseLTO.cmake
vendored
|
|
@ -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()
|
||||
Loading…
Add table
Add a link
Reference in a new issue