Modernize CMake build system
This commit is contained in:
parent
ed2121d7ec
commit
bd760e85da
|
@ -1,16 +1,21 @@
|
||||||
cmake_minimum_required(VERSION 3.13)
|
cmake_minimum_required(VERSION 3.15)
|
||||||
|
|
||||||
include(CheckSymbolExists)
|
|
||||||
include(CheckLibraryExists)
|
|
||||||
|
|
||||||
cmake_policy(VERSION 3.13)
|
cmake_policy(VERSION 3.13)
|
||||||
if (POLICY CMP0076)
|
if (POLICY CMP0076)
|
||||||
cmake_policy(SET CMP0076 NEW)
|
cmake_policy(SET CMP0076 NEW)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version")
|
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
|
||||||
|
|
||||||
project(melonDS CXX)
|
project(melonDS C CXX)
|
||||||
|
|
||||||
|
include(CheckSymbolExists)
|
||||||
|
include(CheckLibraryExists)
|
||||||
|
include(CMakeDependentOption)
|
||||||
|
include(CheckIPOSupported)
|
||||||
|
|
||||||
|
|
||||||
|
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version")
|
||||||
|
|
||||||
set(CMAKE_C_STANDARD 11)
|
set(CMAKE_C_STANDARD 11)
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
@ -24,18 +29,12 @@ list(GET VERSION_LIST 0 MELONDS_VERSION_MAJOR)
|
||||||
list(GET VERSION_LIST 1 MELONDS_VERSION_MINOR)
|
list(GET VERSION_LIST 1 MELONDS_VERSION_MINOR)
|
||||||
# Check if melonDS version is three digits or two digits
|
# Check if melonDS version is three digits or two digits
|
||||||
list(LENGTH VERSION_LIST MELONDS_VER_LEN)
|
list(LENGTH VERSION_LIST MELONDS_VER_LEN)
|
||||||
if (${MELONDS_VER_LEN} GREATER 2)
|
if (${MELONDS_VER_LEN} GREATER 2)
|
||||||
list(GET VERSION_LIST 2 MELONDS_VERSION_PATCH)
|
list(GET VERSION_LIST 2 MELONDS_VERSION_PATCH)
|
||||||
else()
|
else()
|
||||||
set(MELONDS_VERSION_PATCH 0)
|
set(MELONDS_VERSION_PATCH 0)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
check_library_exists(m pow "" LIBM)
|
|
||||||
if(LIBM)
|
|
||||||
link_libraries(m)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (NOT CMAKE_BUILD_TYPE)
|
if (NOT CMAKE_BUILD_TYPE)
|
||||||
set(CMAKE_BUILD_TYPE Release)
|
set(CMAKE_BUILD_TYPE Release)
|
||||||
endif()
|
endif()
|
||||||
|
@ -61,74 +60,38 @@ detect_architecture("__i386__" x86)
|
||||||
detect_architecture("__arm__" ARM)
|
detect_architecture("__arm__" ARM)
|
||||||
detect_architecture("__aarch64__" ARM64)
|
detect_architecture("__aarch64__" ARM64)
|
||||||
|
|
||||||
if (ARCHITECTURE STREQUAL x86_64 OR ARCHITECTURE STREQUAL ARM64)
|
cmake_dependent_option(ENABLE_JIT "Enable JIT recompiler" ON
|
||||||
option(ENABLE_JIT "Enable x64 JIT recompiler" ON)
|
"ARCHITECTURE STREQUAL x86_64 OR ARCHITECTURE STREQUAL ARM64" OFF)
|
||||||
endif()
|
cmake_dependent_option(ENABLE_JIT_PROFILING "Enable JIT profiling with VTune" OFF "ENABLE_JIT" OFF)
|
||||||
|
|
||||||
if (ENABLE_JIT)
|
|
||||||
add_definitions(-DJIT_ENABLED)
|
|
||||||
|
|
||||||
option(ENABLE_JIT_PROFILING "Enable JIT profiling with VTune" OFF)
|
|
||||||
|
|
||||||
if (ENABLE_JIT_PROFILING)
|
|
||||||
include(cmake/FindVTune.cmake)
|
|
||||||
add_definitions(-DJIT_PROFILING_ENABLED)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (CMAKE_BUILD_TYPE STREQUAL Release)
|
|
||||||
option(ENABLE_LTO "Enable link-time optimization" ON)
|
|
||||||
else()
|
|
||||||
option(ENABLE_LTO "Enable link-time optimization" OFF)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
option(ENABLE_OGLRENDERER "Enable OpenGL renderer" ON)
|
option(ENABLE_OGLRENDERER "Enable OpenGL renderer" ON)
|
||||||
|
|
||||||
if (ENABLE_OGLRENDERER)
|
check_ipo_supported(RESULT IPO_SUPPORTED)
|
||||||
add_definitions(-DOGLRENDERER_ENABLED)
|
cmake_dependent_option(ENABLE_LTO "Enable link-time optimizations" "Release" "IPO_SUPPORTED" "OFF")
|
||||||
|
|
||||||
|
if (ENABLE_LTO STREQUAL "Release")
|
||||||
|
set_property(GLOBAL PROPERTY INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE)
|
||||||
|
elseif(ENABLE_LTO STREQUAL "ON")
|
||||||
|
set_property(GLOBAL PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (CMAKE_BUILD_TYPE STREQUAL Debug)
|
set(CMAKE_C_FLAGS_DEBUG "-Og")
|
||||||
add_compile_options(-Og)
|
set(CMAKE_CXX_FLAGS_DEBUG "-Og")
|
||||||
endif()
|
set(CMAKE_C_FLAGS_RELEASE "-O3")
|
||||||
|
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
|
||||||
|
|
||||||
if (CMAKE_BUILD_TYPE STREQUAL Release)
|
if (NOT APPLE)
|
||||||
add_compile_options(-O3)
|
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -s")
|
||||||
if (NOT APPLE)
|
|
||||||
add_link_options(-s)
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
option(BUILD_STATIC "Statically link dependencies" OFF)
|
option(BUILD_STATIC "Statically link dependencies" OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (BUILD_STATIC AND WIN32)
|
if (BUILD_STATIC AND WIN32)
|
||||||
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
|
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (ENABLE_LTO)
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
if (WIN32 OR APPLE)
|
|
||||||
add_compile_options(-flto)
|
|
||||||
add_link_options(-flto)
|
|
||||||
else()
|
|
||||||
add_compile_options(-flto -fPIC)
|
|
||||||
add_link_options(-flto -fuse-linker-plugin -pie)
|
|
||||||
endif()
|
|
||||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
||||||
set(CMAKE_AR "gcc-ar")
|
|
||||||
set(CMAKE_RANLIB "gcc-ranlib")
|
|
||||||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
|
||||||
find_program(LLD NAMES ld.lld ld64.lld lld-link)
|
|
||||||
if (NOT LLD STREQUAL "LLD-NOTFOUND")
|
|
||||||
add_link_options(-fuse-ld=lld)
|
|
||||||
endif()
|
|
||||||
if (NOT APPLE)
|
|
||||||
set(CMAKE_AR "llvm-ar")
|
|
||||||
set(CMAKE_RANLIB "llvm-ranlib")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
find_program(CCACHE "ccache")
|
find_program(CCACHE "ccache")
|
||||||
if (CCACHE)
|
if (CCACHE)
|
||||||
|
@ -142,5 +105,5 @@ option(BUILD_QT_SDL "Build Qt/SDL frontend" ON)
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
|
||||||
if (BUILD_QT_SDL)
|
if (BUILD_QT_SDL)
|
||||||
add_subdirectory(src/frontend/qt_sdl)
|
add_subdirectory(src/frontend/qt_sdl)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
# The entire codebase quire reasonably does things like #include <SDL2/SDL.h> or <epoxy/gl.h>
|
||||||
|
# CMake apparently doesn't think you should be doing this, so just includes $PREFIX/include/packagename for a given
|
||||||
|
# package as include directories when using `target_link_libraries` with an imported target, this hacky function fixes
|
||||||
|
# that up so includes can keep working as they always did but we can still use fancy imported targets.
|
||||||
|
# This is stupid.
|
||||||
|
|
||||||
|
function(fix_interface_includes)
|
||||||
|
foreach (target ${ARGN})
|
||||||
|
set(NEW_DIRS)
|
||||||
|
get_target_property(DIRS "${target}" INTERFACE_INCLUDE_DIRECTORIES)
|
||||||
|
|
||||||
|
foreach (DIR ${DIRS})
|
||||||
|
get_filename_component(PARENT_DIR "${DIR}" DIRECTORY)
|
||||||
|
|
||||||
|
if (PARENT_DIR MATCHES "include$")
|
||||||
|
list(APPEND NEW_DIRS "${PARENT_DIR}")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
list(APPEND DIRS ${NEW_DIRS})
|
||||||
|
set_target_properties("${target}" PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${DIRS}")
|
||||||
|
endforeach()
|
||||||
|
endfunction()
|
||||||
|
|
|
@ -1,141 +1,146 @@
|
||||||
project(core)
|
|
||||||
|
|
||||||
set (CMAKE_CXX_STANDARD 17)
|
set (CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
add_library(core STATIC
|
include(FixInterfaceIncludes)
|
||||||
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
|
add_library(core STATIC
|
||||||
fatfs/ff.c
|
ARCodeFile.cpp
|
||||||
fatfs/ffsystem.c
|
AREngine.cpp
|
||||||
fatfs/ffunicode.c
|
ARM.cpp
|
||||||
fatfs/ffconf.h
|
ARM_InstrTable.h
|
||||||
|
ARMInterpreter.cpp
|
||||||
sha1/sha1.c
|
ARMInterpreter_ALU.cpp
|
||||||
tiny-AES-c/aes.c
|
ARMInterpreter_Branch.cpp
|
||||||
xxhash/xxhash.c
|
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)
|
if (ENABLE_OGLRENDERER)
|
||||||
target_sources(core PRIVATE
|
target_sources(core PRIVATE
|
||||||
GPU_OpenGL.cpp
|
GPU_OpenGL.cpp
|
||||||
GPU_OpenGL_shaders.h
|
GPU_OpenGL_shaders.h
|
||||||
GPU3D_OpenGL.cpp
|
GPU3D_OpenGL.cpp
|
||||||
GPU3D_OpenGL_shaders.h
|
GPU3D_OpenGL_shaders.h
|
||||||
OpenGLSupport.cpp
|
OpenGLSupport.cpp)
|
||||||
)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (ENABLE_JIT)
|
if (ENABLE_JIT)
|
||||||
enable_language(ASM)
|
enable_language(ASM)
|
||||||
|
|
||||||
target_sources(core PRIVATE
|
target_sources(core PRIVATE
|
||||||
ARM_InstrInfo.cpp
|
ARM_InstrInfo.cpp
|
||||||
|
|
||||||
ARMJIT.cpp
|
ARMJIT.cpp
|
||||||
ARMJIT_Memory.cpp
|
ARMJIT_Memory.cpp
|
||||||
|
|
||||||
dolphin/CommonFuncs.cpp
|
dolphin/CommonFuncs.cpp)
|
||||||
)
|
|
||||||
|
|
||||||
if (ARCHITECTURE STREQUAL x86_64)
|
if (ARCHITECTURE STREQUAL x86_64)
|
||||||
target_sources(core PRIVATE
|
target_sources(core PRIVATE
|
||||||
dolphin/x64ABI.cpp
|
dolphin/x64ABI.cpp
|
||||||
dolphin/x64CPUDetect.cpp
|
dolphin/x64CPUDetect.cpp
|
||||||
dolphin/x64Emitter.cpp
|
dolphin/x64Emitter.cpp
|
||||||
|
|
||||||
ARMJIT_x64/ARMJIT_Compiler.cpp
|
ARMJIT_x64/ARMJIT_Compiler.cpp
|
||||||
ARMJIT_x64/ARMJIT_ALU.cpp
|
ARMJIT_x64/ARMJIT_ALU.cpp
|
||||||
ARMJIT_x64/ARMJIT_LoadStore.cpp
|
ARMJIT_x64/ARMJIT_LoadStore.cpp
|
||||||
ARMJIT_x64/ARMJIT_Branch.cpp
|
ARMJIT_x64/ARMJIT_Branch.cpp
|
||||||
|
|
||||||
ARMJIT_x64/ARMJIT_Linkage.S
|
ARMJIT_x64/ARMJIT_Linkage.S)
|
||||||
)
|
endif()
|
||||||
endif()
|
if (ARCHITECTURE STREQUAL ARM64)
|
||||||
if (ARCHITECTURE STREQUAL ARM64)
|
target_sources(core PRIVATE
|
||||||
target_sources(core PRIVATE
|
dolphin/Arm64Emitter.cpp
|
||||||
dolphin/Arm64Emitter.cpp
|
dolphin/MathUtil.cpp
|
||||||
dolphin/MathUtil.cpp
|
|
||||||
|
|
||||||
ARMJIT_A64/ARMJIT_Compiler.cpp
|
ARMJIT_A64/ARMJIT_Compiler.cpp
|
||||||
ARMJIT_A64/ARMJIT_ALU.cpp
|
ARMJIT_A64/ARMJIT_ALU.cpp
|
||||||
ARMJIT_A64/ARMJIT_LoadStore.cpp
|
ARMJIT_A64/ARMJIT_LoadStore.cpp
|
||||||
ARMJIT_A64/ARMJIT_Branch.cpp
|
ARMJIT_A64/ARMJIT_Branch.cpp
|
||||||
|
|
||||||
ARMJIT_A64/ARMJIT_Linkage.S
|
ARMJIT_A64/ARMJIT_Linkage.S)
|
||||||
)
|
endif()
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory(teakra EXCLUDE_FROM_ALL)
|
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)
|
if (ENABLE_OGLRENDERER)
|
||||||
find_package(PkgConfig REQUIRED)
|
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})
|
target_include_directories(core PRIVATE PkgConfig::Epoxy)
|
||||||
if (WIN32)
|
target_link_libraries(core PUBLIC PkgConfig::Epoxy)
|
||||||
target_link_libraries(core ole32 comctl32 ws2_32 ${EPOXY_LIBRARIES})
|
|
||||||
elseif (APPLE)
|
target_compile_definitions(core PUBLIC OGLRENDERER_ENABLED)
|
||||||
target_link_libraries(core ${EPOXY_LIBRARIES})
|
endif()
|
||||||
else()
|
|
||||||
target_link_libraries(core rt ${EPOXY_LIBRARIES})
|
if (ENABLE_JIT)
|
||||||
|
target_compile_definitions(core PUBLIC JIT_ENABLED)
|
||||||
|
|
||||||
|
|
||||||
|
if (ENABLE_JIT_PROFILING)
|
||||||
|
include(cmake/FindVTune.cmake)
|
||||||
|
add_definitions(-DJIT_PROFILING_ENABLED)
|
||||||
endif()
|
endif()
|
||||||
else()
|
endif()
|
||||||
if (WIN32)
|
|
||||||
target_link_libraries(core ole32 comctl32 ws2_32)
|
if (WIN32)
|
||||||
elseif (APPLE)
|
target_link_libraries(core PRIVATE ole32 comctl32 ws2_32)
|
||||||
target_link_libraries(core)
|
elseif(NOT APPLE)
|
||||||
else()
|
target_link_libraries(core PRIVATE rt)
|
||||||
target_link_libraries(core rt)
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (ENABLE_JIT_PROFILING)
|
if (ENABLE_JIT_PROFILING)
|
||||||
target_link_libraries(core jitprofiling)
|
target_link_libraries(core PRIVATE jitprofiling)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
project(qt_sdl)
|
include(CMakeDependentOption)
|
||||||
|
|
||||||
SET(SOURCES_QT_SDL
|
include(FixInterfaceIncludes)
|
||||||
|
|
||||||
|
set(SOURCES_QT_SDL
|
||||||
main.cpp
|
main.cpp
|
||||||
main_shaders.h
|
main_shaders.h
|
||||||
CheatsDialog.cpp
|
CheatsDialog.cpp
|
||||||
Config.cpp
|
Config.cpp
|
||||||
EmuSettingsDialog.cpp
|
EmuSettingsDialog.cpp
|
||||||
PowerManagement/PowerManagementDialog.cpp
|
PowerManagement/PowerManagementDialog.cpp
|
||||||
PowerManagement/resources/battery.qrc
|
PowerManagement/resources/battery.qrc
|
||||||
|
@ -28,9 +30,9 @@ SET(SOURCES_QT_SDL
|
||||||
font.h
|
font.h
|
||||||
Platform.cpp
|
Platform.cpp
|
||||||
QPathInput.h
|
QPathInput.h
|
||||||
ROMManager.cpp
|
ROMManager.cpp
|
||||||
SaveManager.cpp
|
SaveManager.cpp
|
||||||
|
|
||||||
ArchiveUtil.h
|
ArchiveUtil.h
|
||||||
ArchiveUtil.cpp
|
ArchiveUtil.cpp
|
||||||
|
|
||||||
|
@ -40,7 +42,7 @@ SET(SOURCES_QT_SDL
|
||||||
../mic_blow.h
|
../mic_blow.h
|
||||||
|
|
||||||
${CMAKE_SOURCE_DIR}/res/melon.qrc
|
${CMAKE_SOURCE_DIR}/res/melon.qrc
|
||||||
)
|
)
|
||||||
|
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
option(USE_QT6 "Build using Qt 6 instead of 5" ON)
|
option(USE_QT6 "Build using Qt 6 instead of 5" ON)
|
||||||
|
@ -86,9 +88,12 @@ set(CMAKE_AUTORCC ON)
|
||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
find_package(Iconv REQUIRED)
|
find_package(Iconv REQUIRED)
|
||||||
pkg_check_modules(SDL2 REQUIRED sdl2)
|
find_package(SDL2 REQUIRED)
|
||||||
pkg_check_modules(SLIRP REQUIRED slirp)
|
pkg_check_modules(Slirp REQUIRED IMPORTED_TARGET slirp)
|
||||||
pkg_check_modules(LIBARCHIVE REQUIRED libarchive)
|
pkg_check_modules(LibArchive REQUIRED IMPORTED_TARGET libarchive)
|
||||||
|
|
||||||
|
fix_interface_includes(SDL2::SDL2 PkgConfig::Slirp PkgConfig::LibArchive)
|
||||||
|
|
||||||
add_compile_definitions(ARCHIVE_SUPPORT_ENABLED)
|
add_compile_definitions(ARCHIVE_SUPPORT_ENABLED)
|
||||||
|
|
||||||
if (WIN32 AND (CMAKE_BUILD_TYPE STREQUAL Release))
|
if (WIN32 AND (CMAKE_BUILD_TYPE STREQUAL Release))
|
||||||
|
@ -97,49 +102,40 @@ else()
|
||||||
add_executable(melonDS ${SOURCES_QT_SDL})
|
add_executable(melonDS ${SOURCES_QT_SDL})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(melonDS ${CMAKE_THREAD_LIBS_INIT})
|
if (BUILD_STATIC)
|
||||||
|
qt_import_plugins(melonDS INCLUDE Qt::QSvgPlugin)
|
||||||
target_include_directories(melonDS PRIVATE ${SDL2_INCLUDE_DIRS} ${SDL2_PREFIX}/include ${SLIRP_INCLUDE_DIRS} ${LIBARCHIVE_INCLUDE_DIRS})
|
target_link_options(melonDS PRIVATE -static)
|
||||||
target_link_directories(melonDS PRIVATE ${SDL2_LIBRARY_DIRS} ${SLIRP_LIBRARY_DIRS})
|
endif()
|
||||||
target_link_directories(melonDS PRIVATE ${LIBARCHIVE_LIBRARY_DIRS})
|
|
||||||
|
|
||||||
target_include_directories(melonDS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
|
target_include_directories(melonDS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
target_include_directories(melonDS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..")
|
target_include_directories(melonDS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..")
|
||||||
target_include_directories(melonDS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../..")
|
target_include_directories(melonDS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../..")
|
||||||
target_link_libraries(melonDS core)
|
target_link_libraries(melonDS PRIVATE core)
|
||||||
|
target_link_libraries(melonDS PRIVATE SDL2::SDL2 PkgConfig::Slirp PkgConfig::LibArchive)
|
||||||
if (BUILD_STATIC)
|
|
||||||
target_link_libraries(melonDS -static ${SDL2_STATIC_LIBRARIES} ${SLIRP_STATIC_LIBRARIES} ${LIBARCHIVE_STATIC_LIBRARIES})
|
|
||||||
qt_import_plugins(melonDS INCLUDE Qt::QSvgPlugin)
|
|
||||||
else()
|
|
||||||
target_link_libraries(melonDS ${SDL2_LIBRARIES} ${SLIRP_LIBRARIES} ${LIBARCHIVE_LIBRARIES})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (NOT Iconv_IS_BUILT_IN)
|
if (NOT Iconv_IS_BUILT_IN)
|
||||||
target_link_libraries(melonDS ${Iconv_LIBRARIES})
|
target_link_libraries(melonDS PRIVATE Iconv::Iconv)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (UNIX)
|
if (UNIX)
|
||||||
option(PORTABLE "Make a portable build that looks for its configuration in the current directory" OFF)
|
option(PORTABLE "Make a portable build that looks for its configuration in the current directory" OFF)
|
||||||
target_link_libraries(melonDS ${QT_LINK_LIBS})
|
target_link_libraries(melonDS PRIVATE ${QT_LINK_LIBS} ${CMAKE_DL_LIBS})
|
||||||
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|
||||||
target_link_libraries(melonDS dl)
|
|
||||||
endif()
|
|
||||||
elseif (WIN32)
|
elseif (WIN32)
|
||||||
option(PORTABLE "Make a portable build that looks for its configuration in the current directory" ON)
|
option(PORTABLE "Make a portable build that looks for its configuration in the current directory" ON)
|
||||||
|
|
||||||
configure_file("${CMAKE_SOURCE_DIR}/res/melon.rc.in" "${CMAKE_SOURCE_DIR}/melon.rc")
|
configure_file("${CMAKE_SOURCE_DIR}/res/melon.rc.in" "${CMAKE_SOURCE_DIR}/melon.rc")
|
||||||
target_sources(melonDS PUBLIC "${CMAKE_SOURCE_DIR}/melon.rc")
|
target_sources(melonDS PUBLIC "${CMAKE_SOURCE_DIR}/melon.rc")
|
||||||
|
|
||||||
target_link_libraries(melonDS comctl32 d2d1 dwrite uxtheme ws2_32 iphlpapi gdi32)
|
target_link_libraries(melonDS PRIVATE comctl32 d2d1 dwrite uxtheme ws2_32 iphlpapi gdi32)
|
||||||
if (BUILD_STATIC)
|
if (BUILD_STATIC)
|
||||||
target_link_libraries(melonDS imm32 winmm version setupapi -static z zstd ${QT_LINK_LIBS})
|
target_link_libraries(melonDS PRIVATE imm32 winmm version setupapi -static z zstd ${QT_LINK_LIBS})
|
||||||
else()
|
else()
|
||||||
target_link_libraries(melonDS ${QT_LINK_LIBS})
|
target_link_libraries(melonDS PRIVATE ${QT_LINK_LIBS})
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (PORTABLE)
|
if (PORTABLE)
|
||||||
add_definitions(-DPORTABLE)
|
target_compile_definitions(melonDS PRIVATE PORTABLE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
|
@ -152,7 +148,7 @@ if (APPLE)
|
||||||
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/res/melon.plist.in
|
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/res/melon.plist.in
|
||||||
OUTPUT_NAME melonDS
|
OUTPUT_NAME melonDS
|
||||||
RESOURCE "${RESOURCE_FILES}")
|
RESOURCE "${RESOURCE_FILES}")
|
||||||
|
|
||||||
|
|
||||||
option(MACOS_BUNDLE_LIBS "Bundle libraries with the app on macOS" OFF)
|
option(MACOS_BUNDLE_LIBS "Bundle libraries with the app on macOS" OFF)
|
||||||
option(MACOS_BUILD_DMG "Build DMG image of the macOS application bundle" OFF)
|
option(MACOS_BUILD_DMG "Build DMG image of the macOS application bundle" OFF)
|
||||||
|
@ -170,10 +166,10 @@ endif()
|
||||||
if (UNIX AND NOT APPLE)
|
if (UNIX AND NOT APPLE)
|
||||||
foreach(SIZE 16 32 48 64 128 256)
|
foreach(SIZE 16 32 48 64 128 256)
|
||||||
install(FILES ${CMAKE_SOURCE_DIR}/res/icon/melon_${SIZE}x${SIZE}.png
|
install(FILES ${CMAKE_SOURCE_DIR}/res/icon/melon_${SIZE}x${SIZE}.png
|
||||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/${SIZE}x${SIZE}/apps
|
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/${SIZE}x${SIZE}/apps
|
||||||
RENAME net.kuribo64.melonDS.png)
|
RENAME net.kuribo64.melonDS.png)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
install(FILES ${CMAKE_SOURCE_DIR}/res/net.kuribo64.melonDS.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications)
|
install(FILES ${CMAKE_SOURCE_DIR}/res/net.kuribo64.melonDS.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications)
|
||||||
install(TARGETS melonDS BUNDLE DESTINATION ${CMAKE_BINARY_DIR} RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
install(TARGETS melonDS BUNDLE DESTINATION ${CMAKE_BINARY_DIR} RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
||||||
endif()
|
endif()
|
Loading…
Reference in New Issue