cmake: Refactor library management
This commit is contained in:
parent
c126925dd9
commit
6e28ac711f
|
@ -1,27 +1,15 @@
|
||||||
cmake_minimum_required(VERSION 3.16.3)
|
cmake_minimum_required(VERSION 3.16.3)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||||
|
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
if (NOT CMAKE_BUILD_TYPE)
|
||||||
set(CMAKE_BUILD_TYPE Release)
|
set(CMAKE_BUILD_TYPE Release)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
project(shadps4)
|
project(shadps4)
|
||||||
|
|
||||||
include_directories(third-party/)
|
add_subdirectory(third-party)
|
||||||
include_directories(third-party/discord-rpc/include)
|
|
||||||
include_directories(third-party/imgui/)
|
|
||||||
include_directories(third-party/imgui/backends)
|
|
||||||
include_directories(third-party/sdl/)
|
|
||||||
include_directories(third-party/fmt/include)
|
|
||||||
include_directories(third-party/magic_enum/include)
|
|
||||||
include_directories(third-party/zydis/include/Zydis)
|
|
||||||
include_directories(third-party/winpthread/include)
|
|
||||||
include_directories(third-party/vulkan/include)
|
|
||||||
include_directories(third-party/xxhash/include)
|
|
||||||
include_directories(third-party/result/include)
|
|
||||||
add_subdirectory("third-party")
|
|
||||||
#=================== EXAMPLE ===================
|
|
||||||
include_directories(src)
|
include_directories(src)
|
||||||
|
|
||||||
set(LIBC_SOURCES src/core/hle/libraries/Libc/Libc.cpp
|
set(LIBC_SOURCES src/core/hle/libraries/Libc/Libc.cpp
|
||||||
|
@ -52,9 +40,7 @@ set(SYSTEMSERVICE_SOURCES src/core/hle/libraries/libsystemservice/system_service
|
||||||
)
|
)
|
||||||
|
|
||||||
set(FILESYSTEM_SOURCES src/core/hle/libraries/libkernel/file_system.cpp
|
set(FILESYSTEM_SOURCES src/core/hle/libraries/libkernel/file_system.cpp
|
||||||
src/core/hle/libraries/libkernel/file_system.h
|
src/core/hle/libraries/libkernel/file_system.h
|
||||||
|
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set(HOST_SOURCES src/Emulator/Host/controller.cpp
|
set(HOST_SOURCES src/Emulator/Host/controller.cpp
|
||||||
|
@ -110,8 +96,11 @@ add_executable(shadps4
|
||||||
|
|
||||||
"src/Util/Disassembler.cpp" "src/Util/Disassembler.h" "src/core/PS4/Util/aerolib.h" "src/core/PS4/Loader/SymbolsResolver.h" "src/core/PS4/Loader/SymbolsResolver.cpp" "src/core/PS4/HLE/Libs.cpp" "src/core/PS4/HLE/Libs.h" "src/core/PS4/HLE/LibKernel.cpp" "src/core/PS4/HLE/LibKernel.h" "src/core/PS4/HLE/LibSceGnmDriver.cpp" "src/core/PS4/HLE/LibSceGnmDriver.h" "src/core/PS4/HLE/Kernel/ThreadManagement.cpp" "src/core/PS4/HLE/Kernel/ThreadManagement.h" "src/core/PS4/HLE/ErrorCodes.h" "src/debug.h" "src/core/PS4/HLE/Kernel/memory_management.cpp" "src/core/PS4/HLE/Kernel/memory_management.h" "src/core/PS4/GPU/gpu_memory.cpp" "src/core/PS4/GPU/gpu_memory.h" "src/emulator.cpp" "src/emulator.h" "src/core/PS4/HLE/Kernel/Objects/event_queue.h" "src/core/PS4/HLE/Kernel/Objects/event_queue.cpp" "src/core/PS4/HLE/Graphics/Objects/video_out_ctx.cpp" "src/core/PS4/HLE/Graphics/Objects/video_out_ctx.h" "src/core/PS4/HLE/Graphics/graphics_ctx.h" "src/vulkan_util.cpp" "src/vulkan_util.h" "src/core/PS4/GPU/video_out_buffer.cpp" "src/core/PS4/GPU/video_out_buffer.h" "src/core/PS4/HLE/Graphics/graphics_render.cpp" "src/core/PS4/HLE/Graphics/graphics_render.h" "src/core/PS4/GPU/tile_manager.cpp" "src/core/PS4/GPU/tile_manager.h" "src/version.h" "src/emuTimer.cpp" "src/emuTimer.h" "src/core/hle/libraries/libkernel/time_management.cpp" "src/core/hle/libraries/libkernel/time_management.h")
|
"src/Util/Disassembler.cpp" "src/Util/Disassembler.h" "src/core/PS4/Util/aerolib.h" "src/core/PS4/Loader/SymbolsResolver.h" "src/core/PS4/Loader/SymbolsResolver.cpp" "src/core/PS4/HLE/Libs.cpp" "src/core/PS4/HLE/Libs.h" "src/core/PS4/HLE/LibKernel.cpp" "src/core/PS4/HLE/LibKernel.h" "src/core/PS4/HLE/LibSceGnmDriver.cpp" "src/core/PS4/HLE/LibSceGnmDriver.h" "src/core/PS4/HLE/Kernel/ThreadManagement.cpp" "src/core/PS4/HLE/Kernel/ThreadManagement.h" "src/core/PS4/HLE/ErrorCodes.h" "src/debug.h" "src/core/PS4/HLE/Kernel/memory_management.cpp" "src/core/PS4/HLE/Kernel/memory_management.h" "src/core/PS4/GPU/gpu_memory.cpp" "src/core/PS4/GPU/gpu_memory.h" "src/emulator.cpp" "src/emulator.h" "src/core/PS4/HLE/Kernel/Objects/event_queue.h" "src/core/PS4/HLE/Kernel/Objects/event_queue.cpp" "src/core/PS4/HLE/Graphics/Objects/video_out_ctx.cpp" "src/core/PS4/HLE/Graphics/Objects/video_out_ctx.h" "src/core/PS4/HLE/Graphics/graphics_ctx.h" "src/vulkan_util.cpp" "src/vulkan_util.h" "src/core/PS4/GPU/video_out_buffer.cpp" "src/core/PS4/GPU/video_out_buffer.h" "src/core/PS4/HLE/Graphics/graphics_render.cpp" "src/core/PS4/HLE/Graphics/graphics_render.h" "src/core/PS4/GPU/tile_manager.cpp" "src/core/PS4/GPU/tile_manager.h" "src/version.h" "src/emuTimer.cpp" "src/emuTimer.h" "src/core/hle/libraries/libkernel/time_management.cpp" "src/core/hle/libraries/libkernel/time_management.h")
|
||||||
|
|
||||||
find_package(OpenGL REQUIRED)
|
target_link_libraries(shadps4 PRIVATE magic_enum::magic_enum fmt::fmt spdlog::spdlog toml11::toml11)
|
||||||
target_link_libraries(shadps4 PUBLIC fmt mincore spdlog IMGUI SDL3-shared ${OPENGL_LIBRARY} vulkan-1 spirv-tools-opt spirv-tools)
|
target_link_libraries(shadps4 PRIVATE discord-rpc imgui SDL3-shared vulkan-1 xxhash Zydis)
|
||||||
|
if (WIN32)
|
||||||
|
target_link_libraries(shadps4 PRIVATE mincore winpthread)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_custom_command(TARGET shadps4 POST_BUILD
|
add_custom_command(TARGET shadps4 POST_BUILD
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Zydis.h"
|
#include <Zydis/Zydis.h>
|
||||||
#include "../types.h"
|
#include "../types.h"
|
||||||
|
|
||||||
class Disassembler
|
class Disassembler
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
#include <toml11/toml.hpp>
|
#include <toml.hpp>
|
||||||
|
|
||||||
namespace Config {
|
namespace Config {
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "gpu_memory.h"
|
#include "gpu_memory.h"
|
||||||
|
|
||||||
#include <xxhash/xxh3.h>
|
#include <xxh3.h>
|
||||||
|
|
||||||
#include "Emulator/Util/singleton.h"
|
#include "Emulator/Util/singleton.h"
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include "../virtual_memory.h"
|
#include "../virtual_memory.h"
|
||||||
#include <Util/log.h>
|
#include <Util/log.h>
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
#include "Zydis.h"
|
#include <Zydis/Zydis.h>
|
||||||
#include <Util/string_util.h>
|
#include <Util/string_util.h>
|
||||||
#include "Util/aerolib.h"
|
#include "Util/aerolib.h"
|
||||||
#include "Loader/SymbolsResolver.h"
|
#include "Loader/SymbolsResolver.h"
|
||||||
|
|
|
@ -16,4 +16,4 @@ namespace Discord {
|
||||||
void update(RPCStatus status, const std::string& title);
|
void update(RPCStatus status, const std::string& title);
|
||||||
void stop();
|
void stop();
|
||||||
};
|
};
|
||||||
} // namespace Discord
|
} // namespace Discord
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <core/PS4/HLE/Graphics/graphics_render.h>
|
#include <core/PS4/HLE/Graphics/graphics_render.h>
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <src/video/khronos/vulkan/vulkan_core.h>
|
#include <vulkan/vulkan_core.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
|
@ -1,69 +1,70 @@
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
if (MSVC)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
# Silence "deprecation" warnings
|
||||||
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Discord-RPC
|
||||||
|
set(BUILD_EXAMPLES OFF CACHE BOOL "")
|
||||||
|
add_subdirectory(discord-rpc EXCLUDE_FROM_ALL)
|
||||||
|
target_include_directories(discord-rpc INTERFACE ./discord-rpc/include)
|
||||||
|
|
||||||
#====================FMT ====================
|
# fmtlib
|
||||||
set(fmt_DIR ${CMAKE_CURRENT_SOURCE_DIR}/fmt)
|
add_subdirectory(fmt EXCLUDE_FROM_ALL)
|
||||||
add_subdirectory(${fmt_DIR})
|
|
||||||
|
|
||||||
#=================== SPD ====================
|
# MagicEnum
|
||||||
|
add_subdirectory(magic_enum EXCLUDE_FROM_ALL)
|
||||||
|
|
||||||
|
# Spdlog
|
||||||
set(SPDLOG_WCHAR_FILENAMES ON CACHE BOOL "")
|
set(SPDLOG_WCHAR_FILENAMES ON CACHE BOOL "")
|
||||||
set(SPDLOG_NO_THREAD_ID ON CACHE BOOL "")
|
set(SPDLOG_NO_THREAD_ID ON CACHE BOOL "")
|
||||||
set(SPDLOG_FMT_EXTERNAL ON CACHE BOOL "")
|
set(SPDLOG_FMT_EXTERNAL ON CACHE BOOL "")
|
||||||
add_subdirectory(spdlog EXCLUDE_FROM_ALL)
|
add_subdirectory(spdlog EXCLUDE_FROM_ALL)
|
||||||
add_library(stb INTERFACE)
|
add_library(stb INTERFACE)
|
||||||
target_include_directories(stb INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/stb")
|
target_include_directories(stb INTERFACE ./stb)
|
||||||
|
|
||||||
#=================== SDL3 ===================
|
# SDL3
|
||||||
|
add_subdirectory(SDL EXCLUDE_FROM_ALL)
|
||||||
|
|
||||||
set(SDL3_DIR ${CMAKE_CURRENT_SOURCE_DIR}/SDL)
|
# Toml11
|
||||||
add_subdirectory(${SDL3_DIR})
|
add_subdirectory(toml11 EXCLUDE_FROM_ALL)
|
||||||
|
|
||||||
#================ Zydis ========================
|
# Vulkan
|
||||||
# Register Zydis dependency.
|
add_subdirectory(vulkan EXCLUDE_FROM_ALL)
|
||||||
# Disable build of tools and examples.
|
target_include_directories(vulkan-1 INTERFACE vulkan/include)
|
||||||
|
|
||||||
|
# Winpthreads
|
||||||
|
if (WIN32)
|
||||||
|
add_subdirectory(winpthread EXCLUDE_FROM_ALL)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# xxHash
|
||||||
|
add_library(xxhash INTERFACE)
|
||||||
|
target_include_directories(xxhash INTERFACE xxhash)
|
||||||
|
|
||||||
|
# Zydis
|
||||||
option(ZYDIS_BUILD_TOOLS "" OFF)
|
option(ZYDIS_BUILD_TOOLS "" OFF)
|
||||||
option(ZYDIS_BUILD_EXAMPLES "" OFF)
|
option(ZYDIS_BUILD_EXAMPLES "" OFF)
|
||||||
set(zydis_DIR ${CMAKE_CURRENT_SOURCE_DIR}/zydis)
|
add_subdirectory(zydis EXCLUDE_FROM_ALL)
|
||||||
add_subdirectory(${zydis_DIR})
|
|
||||||
|
|
||||||
#========== winpthreads ======================
|
# Imgui
|
||||||
add_subdirectory(winpthread)
|
add_library(imgui STATIC)
|
||||||
#=================== discord-rpc ===================
|
|
||||||
add_subdirectory(discord-rpc)
|
|
||||||
#=================== toml11 ===================
|
|
||||||
add_subdirectory(toml11)
|
|
||||||
#=================== vulkan ==================
|
|
||||||
add_subdirectory(vulkan)
|
|
||||||
#=================== IMGUI ===================
|
|
||||||
|
|
||||||
set(IMGUI_DIR ${CMAKE_CURRENT_SOURCE_DIR}/imgui)
|
target_sources(imgui PRIVATE
|
||||||
add_library(IMGUI STATIC)
|
imgui/imgui_demo.cpp
|
||||||
|
imgui/imgui_draw.cpp
|
||||||
|
imgui/imgui_tables.cpp
|
||||||
target_sources( IMGUI
|
imgui/imgui_widgets.cpp
|
||||||
PRIVATE
|
imgui/imgui.cpp
|
||||||
${IMGUI_DIR}/imgui_demo.cpp
|
imgui/backends/imgui_impl_opengl3.cpp
|
||||||
${IMGUI_DIR}/imgui_draw.cpp
|
imgui/backends/imgui_impl_sdl3.cpp
|
||||||
${IMGUI_DIR}/imgui_tables.cpp
|
)
|
||||||
${IMGUI_DIR}/imgui_widgets.cpp
|
|
||||||
${IMGUI_DIR}/imgui.cpp
|
target_include_directories(imgui PUBLIC
|
||||||
|
imgui
|
||||||
PRIVATE
|
imgui/backends
|
||||||
${IMGUI_DIR}/backends/imgui_impl_opengl3.cpp
|
imgui/include
|
||||||
${IMGUI_DIR}/backends/imgui_impl_sdl3.cpp
|
)
|
||||||
)
|
|
||||||
|
target_link_libraries(imgui PRIVATE SDL3-shared ${CMAKE_DL_LIBS} Zydis winpthread discord-rpc)
|
||||||
target_include_directories( IMGUI
|
|
||||||
PUBLIC ${IMGUI_DIR}
|
|
||||||
PUBLIC ${IMGUI_DIR}/backends
|
|
||||||
PUBLIC ${SDL3_DIR}/include
|
|
||||||
)
|
|
||||||
|
|
||||||
find_package(OpenGL REQUIRED)
|
|
||||||
target_link_libraries(IMGUI PUBLIC ${OPENGL_LIBRARIES})
|
|
||||||
|
|
||||||
|
|
||||||
target_link_libraries(IMGUI PUBLIC SDL3-shared ${CMAKE_DL_LIBS} Zydis winpthread discord-rpc)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue