mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-09 07:35:41 +12:00
Refactor build targets into AlberCore
(#455)
* Ignore `.cache` folder * Add `AlberCore` build-target Separate the AlberCore from its frontends. Allowing two front-ends to interface with the same core implementation. This also allows for the core to interface better with unit-testing. * Modularize SDL/Qt frontend Separates all QT/SDL build files and options into the frontend-build-target * Fix optional OpenGL enablement Software renderer requires OpenGL, so AlberCore requries OpenGL. The QT frontend currently requires OpenGL due to `ScreenWidget` * Fix Android build * Fix LTO linking * Fix windows build `LoadLibrary` is a preprocessor that will use either `LoadLibraryW` or `LoadLibraryA` depending on if `UNICODE` is defined or not. In this case we are using an ASCII string literal and and can explicitly specify the usage of `LoadLibraryA` with an ASCII literal. * Bonk * Bonk --------- Co-authored-by: wheremyfoodat <44909372+wheremyfoodat@users.noreply.github.com>
This commit is contained in:
parent
57193e7944
commit
929019e76b
3 changed files with 178 additions and 167 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -19,7 +19,7 @@ build/
|
||||||
|
|
||||||
.vs/
|
.vs/
|
||||||
.vscode/*.log
|
.vscode/*.log
|
||||||
|
.cache/
|
||||||
ipch/
|
ipch/
|
||||||
*.aps
|
*.aps
|
||||||
*.ncb
|
*.ncb
|
||||||
|
|
123
CMakeLists.txt
123
CMakeLists.txt
|
@ -72,11 +72,9 @@ endif()
|
||||||
|
|
||||||
if(ENABLE_QT_GUI)
|
if(ENABLE_QT_GUI)
|
||||||
find_package(Qt6 REQUIRED COMPONENTS Widgets)
|
find_package(Qt6 REQUIRED COMPONENTS Widgets)
|
||||||
|
if(NOT ENABLE_OPENGL)
|
||||||
# We can't use qt_standard_project_setup since it's Qt 6.3+ and we don't need to set the minimum that high
|
message(FATAL_ERROR "Qt frontend requires OpenGL")
|
||||||
set(CMAKE_AUTOMOC ON)
|
endif()
|
||||||
set(CMAKE_AUTORCC ON)
|
|
||||||
set(CMAKE_AUTOUIC ON)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(SDL_STATIC ON CACHE BOOL "" FORCE)
|
set(SDL_STATIC ON CACHE BOOL "" FORCE)
|
||||||
|
@ -199,8 +197,7 @@ set(AUDIO_SOURCE_FILES src/core/audio/dsp_core.cpp src/core/audio/null_core.cpp
|
||||||
set(RENDERER_SW_SOURCE_FILES src/core/renderer_sw/renderer_sw.cpp)
|
set(RENDERER_SW_SOURCE_FILES src/core/renderer_sw/renderer_sw.cpp)
|
||||||
|
|
||||||
# Frontend source files
|
# Frontend source files
|
||||||
if(NOT ANDROID)
|
if(ENABLE_QT_GUI)
|
||||||
if(ENABLE_QT_GUI)
|
|
||||||
set(FRONTEND_SOURCE_FILES src/panda_qt/main.cpp src/panda_qt/screen.cpp src/panda_qt/main_window.cpp src/panda_qt/about_window.cpp
|
set(FRONTEND_SOURCE_FILES src/panda_qt/main.cpp src/panda_qt/screen.cpp src/panda_qt/main_window.cpp src/panda_qt/about_window.cpp
|
||||||
src/panda_qt/config_window.cpp src/panda_qt/zep.cpp src/panda_qt/text_editor.cpp src/panda_qt/cheats_window.cpp
|
src/panda_qt/config_window.cpp src/panda_qt/zep.cpp src/panda_qt/text_editor.cpp src/panda_qt/cheats_window.cpp
|
||||||
)
|
)
|
||||||
|
@ -215,10 +212,9 @@ if(NOT ANDROID)
|
||||||
include_directories(third_party/zep/include) # Include zep for text editor usage
|
include_directories(third_party/zep/include) # Include zep for text editor usage
|
||||||
configure_file(third_party/zep/cmake/config_app.h.cmake ${CMAKE_BINARY_DIR}/zep_config/config_app.h)
|
configure_file(third_party/zep/cmake/config_app.h.cmake ${CMAKE_BINARY_DIR}/zep_config/config_app.h)
|
||||||
include_directories(${CMAKE_BINARY_DIR}/zep_config)
|
include_directories(${CMAKE_BINARY_DIR}/zep_config)
|
||||||
else()
|
else()
|
||||||
set(FRONTEND_SOURCE_FILES src/panda_sdl/main.cpp src/panda_sdl/frontend_sdl.cpp)
|
set(FRONTEND_SOURCE_FILES src/panda_sdl/main.cpp src/panda_sdl/frontend_sdl.cpp)
|
||||||
set(FRONTEND_HEADER_FILES "")
|
set(FRONTEND_HEADER_FILES "")
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(HEADER_FILES include/emulator.hpp include/helpers.hpp include/termcolor.hpp
|
set(HEADER_FILES include/emulator.hpp include/helpers.hpp include/termcolor.hpp
|
||||||
|
@ -403,10 +399,14 @@ if(ENABLE_VULKAN)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
source_group("Header Files\\Core" FILES ${HEADER_FILES})
|
source_group("Header Files\\Core" FILES ${HEADER_FILES})
|
||||||
set(ALL_SOURCES ${SOURCE_FILES} ${FRONTEND_SOURCE_FILES} ${FS_SOURCE_FILES} ${CRYPTO_SOURCE_FILES} ${KERNEL_SOURCE_FILES}
|
set(ALL_SOURCES ${SOURCE_FILES} ${FS_SOURCE_FILES} ${CRYPTO_SOURCE_FILES} ${KERNEL_SOURCE_FILES}
|
||||||
${LOADER_SOURCE_FILES} ${SERVICE_SOURCE_FILES} ${APPLET_SOURCE_FILES} ${RENDERER_SW_SOURCE_FILES} ${PICA_SOURCE_FILES} ${THIRD_PARTY_SOURCE_FILES}
|
${LOADER_SOURCE_FILES} ${SERVICE_SOURCE_FILES} ${APPLET_SOURCE_FILES} ${RENDERER_SW_SOURCE_FILES} ${PICA_SOURCE_FILES} ${THIRD_PARTY_SOURCE_FILES}
|
||||||
${AUDIO_SOURCE_FILES} ${HEADER_FILES} ${FRONTEND_HEADER_FILES})
|
${AUDIO_SOURCE_FILES} ${HEADER_FILES} ${FRONTEND_HEADER_FILES})
|
||||||
|
|
||||||
|
if(ANDROID)
|
||||||
|
set(ALL_SOURCES ${ALL_SOURCES} src/jni_driver.cpp)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(ENABLE_OPENGL)
|
if(ENABLE_OPENGL)
|
||||||
# Add the OpenGL source files to ALL_SOURCES
|
# Add the OpenGL source files to ALL_SOURCES
|
||||||
set(ALL_SOURCES ${ALL_SOURCES} ${RENDERER_GL_SOURCE_FILES})
|
set(ALL_SOURCES ${ALL_SOURCES} ${RENDERER_GL_SOURCE_FILES})
|
||||||
|
@ -417,64 +417,82 @@ if(ENABLE_VULKAN)
|
||||||
set(ALL_SOURCES ${ALL_SOURCES} ${RENDERER_VK_SOURCE_FILES})
|
set(ALL_SOURCES ${ALL_SOURCES} ${RENDERER_VK_SOURCE_FILES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ANDROID)
|
add_library(AlberCore STATIC ${ALL_SOURCES})
|
||||||
set(ALL_SOURCES ${ALL_SOURCES} src/jni_driver.cpp)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(BUILD_HYDRA_CORE)
|
|
||||||
include_directories(third_party/hydra_core/include)
|
|
||||||
add_library(Alber SHARED ${ALL_SOURCES} src/hydra_core.cpp)
|
|
||||||
target_compile_definitions(Alber PRIVATE PANDA3DS_HYDRA_CORE=1)
|
|
||||||
else()
|
|
||||||
add_executable(Alber ${ALL_SOURCES})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(ANDROID)
|
if(ANDROID)
|
||||||
target_link_libraries(Alber PRIVATE EGL log)
|
target_link_libraries(AlberCore PRIVATE EGL log)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENABLE_LTO OR ENABLE_USER_BUILD)
|
target_link_libraries(AlberCore PRIVATE dynarmic cryptopp glad resources_console_fonts teakra)
|
||||||
set_target_properties(Alber PROPERTIES INTERPROCEDURAL_OPTIMIZATION TRUE)
|
target_link_libraries(AlberCore PUBLIC glad)
|
||||||
endif()
|
|
||||||
|
|
||||||
target_link_libraries(Alber PRIVATE dynarmic cryptopp glad resources_console_fonts teakra)
|
|
||||||
|
|
||||||
if(NOT ANDROID)
|
if(NOT ANDROID)
|
||||||
target_link_libraries(Alber PRIVATE SDL2-static)
|
target_link_libraries(AlberCore PUBLIC SDL2-static)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENABLE_DISCORD_RPC AND NOT ANDROID)
|
if(ENABLE_DISCORD_RPC AND NOT ANDROID)
|
||||||
target_compile_definitions(Alber PUBLIC "PANDA3DS_ENABLE_DISCORD_RPC=1")
|
target_compile_definitions(AlberCore PUBLIC "PANDA3DS_ENABLE_DISCORD_RPC=1")
|
||||||
target_link_libraries(Alber PRIVATE discord-rpc)
|
target_link_libraries(AlberCore PRIVATE discord-rpc)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENABLE_LUAJIT)
|
if(ENABLE_LUAJIT)
|
||||||
target_compile_definitions(Alber PUBLIC "PANDA3DS_ENABLE_LUA=1")
|
target_compile_definitions(AlberCore PUBLIC "PANDA3DS_ENABLE_LUA=1")
|
||||||
target_link_libraries(Alber PRIVATE libluajit)
|
target_link_libraries(AlberCore PRIVATE libluajit)
|
||||||
|
|
||||||
# If we're not on Android, link libuv too
|
# If we're not on Android, link libuv too
|
||||||
if (NOT ANDROID)
|
if (NOT ANDROID)
|
||||||
target_link_libraries(Alber PRIVATE uv_a)
|
target_link_libraries(AlberCore PRIVATE uv_a)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENABLE_OPENGL)
|
if(ENABLE_OPENGL)
|
||||||
target_compile_definitions(Alber PUBLIC "PANDA3DS_ENABLE_OPENGL=1")
|
target_compile_definitions(AlberCore PUBLIC "PANDA3DS_ENABLE_OPENGL=1")
|
||||||
target_link_libraries(Alber PRIVATE resources_renderer_gl)
|
target_link_libraries(AlberCore PRIVATE resources_renderer_gl)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENABLE_VULKAN)
|
if(ENABLE_VULKAN)
|
||||||
target_compile_definitions(Alber PUBLIC "PANDA3DS_ENABLE_VULKAN=1")
|
target_compile_definitions(AlberCore PUBLIC "PANDA3DS_ENABLE_VULKAN=1")
|
||||||
target_link_libraries(Alber PRIVATE Vulkan::Vulkan resources_renderer_vk)
|
target_link_libraries(AlberCore PRIVATE Vulkan::Vulkan resources_renderer_vk)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(GPU_DEBUG_INFO)
|
||||||
|
target_compile_definitions(AlberCore PRIVATE GPU_DEBUG_INFO=1)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_USER_BUILD)
|
||||||
|
target_compile_definitions(AlberCore PRIVATE PANDA3DS_USER_BUILD=1)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_USER_BUILD OR DISABLE_PANIC_DEV)
|
||||||
|
target_compile_definitions(AlberCore PRIVATE PANDA3DS_LIMITED_PANICS=1)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_HTTP_SERVER)
|
||||||
|
target_compile_definitions(AlberCore PRIVATE PANDA3DS_ENABLE_HTTP_SERVER=1)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Configure frontend
|
||||||
|
|
||||||
if(ENABLE_QT_GUI)
|
if(ENABLE_QT_GUI)
|
||||||
target_compile_definitions(Alber PUBLIC "PANDA3DS_FRONTEND_QT=1")
|
target_compile_definitions(AlberCore PUBLIC "PANDA3DS_FRONTEND_QT=1")
|
||||||
|
else()
|
||||||
|
target_compile_definitions(AlberCore PUBLIC "PANDA3DS_FRONTEND_SDL=1")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT BUILD_HYDRA_CORE)
|
||||||
|
add_executable(Alber ${FRONTEND_SOURCE_FILES} ${FRONTEND_HEADER_FILES})
|
||||||
|
target_link_libraries(Alber PRIVATE AlberCore)
|
||||||
|
|
||||||
|
if(ENABLE_QT_GUI)
|
||||||
target_compile_definitions(Alber PUBLIC "ZEP_QT=1")
|
target_compile_definitions(Alber PUBLIC "ZEP_QT=1")
|
||||||
target_compile_definitions(Alber PUBLIC "ZEP_FEATURE_CPP_FILE_SYSTEM=1")
|
target_compile_definitions(Alber PUBLIC "ZEP_FEATURE_CPP_FILE_SYSTEM=1")
|
||||||
|
|
||||||
target_link_libraries(Alber PRIVATE Qt6::Widgets)
|
target_link_libraries(Alber PRIVATE Qt6::Widgets)
|
||||||
|
|
||||||
|
# We can't use qt_standard_project_setup since it's Qt 6.3+ and we don't need to set the minimum that high
|
||||||
|
set_target_properties(Alber PROPERTIES AUTOMOC ON)
|
||||||
|
set_target_properties(Alber PROPERTIES AUTORCC ON)
|
||||||
|
set_target_properties(Alber PROPERTIES AUTOUIC ON)
|
||||||
|
|
||||||
if(LINUX OR FREEBSD)
|
if(LINUX OR FREEBSD)
|
||||||
find_package(X11 REQUIRED)
|
find_package(X11 REQUIRED)
|
||||||
target_link_libraries(Alber PRIVATE ${X11_LIBRARIES})
|
target_link_libraries(Alber PRIVATE ${X11_LIBRARIES})
|
||||||
|
@ -485,27 +503,20 @@ if(ENABLE_QT_GUI)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
qt_add_resources(Alber "app_images"
|
qt_add_resources(AlberCore "app_images"
|
||||||
PREFIX "/"
|
PREFIX "/"
|
||||||
FILES
|
FILES
|
||||||
docs/img/rsob_icon.png docs/img/rstarstruck_icon.png
|
docs/img/rsob_icon.png docs/img/rstarstruck_icon.png
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
target_compile_definitions(Alber PUBLIC "PANDA3DS_FRONTEND_SDL=1")
|
endif()
|
||||||
|
elseif(BUILD_HYDRA_CORE)
|
||||||
|
target_compile_definitions(AlberCore PRIVATE PANDA3DS_HYDRA_CORE=1)
|
||||||
|
include_directories(third_party/hydra_core/include)
|
||||||
|
add_library(Alber SHARED src/hydra_core.cpp)
|
||||||
|
target_link_libraries(Alber PUBLIC AlberCore)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(GPU_DEBUG_INFO)
|
if(ENABLE_LTO OR ENABLE_USER_BUILD)
|
||||||
target_compile_definitions(Alber PRIVATE GPU_DEBUG_INFO=1)
|
set_target_properties(Alber PROPERTIES INTERPROCEDURAL_OPTIMIZATION TRUE)
|
||||||
endif()
|
|
||||||
|
|
||||||
if(ENABLE_USER_BUILD)
|
|
||||||
target_compile_definitions(Alber PRIVATE PANDA3DS_USER_BUILD=1)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(ENABLE_USER_BUILD OR DISABLE_PANIC_DEV)
|
|
||||||
target_compile_definitions(Alber PRIVATE PANDA3DS_LIMITED_PANICS=1)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(ENABLE_HTTP_SERVER)
|
|
||||||
target_compile_definitions(Alber PRIVATE PANDA3DS_ENABLE_HTTP_SERVER=1)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
2
third_party/duckstation/window_info.cpp
vendored
2
third_party/duckstation/window_info.cpp
vendored
|
@ -16,7 +16,7 @@ static bool GetRefreshRateFromDWM(HWND hwnd, float* refresh_rate)
|
||||||
if (!load_tried)
|
if (!load_tried)
|
||||||
{
|
{
|
||||||
load_tried = true;
|
load_tried = true;
|
||||||
dwm_module = LoadLibrary(L"dwmapi.dll");
|
dwm_module = LoadLibraryA("dwmapi.dll");
|
||||||
if (dwm_module)
|
if (dwm_module)
|
||||||
{
|
{
|
||||||
std::atexit([]() {
|
std::atexit([]() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue