build: improve the Linux aspect of things (#75)

Improved, fixed and streamlined cmake files. Optionally use system libraries instead of vcpkg (-DENABLE_VCPKG=OFF)
This commit is contained in:
Andrea Pappacoda 2022-08-29 07:19:48 +02:00 committed by GitHub
parent 0f24b0663e
commit f51a51df3b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 368 additions and 96 deletions

View file

@ -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$<$<CONFIG:Debug>: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$<$<CONFIG:Debug>: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)
find_package(ZArchive)
if (NOT ZArchive_FOUND)
add_subdirectory("dependencies/ZArchive")
endif()
add_subdirectory(src)