diff --git a/CMakeLists.txt b/CMakeLists.txt index 9666005d..82599f2a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,21 +1,30 @@ cmake_minimum_required(VERSION 3.21.1) option(PUBLIC_RELEASE "Compile with debug asserts disabled and no console" OFF) +option(ENABLE_VCPKG "Enable the vcpkg package manager" ON) if (PUBLIC_RELEASE) add_definitions(-DPUBLIC_RELEASE) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) # enable LTO endif() -if (WIN32) - set(VCPKG_TARGET_TRIPLET "x64-windows-static" CACHE STRING "") +if (ENABLE_VCPKG) + set(VCPKG_OVERLAY_PORTS "${CMAKE_CURRENT_LIST_DIR}/dependencies/vcpkg_overlay_ports") + set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/vcpkg/scripts/buildsystems/vcpkg.cmake" + CACHE STRING "Vcpkg toolchain file") + # Set this so that all the various find_package() calls don't need an explicit + # CONFIG option + set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE) + if (WIN32) + set(VCPKG_TARGET_TRIPLET "x64-windows-static" CACHE STRING "") + endif() endif() -set(VCPKG_OVERLAY_PORTS "${CMAKE_CURRENT_LIST_DIR}/dependencies/vcpkg_overlay_ports") -set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/vcpkg/scripts/buildsystems/vcpkg.cmake" - CACHE STRING "Vcpkg toolchain file") project(Cemu VERSION 0.1) + +list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") + set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -58,16 +67,31 @@ option(ENABLE_CUBEB "Enabled cubeb backend" ON) option(ENABLE_WXWIDGETS "Build with wxWidgets UI (Currently required)" ON) -find_package(SDL2 CONFIG REQUIRED) -find_package(CURL CONFIG REQUIRED) -find_package(pugixml CONFIG REQUIRED) -find_package(imgui CONFIG REQUIRED) -find_package(RapidJSON CONFIG REQUIRED) +set(THREADS_PREFER_PTHREAD_FLAG true) +find_package(Threads REQUIRED) +find_package(SDL2 REQUIRED) +find_package(CURL REQUIRED) +find_package(pugixml REQUIRED) +find_package(imgui REQUIRED) +find_package(RapidJSON REQUIRED) find_package(Boost COMPONENTS program_options filesystem nowide REQUIRED) find_package(libzip REQUIRED) find_package(glslang REQUIRED) find_package(ZLIB REQUIRED) -find_package(zstd CONFIG REQUIRED) +find_package(zstd MODULE REQUIRED) # MODULE so that zstd::zstd is available +find_package(OpenSSL COMPONENTS Crypto SSL REQUIRED) +find_package(glm REQUIRED) +find_package(fmt 7.0.0 REQUIRED) +find_package(PNG REQUIRED) + +# glslang versions older than 11.11.0 define targets without a namespace +if (NOT TARGET glslang::SPIRV AND TARGET SPIRV) + add_library(glslang::SPIRV ALIAS SPIRV) +endif() + +if (UNIX) + find_package(X11 REQUIRED) +endif() if (ENABLE_VULKAN) include_directories("dependencies/Vulkan-Headers/include") @@ -84,32 +108,28 @@ if (ENABLE_DISCORD_RPC) endif() if (ENABLE_WXWIDGETS) - find_package(wxWidgets CONFIG REQUIRED) -endif() - -find_package(OpenSSL REQUIRED) -find_package(X11) - -# find a better way to handle this -link_libraries(${Boost_LIBRARIES}) -link_libraries(${X11_LIBRARIES}) -link_libraries(SDL2::SDL2 SDL2::SDL2main SDL2::SDL2-static) -if (ENABLE_WXWIDGETS) - link_libraries(wx::core wx::base) + find_package(wxWidgets 3.2 REQUIRED COMPONENTS base core gl propgrid xrc) endif() if (ENABLE_CUBEB) - option(BUILD_TESTS "" OFF) - option(BUILD_TOOLS "" OFF) - option(BUNDLE_SPEEX "" OFF) - set(USE_WINMM OFF CACHE BOOL "") - add_subdirectory(dependencies/cubeb) - set_property(TARGET cubeb PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") - link_libraries(cubeb) - add_compile_definitions(HAS_CUBEB=1) + find_package(cubeb) + if (NOT cubeb_FOUND) + option(BUILD_TESTS "" OFF) + option(BUILD_TOOLS "" OFF) + option(BUNDLE_SPEEX "" OFF) + set(USE_WINMM OFF CACHE BOOL "") + add_subdirectory("dependencies/cubeb") + set_property(TARGET cubeb PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + add_library(cubeb::cubeb ALIAS cubeb) + endif() + add_compile_definitions("HAS_CUBEB=1") endif() -add_subdirectory(dependencies/ih264d) -add_subdirectory(dependencies/ZArchive) +add_subdirectory("dependencies/ih264d") -add_subdirectory(src) \ No newline at end of file +find_package(ZArchive) +if (NOT ZArchive_FOUND) + add_subdirectory("dependencies/ZArchive") +endif() + +add_subdirectory(src) diff --git a/cmake/FindZArchive.cmake b/cmake/FindZArchive.cmake new file mode 100644 index 00000000..0c4b7714 --- /dev/null +++ b/cmake/FindZArchive.cmake @@ -0,0 +1,20 @@ +# SPDX-FileCopyrightText: 2022 Andrea Pappacoda +# SPDX-License-Identifier: ISC + +find_package(PkgConfig) + +if (PKG_CONFIG_FOUND) + pkg_search_module(zarchive IMPORTED_TARGET GLOBAL zarchive) + if (zarchive_FOUND) + add_library(ZArchive::zarchive ALIAS PkgConfig::zarchive) + endif() +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(ZArchive + REQUIRED_VARS + zarchive_LINK_LIBRARIES + zarchive_FOUND + VERSION_VAR + zarchive_VERSION +) diff --git a/cmake/Findimgui.cmake b/cmake/Findimgui.cmake new file mode 100644 index 00000000..269297a1 --- /dev/null +++ b/cmake/Findimgui.cmake @@ -0,0 +1,27 @@ +# SPDX-FileCopyrightText: 2022 Andrea Pappacoda +# SPDX-License-Identifier: ISC + +include(FindPackageHandleStandardArgs) + +find_package(imgui CONFIG) +if (imgui_FOUND) + # Use upstream imguiConfig.cmake if possible + find_package_handle_standard_args(imgui CONFIG_MODE) +else() + # Fallback to pkg-config otherwise + find_package(PkgConfig) + if (PKG_CONFIG_FOUND) + pkg_search_module(imgui IMPORTED_TARGET GLOBAL imgui) + if (imgui_FOUND) + add_library(imgui::imgui ALIAS PkgConfig::imgui) + endif() + endif() + + find_package_handle_standard_args(imgui + REQUIRED_VARS + imgui_LINK_LIBRARIES + imgui_FOUND + VERSION_VAR + imgui_VERSION + ) +endif() diff --git a/cmake/FindwxWidgets.cmake b/cmake/FindwxWidgets.cmake new file mode 100644 index 00000000..46abca0e --- /dev/null +++ b/cmake/FindwxWidgets.cmake @@ -0,0 +1,49 @@ +# SPDX-FileCopyrightText: 2022 Andrea Pappacoda +# SPDX-License-Identifier: ISC + +include(FindPackageHandleStandardArgs) +find_package(wxWidgets CONFIG COMPONENTS ${wxWidgets_FIND_COMPONENTS}) + +if (wxWidgets_FOUND) + # Use upstream wxWidgetsConfig.cmake if possible + find_package_handle_standard_args(wxWidgets CONFIG_MODE) +else() + # Fall back to CMake's FindwxWidgets + # Temporarily unset CMAKE_MODULE_PATH to avoid calling the current find + # module recursively + set(_tmp_module_path "${CMAKE_MODULE_PATH}") + set(CMAKE_MODULE_PATH "") + + find_package(wxWidgets MODULE QUIET COMPONENTS ${wxWidgets_FIND_COMPONENTS}) + + set(CMAKE_MODULE_PATH "${_tmp_module_path}") + unset(_tmp_module_path) + + if (wxWidgets_FOUND) + add_library(wx::base IMPORTED INTERFACE) + target_include_directories(wx::base INTERFACE ${wxWidgets_INCLUDE_DIRS}) + target_link_libraries(wx::base INTERFACE ${wxWidgets_LIBRARIES}) + target_link_directories(wx::base INTERFACE ${wxWidgets_LIBRARY_DIRS}) + target_compile_definitions(wx::base INTERFACE ${wxWidgets_DEFINITIONS}) + target_compile_options(wx::base INTERFACE ${wxWidgets_CXX_FLAGS}) + + # FindwxWidgets sets everything into a single set of variables, so it is + # impossible to tell what libraries are required for what component. + # To be compatible with wxWidgetsConfig, we create an alias for each + # component so that the user can still use target_link_libraries(wx::gl) + foreach(component ${wxWidgets_FIND_COMPONENTS}) + if (NOT component STREQUAL "base") + # don't alias base to itself + add_library(wx::${component} ALIAS wx::base) + endif() + endforeach() + endif() + + find_package_handle_standard_args(wxWidgets + REQUIRED_VARS + wxWidgets_LIBRARIES + wxWidgets_FOUND + VERSION_VAR + wxWidgets_VERSION_STRING + ) +endif() diff --git a/cmake/Findzstd.cmake b/cmake/Findzstd.cmake new file mode 100644 index 00000000..a8a45a67 --- /dev/null +++ b/cmake/Findzstd.cmake @@ -0,0 +1,33 @@ +# SPDX-FileCopyrightText: 2022 Andrea Pappacoda +# SPDX-License-Identifier: ISC + +include(FindPackageHandleStandardArgs) + +find_package(zstd CONFIG) +if (zstd_FOUND) + # Use upstream zstdConfig.cmake if possible + if (NOT TARGET zstd::zstd) + if (TARGET zstd::libzstd_static) + add_library(zstd::zstd ALIAS zstd::libzstd_static) + elseif (TARGET zstd::libzstd_shared) + add_library(zstd::zstd ALIAS zstd::libzstd_shared) + endif() + endif() + find_package_handle_standard_args(zstd CONFIG_MODE) +else() + # Fallback to pkg-config otherwise + find_package(PkgConfig) + if (PKG_CONFIG_FOUND) + pkg_search_module(libzstd IMPORTED_TARGET GLOBAL libzstd) + if (libzstd_FOUND) + add_library(zstd::zstd ALIAS PkgConfig::libzstd) + endif() + endif() + + find_package_handle_standard_args(zstd + REQUIRED_VARS + libzstd_LINK_LIBRARIES + libzstd_FOUND + VERSION_VAR libzstd_VERSION + ) +endif() diff --git a/dependencies/discord-rpc/src/CMakeLists.txt b/dependencies/discord-rpc/src/CMakeLists.txt index 2eeacf48..afd8902d 100644 --- a/dependencies/discord-rpc/src/CMakeLists.txt +++ b/dependencies/discord-rpc/src/CMakeLists.txt @@ -98,8 +98,7 @@ if(UNIX) endif (APPLE) endif(UNIX) -target_link_libraries(discord-rpc PRIVATE rapidjson) -#target_include_directories(discord-rpc PRIVATE ${RAPIDJSON}/include) +target_include_directories(discord-rpc PRIVATE ${RAPIDJSON_INCLUDE_DIRS}) if (NOT ${ENABLE_IO_THREAD}) target_compile_definitions(discord-rpc PUBLIC -DDISCORD_DISABLE_IO_THREAD) diff --git a/dist/linux/info.cemu.Cemu.desktop b/dist/linux/info.cemu.Cemu.desktop index 90e869f1..74fd48a8 100644 --- a/dist/linux/info.cemu.Cemu.desktop +++ b/dist/linux/info.cemu.Cemu.desktop @@ -4,11 +4,14 @@ Type=Application Terminal=false Icon=info.cemu.Cemu Exec=cemu +GenericName=Wii U Emulator +GenericName[es]=Emulador de Wii U Comment=Software to emulate Wii U games and applications on PC Comment[de]=Software zum emulieren von Wii U Spielen und Anwendungen auf dem PC Comment[ru]=Программа для эмуляции игр и приложений Wii U на PC Comment[fr]=Application pour émuler des jeux et des applications Wii U sur PC Comment[nl]=Applicatie om Wii U spellen en applicaties te emuleren op PC +Comment[es]=Software para emular juegos y aplicaciones de Wii U en PC Categories=Game;Emulator; Keywords=Nintendo; MimeType=application/x-wii-u-rom; diff --git a/dist/linux/info.cemu.Cemu.metainfo.xml b/dist/linux/info.cemu.Cemu.metainfo.xml index db2cde03..bfea493e 100644 --- a/dist/linux/info.cemu.Cemu.metainfo.xml +++ b/dist/linux/info.cemu.Cemu.metainfo.xml @@ -7,6 +7,7 @@ Software zum emulieren von Wii U Spielen und Anwendungen auf dem PC Application pour émuler des jeux et applications Wii U sur PC Applicatie om Wii U spellen en applicaties te emuleren op PC + Software para emular juegos y aplicaciones de Wii U en PC Cemu Project info.cemu.Cemu.desktop CC0-1.0 @@ -16,14 +17,17 @@

Cemu ist ein Nintendo Wii U-Emulator, der die meisten Wii U Spiele und Homebrew in einem spielbaren Zustand ausführen kann. Erstellt von Exzap, und geschrieben in C/C++.

Cemu est un émulateur de Wii U capable de lancer la plupart des jeux Wii U et des homebrews en interface de jeu. Crée par Exzap, et développé en C/C++.

Cemu is een Nintendo Wii U emulator die de meeste Wii U en Homebrew games speelbaar kan runnen. Het project is begonnen door Exzap, en het is geschreven in C/C++.

+

Cemu es un emulador de Nintendo Wii U que es capaz de ejecutar la mayoría de los juegos de Wii U y homebrew en un estado jugable. Creado por Exzap, y escrito en C y C++.

This emulator aims at providing both high-accuracy and performance, and is actively being developed with new features and fixes to increase compatibility, convenience and usability.

Dieser Emulator zielt darauf ab, sowohl hohe Genauigkeit als auch Leistung zu bieten, und wird aktiv mit neuen Funktionen und Korrekturen weiterentwickelt, um Kompatibilität, Komfort und Benutzerfreundlichkeit zu verbessern.

Cet émulateur vise à la fois à offrir fidélité et performance, il est activement développé avec des nouvelles fonctionnalités et des correctifs pour augmenter la compatibilité, la commodité et la facilité d'utilisation.

