2022-08-22 22:21:23 +02:00
|
|
|
cmake_minimum_required(VERSION 3.21.1)
|
|
|
|
|
|
|
|
option(PUBLIC_RELEASE "Compile with debug asserts disabled and no console" OFF)
|
|
|
|
|
|
|
|
if (PUBLIC_RELEASE)
|
|
|
|
add_definitions(-DPUBLIC_RELEASE)
|
|
|
|
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) # enable LTO
|
|
|
|
endif()
|
|
|
|
|
2022-08-24 08:32:04 +02:00
|
|
|
if (WIN32)
|
|
|
|
set(VCPKG_TARGET_TRIPLET "x64-windows-static" CACHE STRING "")
|
2022-08-22 22:21:23 +02:00
|
|
|
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)
|
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
|
|
|
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
|
|
|
|
2022-08-26 17:56:19 +02:00
|
|
|
if (MSVC)
|
|
|
|
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT CemuBin)
|
|
|
|
endif()
|
|
|
|
|
2022-08-24 08:32:04 +02:00
|
|
|
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
|
|
|
|
if (PUBLIC_RELEASE)
|
2022-08-22 22:21:23 +02:00
|
|
|
message(STATUS "Using additional optimization flags for MSVC")
|
2022-08-24 08:32:04 +02:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Oi /Ot") # enable intrinsic functions, favor speed
|
|
|
|
endif()
|
|
|
|
endif()
|
2022-08-22 22:21:23 +02:00
|
|
|
|
|
|
|
option(ENABLE_OPENGL "Enables the OpenGL backend" ON)
|
|
|
|
option(ENABLE_VULKAN "Enables the Vulkan backend" ON)
|
|
|
|
option(ENABLE_DISCORD_RPC "Enables the Discord Rich Presence feature" ON)
|
|
|
|
|
|
|
|
# input backends
|
2022-08-24 08:32:04 +02:00
|
|
|
if (WIN32)
|
|
|
|
option(ENABLE_XINPUT "Enables the usage of XInput" ON)
|
|
|
|
option(ENABLE_DIRECTINPUT "Enables the usage of DirectInput" ON)
|
|
|
|
add_definitions(-DHAS_DIRECTINPUT)
|
2022-08-22 22:21:23 +02:00
|
|
|
endif()
|
|
|
|
option(ENABLE_SDL "Enables the SDLController backend" ON)
|
|
|
|
|
|
|
|
# audio backends
|
2022-08-24 08:32:04 +02:00
|
|
|
if (WIN32)
|
|
|
|
option(ENABLE_DIRECTAUDIO "Enables the directaudio backend" ON)
|
|
|
|
option(ENABLE_XAUDIO "Enables the xaudio backend" ON)
|
2022-08-22 22:21:23 +02:00
|
|
|
endif()
|
|
|
|
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)
|
|
|
|
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)
|
|
|
|
|
2022-08-24 08:32:04 +02:00
|
|
|
if (ENABLE_VULKAN)
|
2022-08-25 06:31:32 +02:00
|
|
|
include_directories("dependencies/Vulkan-Headers/include")
|
2022-08-22 22:21:23 +02:00
|
|
|
endif()
|
2022-08-24 08:32:04 +02:00
|
|
|
|
|
|
|
if (ENABLE_OPENGL)
|
|
|
|
find_package(OpenGL REQUIRED)
|
2022-08-22 22:21:23 +02:00
|
|
|
endif()
|
2022-08-24 08:32:04 +02:00
|
|
|
|
|
|
|
if (ENABLE_DISCORD_RPC)
|
|
|
|
add_definitions(-DENABLE_DISCORD_RPC)
|
|
|
|
add_subdirectory(dependencies/discord-rpc EXCLUDE_FROM_ALL)
|
|
|
|
target_include_directories(discord-rpc INTERFACE ./dependencies/discord-rpc/include)
|
2022-08-22 22:21:23 +02:00
|
|
|
endif()
|
|
|
|
|
2022-08-24 08:32:04 +02:00
|
|
|
if (ENABLE_WXWIDGETS)
|
|
|
|
find_package(wxWidgets CONFIG REQUIRED)
|
2022-08-22 22:21:23 +02:00
|
|
|
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)
|
2022-08-24 08:32:04 +02:00
|
|
|
if (ENABLE_WXWIDGETS)
|
|
|
|
link_libraries(wx::core wx::base)
|
2022-08-22 22:21:23 +02:00
|
|
|
endif()
|
|
|
|
|
2022-08-24 08:32:04 +02:00
|
|
|
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$<$<CONFIG:Debug>:Debug>")
|
|
|
|
link_libraries(cubeb)
|
|
|
|
add_compile_definitions(HAS_CUBEB=1)
|
2022-08-22 22:21:23 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
add_subdirectory(dependencies/ih264d)
|
|
|
|
add_subdirectory(dependencies/ZArchive)
|
|
|
|
|
2022-08-26 19:41:42 +02:00
|
|
|
add_subdirectory(src)
|