Merge pull request #112 from Tachi107/build-minor-fixes

build: minor refactoring and fixes
This commit is contained in:
Exzap 2022-09-02 19:22:19 +02:00 committed by GitHub
commit 4ed38a28b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 208 additions and 235 deletions

View File

@ -4,11 +4,6 @@ option(PUBLIC_RELEASE "Compile with debug asserts disabled and no console" OFF)
option(ENABLE_VCPKG "Enable the vcpkg package manager" ON)
set(EXPERIMENTAL_VERSION "" CACHE STRING "") # used by CI script to set experimental version
if (PUBLIC_RELEASE)
add_definitions(-DPUBLIC_RELEASE)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) # enable LTO
endif()
if (EXPERIMENTAL_VERSION)
add_definitions(-DEMULATOR_VERSION_MINOR=${EXPERIMENTAL_VERSION})
endif()
@ -25,8 +20,7 @@ if (ENABLE_VCPKG)
endif()
endif()
project(Cemu VERSION 0.1)
project(Cemu VERSION 2.0)
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
@ -35,19 +29,20 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if (PUBLIC_RELEASE)
add_compile_definitions(PUBLIC_RELEASE)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) # enable LTO
endif()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
if (MSVC)
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT CemuBin)
endif()
if (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:precise") # floating point model: precise
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GT") # fiber safe optimizations
# floating point model: precise, fiber safe optimizations
add_compile_options(/EHsc /fp:precise /GT)
if (PUBLIC_RELEASE)
message(STATUS "Using additional optimization flags for MSVC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Oi /Ot") # enable intrinsic functions, favor speed
add_compile_options(/Oi /Ot) # enable intrinsic functions, favor speed
endif()
endif()
@ -59,7 +54,7 @@ option(ENABLE_DISCORD_RPC "Enables the Discord Rich Presence feature" ON)
if (WIN32)
option(ENABLE_XINPUT "Enables the usage of XInput" ON)
option(ENABLE_DIRECTINPUT "Enables the usage of DirectInput" ON)
add_definitions(-DHAS_DIRECTINPUT)
add_compile_definitions(HAS_DIRECTINPUT)
endif()
option(ENABLE_SDL "Enables the SDLController backend" ON)
@ -107,7 +102,7 @@ if (ENABLE_OPENGL)
endif()
if (ENABLE_DISCORD_RPC)
add_definitions(-DENABLE_DISCORD_RPC)
add_compile_definitions(ENABLE_DISCORD_RPC)
add_subdirectory(dependencies/discord-rpc EXCLUDE_FROM_ALL)
target_include_directories(discord-rpc INTERFACE ./dependencies/discord-rpc/include)
endif()

View File

@ -2,42 +2,43 @@ project(cemuMain)
option(CEMU_CXX_FLAGS "Additional flags used for compiling Cemu source code")
if(CEMU_CXX_FLAGS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CEMU_CXX_FLAGS}")
add_compile_options(${CEMU_CXX_FLAGS})
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
# all ok
else()
if(NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
message( FATAL_ERROR "Pointers are not 64bit" )
endif()
if(MSVC)
add_definitions(-DWIN32_LEAN_AND_MEAN)
add_definitions(-DCURL_STATICLIB)
#add_definitions(-DVK_USE_PLATFORM_WIN32_KHR)
add_compile_definitions(WIN32_LEAN_AND_MEAN CURL_STATICLIB)
#add_compile_definitions(VK_USE_PLATFORM_WIN32_KHR)
# _CRT_SECURE_NO_WARNINGS
# _WINSOCK_DEPRECATED_NO_WARNINGS
# _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING
# _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
elseif(UNIX)
if(APPLE)
add_definitions(-D_XOPEN_SOURCE)
add_definitions(-DVK_USE_PLATFORM_MACOS_MVK)
add_definitions(-DVK_USE_PLATFORM_METAL_EXT)
add_compile_definitions(
_XOPEN_SOURCE
VK_USE_PLATFORM_MACOS_MVK
VK_USE_PLATFORM_METAL_EXT
)
else()
add_definitions(-DVK_USE_PLATFORM_XLIB_KHR) # legacy. Do we need to support XLIB surfaces?
add_definitions(-DVK_USE_PLATFORM_XCB_KHR)
add_compile_definitions(
VK_USE_PLATFORM_XLIB_KHR # legacy. Do we need to support XLIB surfaces?
VK_USE_PLATFORM_XCB_KHR
)
endif()
add_definitions(-maes)
add_compile_options(-maes)
# warnings
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
add_compile_options(-Wno-ambiguous-reversed-operator)
endif()
add_compile_options(-Wno-multichar -Wno-invalid-offsetof -Wno-switch -Wno-ignored-attributes -Wno-deprecated-enum-enum-conversion)
endif()
add_definitions(-DVK_NO_PROTOTYPES)
add_compile_definitions(VK_NO_PROTOTYPES)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
@ -54,32 +55,29 @@ add_subdirectory(resource)
add_subdirectory(asm)
if(PUBLIC_RELEASE)
add_executable(CemuBin WIN32
main.cpp
mainLLE.cpp
)
add_executable(CemuBin WIN32
main.cpp
mainLLE.cpp
)
else()
add_executable(CemuBin
main.cpp
mainLLE.cpp
)
add_executable(CemuBin
main.cpp
mainLLE.cpp
)
endif()
target_precompile_headers(CemuBin PRIVATE Common/precompiled.h)
if(WIN32)
target_sources(CemuBin PRIVATE
resource/cemu.rc
)
)
endif()
set_property(TARGET CemuBin PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set_target_properties(CemuBin PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/../bin/
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/../bin/
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../bin/"
OUTPUT_NAME "Cemu"
)
)
target_link_libraries(CemuBin PRIVATE
CemuAudio
@ -90,12 +88,10 @@ target_link_libraries(CemuBin PRIVATE
CemuGui
CemuInput
CemuUtil
OpenGL::GL
SDL2::SDL2
)
target_link_libraries(CemuBin PRIVATE CemuAsm)
target_link_libraries(CemuBin PRIVATE SDL2::SDL2 SDL2::SDL2main) # is SDL2main needed?
target_link_libraries(CemuBin PRIVATE imguiImpl OpenGL::GL)
if (ENABLE_WXWIDGETS)
target_link_libraries(CemuBin PRIVATE wx::base wx::core)
endif()

View File

@ -12,8 +12,6 @@ endif()
set_property(TARGET CemuCafe PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
target_precompile_headers(CemuCafe PRIVATE ../Common/precompiled.h)
target_include_directories(CemuCafe PUBLIC "../")
target_link_libraries(CemuCafe PRIVATE

View File

@ -6,8 +6,6 @@ add_library(CemuComponents ${CPP_FILES} ${H_FILES})
set_property(TARGET CemuComponents PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
target_precompile_headers(CemuComponents PRIVATE ../Common/precompiled.h)
target_include_directories(CemuComponents PUBLIC "../")
target_link_libraries(CemuComponents PRIVATE
@ -28,5 +26,5 @@ target_link_libraries(CemuComponents PRIVATE
target_link_libraries(CemuComponents PUBLIC fmt::fmt)
if(ENABLE_DISCORD_RPC)
target_link_libraries(CemuComponents PRIVATE discord-rpc)
target_link_libraries(CemuComponents PRIVATE discord-rpc)
endif()

View File

@ -7,12 +7,11 @@ add_library(CemuCommon ${CPP_FILES} ${H_FILES})
set_property(TARGET CemuCommon PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
if(WIN32)
target_sources(CemuCommon
PRIVATE
target_sources(CemuCommon PRIVATE
windows/platform.cpp
windows/platform.h
ExceptionHandler/ExceptionHandler_win32.cpp
)
)
else()
target_sources(CemuCommon
PRIVATE
@ -22,11 +21,12 @@ PRIVATE
)
endif()
target_sources(CemuCommon
PRIVATE
target_sources(CemuCommon PRIVATE
ExceptionHandler/ExceptionHandler.h
)
)
# All the targets wanting to use the precompiled.h header
# have to link to CemuCommon
target_precompile_headers(CemuCommon PUBLIC precompiled.h)
target_include_directories(CemuCommon PUBLIC "../")

View File

@ -1,43 +1,39 @@
project(CemuAsm C)
IF (WIN32)
if (WIN32)
enable_language(C ASM_MASM)
enable_language(C ASM_MASM)
add_library(CemuAsm
x64util_masm.asm
)
set_source_files_properties(x64util_masm.asm PROPERTIES LANGUAGE ASM_MASM)
add_library(CemuAsm x64util_masm.asm)
set_source_files_properties(x64util_masm.asm PROPERTIES LANGUAGE ASM_MASM)
# workaround for cr flag being passed to LINK.exe which considers it an input file and thus fails
# doesn't always seem to happen. The Windows CI builds were fine, but locally I would run into this problem
# possibly related to https://gitlab.kitware.com/cmake/cmake/-/issues/18889
set(CMAKE_ASM_MASM_CREATE_STATIC_LIBRARY "<CMAKE_AR> /OUT:<TARGET> <LINK_FLAGS> <OBJECTS>")
# workaround for cr flag being passed to LINK.exe which considers it an input file and thus fails
# doesn't always seem to happen. The Windows CI builds were fine, but locally I would run into this problem
# possibly related to https://gitlab.kitware.com/cmake/cmake/-/issues/18889
set(CMAKE_ASM_MASM_CREATE_STATIC_LIBRARY "<CMAKE_AR> /OUT:<TARGET> <LINK_FLAGS> <OBJECTS>")
ELSE()
else()
# NASM
IF (APPLE)
set(CMAKE_ASM_NASM_COMPILE_OBJECT "<CMAKE_ASM_NASM_COMPILER> -g -Fdwarf -f macho64 --prefix _ -o <OBJECT> <SOURCE>")
ELSE()
set(CMAKE_ASM_NASM_COMPILE_OBJECT "<CMAKE_ASM_NASM_COMPILER> -g -Fdwarf -f elf64 -o <OBJECT> <SOURCE>")
ENDIF()
set(CMAKE_ASM_NASM_LINK_EXECUTABLE "ld <FLAGS> <CMAKE_ASM_NASM_LINK_FLAGS> <LINK_FLAGS> -fPIC <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
# NASM
if (APPLE)
set(CMAKE_ASM_NASM_COMPILE_OBJECT "<CMAKE_ASM_NASM_COMPILER> -g -Fdwarf -f macho64 --prefix _ -o <OBJECT> <SOURCE>")
else()
set(CMAKE_ASM_NASM_COMPILE_OBJECT "<CMAKE_ASM_NASM_COMPILER> -g -Fdwarf -f elf64 -o <OBJECT> <SOURCE>")
endif()
set(CMAKE_ASM_NASM_LINK_EXECUTABLE "ld <FLAGS> <CMAKE_ASM_NASM_LINK_FLAGS> <LINK_FLAGS> -fPIC <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
enable_language(C ASM_NASM)
enable_language(C ASM_NASM)
add_library(CemuAsm
x64util_nasm.asm
)
set_source_files_properties(x64util_nasm.asm PROPERTIES LANGUAGE ASM_NASM)
add_library(CemuAsm x64util_nasm.asm)
set_source_files_properties(x64util_nasm.asm PROPERTIES LANGUAGE ASM_NASM)
IF (APPLE)
set_target_properties(CemuAsm PROPERTIES NASM_OBJ_FORMAT macho64)
ELSE()
set_target_properties(CemuAsm PROPERTIES NASM_OBJ_FORMAT elf64)
ENDIF()
set_target_properties(CemuAsm PROPERTIES LINKER_LANGUAGE C)
if (APPLE)
set_target_properties(CemuAsm PROPERTIES NASM_OBJ_FORMAT macho64)
else()
set_target_properties(CemuAsm PROPERTIES NASM_OBJ_FORMAT elf64)
endif()
set_target_properties(CemuAsm PROPERTIES LINKER_LANGUAGE C)
ENDIF()
endif()
set_property(TARGET CemuAsm PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")

View File

@ -1,8 +1,8 @@
project(CemuAudio)
add_library(CemuAudio
IAudioAPI.cpp
IAudioAPI.h
IAudioAPI.cpp
IAudioAPI.h
)
set_property(TARGET CemuAudio PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
@ -29,14 +29,18 @@ if(ENABLE_CUBEB)
CubebAPI.cpp
CubebAPI.h
)
#add_definitions(HAS_CUBEB)
#add_compile_definitions(HAS_CUBEB)
endif()
target_precompile_headers(CemuAudio PRIVATE ../Common/precompiled.h)
target_include_directories(CemuAudio PUBLIC "../")
target_link_libraries(CemuAudio PRIVATE CemuCafe CemuConfig CemuGui CemuUtil)
target_link_libraries(CemuAudio PRIVATE
CemuCafe
CemuCommon
CemuConfig
CemuGui
CemuUtil
)
if(ENABLE_CUBEB)
# PUBLIC because cubeb.h/cubeb.h is included in CubebAPI.h

View File

@ -6,8 +6,6 @@ add_library(CemuConfig ${CPP_FILES} ${H_FILES})
set_property(TARGET CemuConfig PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
target_precompile_headers(CemuConfig PRIVATE ../Common/precompiled.h)
target_include_directories(CemuConfig PUBLIC "../")
target_link_libraries(CemuConfig PRIVATE

View File

@ -7,14 +7,12 @@ add_library(CemuGui ${CPP_FILES} ${H_FILES})
set_property(TARGET CemuGui PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
target_sources(CemuGui PRIVATE
wxcomponents/checkedlistctrl.cpp
wxcomponents/checkedlistctrl.h
wxcomponents/checktree.cpp
wxcomponents/checktree.h
wxcomponents/checkedlistctrl.cpp
wxcomponents/checkedlistctrl.h
wxcomponents/checktree.cpp
wxcomponents/checktree.h
)
target_precompile_headers(CemuGui PRIVATE ../Common/precompiled.h)
target_include_directories(CemuGui PUBLIC "../")
# PUBLIC because rapidjson/document.h is included in ChecksumTool.h
target_include_directories(CemuGui PUBLIC ${RAPIDJSON_INCLUDE_DIRS})

View File

@ -13,8 +13,6 @@ target_sources(imguiImpl PRIVATE
imgui_extension.h
)
target_precompile_headers(imguiImpl PRIVATE ../Common/precompiled.h)
target_include_directories(imguiImpl PUBLIC "../")
target_link_libraries(imguiImpl PRIVATE

View File

@ -1,98 +1,96 @@
project(CemuInput)
add_library(CemuInput
InputManager.cpp
InputManager.h
ControllerFactory.cpp
ControllerFactory.h
api/ControllerState.h
api/Controller.cpp
api/Controller.h
api/ControllerState.cpp
api/InputAPI.h
api/ControllerProvider.h
emulated/ProController.cpp
emulated/EmulatedController.h
emulated/EmulatedController.cpp
emulated/ProController.h
emulated/WPADController.cpp
emulated/WPADController.h
emulated/WiimoteController.h
emulated/VPADController.cpp
emulated/WiimoteController.cpp
emulated/VPADController.h
emulated/ClassicController.cpp
emulated/ClassicController.h
InputManager.cpp
InputManager.h
ControllerFactory.cpp
ControllerFactory.h
api/ControllerState.h
api/Controller.cpp
api/Controller.h
api/ControllerState.cpp
api/InputAPI.h
api/ControllerProvider.h
emulated/ProController.cpp
emulated/EmulatedController.h
emulated/EmulatedController.cpp
emulated/ProController.h
emulated/WPADController.cpp
emulated/WPADController.h
emulated/WiimoteController.h
emulated/VPADController.cpp
emulated/WiimoteController.cpp
emulated/VPADController.h
emulated/ClassicController.cpp
emulated/ClassicController.h
)
set_property(TARGET CemuInput PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
# SDL
target_sources(CemuInput PRIVATE
api/SDL/SDLController.cpp
api/SDL/SDLControllerProvider.cpp
api/SDL/SDLController.h
api/SDL/SDLControllerProvider.h
api/SDL/SDLController.cpp
api/SDL/SDLControllerProvider.cpp
api/SDL/SDLController.h
api/SDL/SDLControllerProvider.h
)
# DSU
target_sources(CemuInput PRIVATE
api/DSU/DSUController.h
api/DSU/DSUControllerProvider.cpp
api/DSU/DSUController.cpp
api/DSU/DSUControllerProvider.h
api/DSU/DSUMessages.h
api/DSU/DSUMessages.cpp
api/DSU/DSUController.h
api/DSU/DSUControllerProvider.cpp
api/DSU/DSUController.cpp
api/DSU/DSUControllerProvider.h
api/DSU/DSUMessages.h
api/DSU/DSUMessages.cpp
)
# Keyboard controller
target_sources(CemuInput PRIVATE
api/Keyboard/KeyboardControllerProvider.h
api/Keyboard/KeyboardControllerProvider.cpp
api/Keyboard/KeyboardController.cpp
api/Keyboard/KeyboardController.h
api/Keyboard/KeyboardControllerProvider.h
api/Keyboard/KeyboardControllerProvider.cpp
api/Keyboard/KeyboardController.cpp
api/Keyboard/KeyboardController.h
)
# Native gamecube
target_sources(CemuInput PRIVATE
api/GameCube/GameCubeController.cpp
api/GameCube/GameCubeControllerProvider.h
api/GameCube/GameCubeControllerProvider.cpp
api/GameCube/GameCubeController.h
api/GameCube/GameCubeController.cpp
api/GameCube/GameCubeControllerProvider.h
api/GameCube/GameCubeControllerProvider.cpp
api/GameCube/GameCubeController.h
)
if(WIN32)
# Native wiimote (Win32 only for now)
target_sources(CemuInput PRIVATE
api/Wiimote/WiimoteControllerProvider.h
api/Wiimote/windows/WinWiimoteDevice.cpp
api/Wiimote/windows/WinWiimoteDevice.h
api/Wiimote/WiimoteControllerProvider.cpp
api/Wiimote/WiimoteMessages.h
api/Wiimote/NativeWiimoteController.h
api/Wiimote/NativeWiimoteController.cpp
api/Wiimote/WiimoteDevice.h
)
# Native wiimote (Win32 only for now)
target_sources(CemuInput PRIVATE
api/Wiimote/WiimoteControllerProvider.h
api/Wiimote/windows/WinWiimoteDevice.cpp
api/Wiimote/windows/WinWiimoteDevice.h
api/Wiimote/WiimoteControllerProvider.cpp
api/Wiimote/WiimoteMessages.h
api/Wiimote/NativeWiimoteController.h
api/Wiimote/NativeWiimoteController.cpp
api/Wiimote/WiimoteDevice.h
)
# XInput
target_sources(CemuInput PRIVATE
api/XInput/XInputControllerProvider.cpp
api/XInput/XInputControllerProvider.h
api/XInput/XInputController.cpp
api/XInput/XInputController.h
)
# XInput
target_sources(CemuInput PRIVATE
api/XInput/XInputControllerProvider.cpp
api/XInput/XInputControllerProvider.h
api/XInput/XInputController.cpp
api/XInput/XInputController.h
)
# DirectInput
target_sources(CemuInput PRIVATE
api/DirectInput/DirectInputControllerProvider.cpp
api/DirectInput/DirectInputController.h
api/DirectInput/DirectInputControllerProvider.h
api/DirectInput/DirectInputController.cpp
)
# DirectInput
target_sources(CemuInput PRIVATE
api/DirectInput/DirectInputControllerProvider.cpp
api/DirectInput/DirectInputController.h
api/DirectInput/DirectInputControllerProvider.h
api/DirectInput/DirectInputController.cpp
)
endif()
target_precompile_headers(CemuInput PRIVATE ../Common/precompiled.h)
target_include_directories(CemuInput PUBLIC "../")
target_link_libraries(CemuInput PRIVATE

View File

@ -2,8 +2,6 @@ add_library(CemuResource)
set_property(TARGET CemuResource PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
target_precompile_headers(CemuResource PRIVATE ../Common/precompiled.h)
# icon resources
if(UNIX)
target_sources(CemuResource PRIVATE
@ -12,10 +10,8 @@ if(UNIX)
)
endif()
target_sources(CemuResource PRIVATE
CafeDefaultFont.cpp
)
target_sources(CemuResource PRIVATE CafeDefaultFont.cpp)
target_include_directories(CemuResource PUBLIC "../")
target_link_libraries(CemuResource PRIVATE CemuComponents)
target_link_libraries(CemuResource PRIVATE CemuCommon CemuComponents)

View File

@ -7,8 +7,6 @@ add_library(CemuUtil ${CPP_FILES} ${H_FILES})
set_property(TARGET CemuUtil PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
target_precompile_headers(CemuUtil PRIVATE ../Common/precompiled.h)
target_include_directories(CemuUtil PUBLIC "../")
target_link_libraries(CemuUtil PRIVATE