De emulator richt zich op integriteit en snelheid, en wordt continu verder ontwikkeld met nieuwe toevoegingen en fixes om de compatibiliteit, het gemak en de gebruiksvriendelijkheid te verbeteren.

+

Este emulador tiene como objetivo proporcionar tanto alta precisión como rendimiento y se desarrolla activamente con nuevas características y correcciones para mejorar la compatibilidad, la comodidad y la usabilidad.

It was written from scratch and development on the project began roughly early 2015.

Er wird seit Anfang 2015 entwickelt.

Il a été écrit à partir de zéro et son développement a débuté vers le début de l'année 2015.

Ontwikkeling van Cemu begon ongeveer in het voorjaar van 2015.

+

Fue escrito desde cero y el desarrollo del proyecto comenzó aproximadamente a principios de 2015.

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fd2c4add..e903db4c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -79,18 +79,21 @@ set_target_properties(CemuBin PROPERTIES OUTPUT_NAME "Cemu" ) -target_link_libraries(CemuBin PRIVATE CemuCommon CemuComponents CemuCafe CemuConfig CemuGui CemuAudio CemuInput CemuUtil) +target_link_libraries(CemuBin PRIVATE + CemuAudio + CemuCafe + CemuCommon + CemuComponents + CemuConfig + CemuGui + CemuInput + CemuUtil +) + target_link_libraries(CemuBin PRIVATE CemuAsm) -target_link_libraries(CemuBin PRIVATE OpenSSL::SSL) -target_link_libraries(CemuBin PRIVATE ZLIB::ZLIB) -target_link_libraries(CemuBin PRIVATE ${wxWidgets_LIBRARIES}) -target_link_libraries(CemuBin PRIVATE CURL::libcurl) -target_link_libraries(CemuBin PRIVATE imgui::imgui) -target_link_libraries(CemuBin PRIVATE pugixml pugixml::static pugixml::pugixml) +target_link_libraries(CemuBin PRIVATE SDL2::SDL2 SDL2::SDL2main) # is SDL2main needed? +target_link_libraries(CemuBin PRIVATE imguiImpl OpenGL::GL) -target_link_libraries(CemuBin PUBLIC -CemuCommon CemuAudio CemuInput CemuComponents CemuCafe CemuConfig CemuGui imguiImpl) - -# needed because of some cyclic dependencies. fix this -target_link_libraries(CemuBin PUBLIC -CemuCommon CemuInput CemuComponents CemuCafe CemuResource CemuGui CemuAsm) +if (ENABLE_WXWIDGETS) + target_link_libraries(CemuBin PRIVATE wx::base wx::core) +endif() diff --git a/src/Cafe/CMakeLists.txt b/src/Cafe/CMakeLists.txt index ae0b3e60..a4a60d0d 100644 --- a/src/Cafe/CMakeLists.txt +++ b/src/Cafe/CMakeLists.txt @@ -1,7 +1,5 @@ project(CemuCafe) -include_directories(".") - if((CMAKE_C_COMPILER_ID STREQUAL "GNU") OR (CMAKE_C_COMPILER_ID STREQUAL "Clang")) add_compile_options(-mssse3 -mavx2) endif() @@ -14,20 +12,39 @@ set_property(TARGET CemuCafe PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$ #include #if BOOST_OS_WINDOWS diff --git a/src/audio/CMakeLists.txt b/src/audio/CMakeLists.txt index 6a11033d..9217349d 100644 --- a/src/audio/CMakeLists.txt +++ b/src/audio/CMakeLists.txt @@ -34,9 +34,16 @@ endif() target_precompile_headers(CemuAudio PRIVATE ../Common/precompiled.h) -#target_link_libraries(CemuAudio CemuCommon CemuGui CemuPlatform) -target_include_directories(CemuAudio PRIVATE ../) +target_include_directories(CemuAudio PUBLIC "../") + +target_link_libraries(CemuAudio PRIVATE CemuCafe CemuConfig CemuGui CemuUtil) if(ENABLE_CUBEB) - target_link_libraries(CemuAudio cubeb) + # PUBLIC because cubeb.h/cubeb.h is included in CubebAPI.h + target_link_libraries(CemuAudio PUBLIC cubeb::cubeb) +endif() + +if (ENABLE_WXWIDGETS) + # PUBLIC because wx/wx.h is included in audioDebuggerWindow.h + target_link_libraries(CemuAudio PUBLIC wx::base wx::core) endif() diff --git a/src/config/CMakeLists.txt b/src/config/CMakeLists.txt index 4710b5c4..4aafdc04 100644 --- a/src/config/CMakeLists.txt +++ b/src/config/CMakeLists.txt @@ -8,4 +8,19 @@ set_property(TARGET CemuConfig PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") @@ -17,5 +15,14 @@ target_sources(imguiImpl PRIVATE target_precompile_headers(imguiImpl PRIVATE ../Common/precompiled.h) -target_link_libraries(CemuCommon) -target_include_directories(imguiImpl PRIVATE ../) \ No newline at end of file +target_include_directories(imguiImpl PUBLIC "../") + +target_link_libraries(imguiImpl PRIVATE + CemuCafe + CemuCommon + CemuGui + CemuInput + CemuResource + CemuUtil + imgui::imgui +) diff --git a/src/input/CMakeLists.txt b/src/input/CMakeLists.txt index cbd86a32..de79cd8b 100644 --- a/src/input/CMakeLists.txt +++ b/src/input/CMakeLists.txt @@ -1,7 +1,5 @@ project(CemuInput) -include_directories(".") - add_library(CemuInput InputManager.cpp InputManager.h @@ -95,4 +93,21 @@ endif() target_precompile_headers(CemuInput PRIVATE ../Common/precompiled.h) -target_include_directories(CemuInput PRIVATE ../) +target_include_directories(CemuInput PUBLIC "../") + +target_link_libraries(CemuInput PRIVATE + CemuCafe + CemuCommon + CemuConfig + CemuGui + CemuUtil + Boost::headers + Boost::program_options + glm::glm + pugixml::pugixml + SDL2::SDL2 +) + +if (ENABLE_WXWIDGETS) + target_link_libraries(CemuInput PRIVATE wx::base wx::core) +endif() diff --git a/src/resource/CMakeLists.txt b/src/resource/CMakeLists.txt index 85084bca..ec445061 100644 --- a/src/resource/CMakeLists.txt +++ b/src/resource/CMakeLists.txt @@ -16,4 +16,6 @@ target_sources(CemuResource PRIVATE CafeDefaultFont.cpp ) -target_include_directories(CemuResource PRIVATE ../) +target_include_directories(CemuResource PUBLIC "../") + +target_link_libraries(CemuResource PRIVATE CemuComponents) diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index d31541ff..69887fa7 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -1,7 +1,5 @@ project(CemuUtil) -include_directories(".") - file(GLOB_RECURSE CPP_FILES *.cpp) file(GLOB_RECURSE H_FILES *.h) @@ -11,5 +9,16 @@ set_property(TARGET CemuUtil PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$