mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-26 07:39:56 -06:00
Modernize CMake build system (#1434)
These changes modernize the CMake build system to (hopefully) match newer best practices * Library linking is simpler and more automatic because of using imported targets * Multi-configuration builds should be supported (Ninja Multi-Config, Visual Studio, etc. generators) * Clean up build options using cmake_dependent_option * Let CMake do its job in more cases, like finding the math/dl libraries and detecting and enabling LTO support * Remove platform-specific kludges like the Fedora/flatpak LTO workaround and a bunch of Windows stuff * Simplify Windows static builds * Consistent formatting
This commit is contained in:

committed by
GitHub

parent
6c7485d017
commit
94b33c924e
@ -1,141 +1,145 @@
|
||||
project(core)
|
||||
|
||||
set (CMAKE_CXX_STANDARD 17)
|
||||
|
||||
add_library(core STATIC
|
||||
ARCodeFile.cpp
|
||||
AREngine.cpp
|
||||
ARM.cpp
|
||||
ARM_InstrTable.h
|
||||
ARMInterpreter.cpp
|
||||
ARMInterpreter_ALU.cpp
|
||||
ARMInterpreter_Branch.cpp
|
||||
ARMInterpreter_LoadStore.cpp
|
||||
CP15.cpp
|
||||
CRC32.cpp
|
||||
DMA.cpp
|
||||
DMA_Timings.h
|
||||
DSi.cpp
|
||||
DSi_AES.cpp
|
||||
DSi_Camera.cpp
|
||||
DSi_DSP.cpp
|
||||
DSi_I2C.cpp
|
||||
DSi_NAND.cpp
|
||||
DSi_NDMA.cpp
|
||||
DSi_NWifi.cpp
|
||||
DSi_SD.cpp
|
||||
DSi_SPI_TSC.cpp
|
||||
FATStorage.cpp
|
||||
FIFO.h
|
||||
GBACart.cpp
|
||||
GPU.cpp
|
||||
GPU2D.cpp
|
||||
GPU2D_Soft.cpp
|
||||
GPU3D.cpp
|
||||
GPU3D_Soft.cpp
|
||||
melonDLDI.h
|
||||
NDS.cpp
|
||||
NDSCart.cpp
|
||||
Platform.h
|
||||
ROMList.h
|
||||
FreeBIOS.h
|
||||
RTC.cpp
|
||||
Savestate.cpp
|
||||
SPI.cpp
|
||||
SPU.cpp
|
||||
types.h
|
||||
version.h
|
||||
Wifi.cpp
|
||||
WifiAP.cpp
|
||||
include(FixInterfaceIncludes)
|
||||
|
||||
fatfs/diskio.c
|
||||
fatfs/ff.c
|
||||
fatfs/ffsystem.c
|
||||
fatfs/ffunicode.c
|
||||
fatfs/ffconf.h
|
||||
|
||||
sha1/sha1.c
|
||||
tiny-AES-c/aes.c
|
||||
xxhash/xxhash.c
|
||||
)
|
||||
add_library(core STATIC
|
||||
ARCodeFile.cpp
|
||||
AREngine.cpp
|
||||
ARM.cpp
|
||||
ARM_InstrTable.h
|
||||
ARMInterpreter.cpp
|
||||
ARMInterpreter_ALU.cpp
|
||||
ARMInterpreter_Branch.cpp
|
||||
ARMInterpreter_LoadStore.cpp
|
||||
CP15.cpp
|
||||
CRC32.cpp
|
||||
DMA.cpp
|
||||
DMA_Timings.h
|
||||
DSi.cpp
|
||||
DSi_AES.cpp
|
||||
DSi_Camera.cpp
|
||||
DSi_DSP.cpp
|
||||
DSi_I2C.cpp
|
||||
DSi_NAND.cpp
|
||||
DSi_NDMA.cpp
|
||||
DSi_NWifi.cpp
|
||||
DSi_SD.cpp
|
||||
DSi_SPI_TSC.cpp
|
||||
FATStorage.cpp
|
||||
FIFO.h
|
||||
GBACart.cpp
|
||||
GPU.cpp
|
||||
GPU2D.cpp
|
||||
GPU2D_Soft.cpp
|
||||
GPU3D.cpp
|
||||
GPU3D_Soft.cpp
|
||||
melonDLDI.h
|
||||
NDS.cpp
|
||||
NDSCart.cpp
|
||||
Platform.h
|
||||
ROMList.h
|
||||
FreeBIOS.h
|
||||
RTC.cpp
|
||||
Savestate.cpp
|
||||
SPI.cpp
|
||||
SPU.cpp
|
||||
types.h
|
||||
version.h
|
||||
Wifi.cpp
|
||||
WifiAP.cpp
|
||||
|
||||
fatfs/diskio.c
|
||||
fatfs/ff.c
|
||||
fatfs/ffsystem.c
|
||||
fatfs/ffunicode.c
|
||||
fatfs/ffconf.h
|
||||
|
||||
sha1/sha1.c
|
||||
tiny-AES-c/aes.c
|
||||
xxhash/xxhash.c)
|
||||
|
||||
if (ENABLE_OGLRENDERER)
|
||||
target_sources(core PRIVATE
|
||||
GPU_OpenGL.cpp
|
||||
GPU_OpenGL_shaders.h
|
||||
GPU3D_OpenGL.cpp
|
||||
GPU3D_OpenGL_shaders.h
|
||||
OpenGLSupport.cpp
|
||||
)
|
||||
target_sources(core PRIVATE
|
||||
GPU_OpenGL.cpp
|
||||
GPU_OpenGL_shaders.h
|
||||
GPU3D_OpenGL.cpp
|
||||
GPU3D_OpenGL_shaders.h
|
||||
OpenGLSupport.cpp)
|
||||
endif()
|
||||
|
||||
if (ENABLE_JIT)
|
||||
enable_language(ASM)
|
||||
enable_language(ASM)
|
||||
|
||||
target_sources(core PRIVATE
|
||||
ARM_InstrInfo.cpp
|
||||
target_sources(core PRIVATE
|
||||
ARM_InstrInfo.cpp
|
||||
|
||||
ARMJIT.cpp
|
||||
ARMJIT_Memory.cpp
|
||||
ARMJIT.cpp
|
||||
ARMJIT_Memory.cpp
|
||||
|
||||
dolphin/CommonFuncs.cpp
|
||||
)
|
||||
dolphin/CommonFuncs.cpp)
|
||||
|
||||
if (ARCHITECTURE STREQUAL x86_64)
|
||||
target_sources(core PRIVATE
|
||||
dolphin/x64ABI.cpp
|
||||
dolphin/x64CPUDetect.cpp
|
||||
dolphin/x64Emitter.cpp
|
||||
if (ARCHITECTURE STREQUAL x86_64)
|
||||
target_sources(core PRIVATE
|
||||
dolphin/x64ABI.cpp
|
||||
dolphin/x64CPUDetect.cpp
|
||||
dolphin/x64Emitter.cpp
|
||||
|
||||
ARMJIT_x64/ARMJIT_Compiler.cpp
|
||||
ARMJIT_x64/ARMJIT_ALU.cpp
|
||||
ARMJIT_x64/ARMJIT_LoadStore.cpp
|
||||
ARMJIT_x64/ARMJIT_Branch.cpp
|
||||
ARMJIT_x64/ARMJIT_Compiler.cpp
|
||||
ARMJIT_x64/ARMJIT_ALU.cpp
|
||||
ARMJIT_x64/ARMJIT_LoadStore.cpp
|
||||
ARMJIT_x64/ARMJIT_Branch.cpp
|
||||
|
||||
ARMJIT_x64/ARMJIT_Linkage.S
|
||||
)
|
||||
endif()
|
||||
if (ARCHITECTURE STREQUAL ARM64)
|
||||
target_sources(core PRIVATE
|
||||
dolphin/Arm64Emitter.cpp
|
||||
dolphin/MathUtil.cpp
|
||||
ARMJIT_x64/ARMJIT_Linkage.S)
|
||||
endif()
|
||||
if (ARCHITECTURE STREQUAL ARM64)
|
||||
target_sources(core PRIVATE
|
||||
dolphin/Arm64Emitter.cpp
|
||||
dolphin/MathUtil.cpp
|
||||
|
||||
ARMJIT_A64/ARMJIT_Compiler.cpp
|
||||
ARMJIT_A64/ARMJIT_ALU.cpp
|
||||
ARMJIT_A64/ARMJIT_LoadStore.cpp
|
||||
ARMJIT_A64/ARMJIT_Branch.cpp
|
||||
ARMJIT_A64/ARMJIT_Compiler.cpp
|
||||
ARMJIT_A64/ARMJIT_ALU.cpp
|
||||
ARMJIT_A64/ARMJIT_LoadStore.cpp
|
||||
ARMJIT_A64/ARMJIT_Branch.cpp
|
||||
|
||||
ARMJIT_A64/ARMJIT_Linkage.S
|
||||
)
|
||||
endif()
|
||||
ARMJIT_A64/ARMJIT_Linkage.S)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_subdirectory(teakra EXCLUDE_FROM_ALL)
|
||||
target_link_libraries(core teakra)
|
||||
target_link_libraries(core PRIVATE teakra)
|
||||
|
||||
find_library(m MATH_LIBRARY)
|
||||
|
||||
if (MATH_LIBRARY)
|
||||
target_link_libraries(core PRIVATE ${MATH_LIBRARY})
|
||||
endif()
|
||||
|
||||
if (ENABLE_OGLRENDERER)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(EPOXY REQUIRED epoxy)
|
||||
pkg_check_modules(Epoxy REQUIRED IMPORTED_TARGET epoxy)
|
||||
fix_interface_includes(PkgConfig::Epoxy)
|
||||
|
||||
target_include_directories(core PRIVATE ${EPOXY_INCLUDE_DIRS})
|
||||
if (WIN32)
|
||||
target_link_libraries(core ole32 comctl32 ws2_32 ${EPOXY_LIBRARIES})
|
||||
elseif (APPLE)
|
||||
target_link_libraries(core ${EPOXY_LIBRARIES})
|
||||
else()
|
||||
target_link_libraries(core rt ${EPOXY_LIBRARIES})
|
||||
target_link_libraries(core PUBLIC PkgConfig::Epoxy)
|
||||
|
||||
target_compile_definitions(core PUBLIC OGLRENDERER_ENABLED)
|
||||
endif()
|
||||
|
||||
if (ENABLE_JIT)
|
||||
target_compile_definitions(core PUBLIC JIT_ENABLED)
|
||||
|
||||
|
||||
if (ENABLE_JIT_PROFILING)
|
||||
include(cmake/FindVTune.cmake)
|
||||
add_definitions(-DJIT_PROFILING_ENABLED)
|
||||
endif()
|
||||
else()
|
||||
if (WIN32)
|
||||
target_link_libraries(core ole32 comctl32 ws2_32)
|
||||
elseif (APPLE)
|
||||
target_link_libraries(core)
|
||||
else()
|
||||
target_link_libraries(core rt)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
target_link_libraries(core PRIVATE ole32 comctl32 ws2_32)
|
||||
elseif(NOT APPLE)
|
||||
target_link_libraries(core PRIVATE rt)
|
||||
endif()
|
||||
|
||||
if (ENABLE_JIT_PROFILING)
|
||||
target_link_libraries(core jitprofiling)
|
||||
target_link_libraries(core PRIVATE jitprofiling)
|
||||
endif()
|
||||
|
Reference in New Issue
Block a user