From 065a64371ee274d4e957501274ae045a0caa5ff1 Mon Sep 17 00:00:00 2001 From: oltolm Date: Thu, 2 May 2024 13:53:18 +0200 Subject: [PATCH] improve CMake files Signed-off-by: oltolm --- 3rdparty/CMakeLists.txt | 5 ++--- 3rdparty/OpenAL/CMakeLists.txt | 18 ++++++++++-------- 3rdparty/curl/CMakeLists.txt | 1 + 3rdparty/llvm/CMakeLists.txt | 2 +- 3rdparty/rtmidi/CMakeLists.txt | 1 + 3rdparty/wolfssl/CMakeLists.txt | 26 +++++++++++++------------- 3rdparty/zlib/CMakeLists.txt | 5 +---- 3rdparty/zstd/CMakeLists.txt | 1 + CMakeLists.txt | 1 + rpcs3/CMakeLists.txt | 3 +-- rpcs3/Emu/CMakeLists.txt | 2 +- 11 files changed, 33 insertions(+), 32 deletions(-) diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index 6c82cdfc81..f34a070d7c 100644 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -224,7 +224,7 @@ if(USE_FAUDIO) if (USE_SYSTEM_FAUDIO) if (NOT SDL2_FOUND OR SDL2_VERSION VERSION_LESS 2.0.12) message(WARNING - "RPCS3: FAudio requires SDL 2.0.9 or newer. Please note, this warning" + "RPCS3: System FAudio requires SDL 2.0.9 or newer. Please note, this warning" "can also be displayed with SDL2 versions between 2.0.9-2.0.12, as the" "CMake config files are not correctly installed. Since a valid SDL2" ">=2.0.9 version cannot be found, building with FAudio will be skipped.") @@ -329,8 +329,7 @@ if(USE_SDL) message(STATUS "Using system SDL2") add_library(3rdparty_sdl2 INTERFACE) target_compile_definitions(3rdparty_sdl2 INTERFACE -DHAVE_SDL2=1) - target_include_directories(3rdparty_sdl2 INTERFACE ${SDL2_INCLUDE_DIRS}) - target_link_libraries(3rdparty_sdl2 INTERFACE ${SDL2_LIBRARIES}) + target_link_libraries(3rdparty_sdl2 INTERFACE SDL2::SDL2) set(SDL2_TARGET 3rdparty_sdl2) else() message(FATAL_ERROR "SDL2 is not available on this system") diff --git a/3rdparty/OpenAL/CMakeLists.txt b/3rdparty/OpenAL/CMakeLists.txt index 2aa1d49452..ffeeee2bdc 100644 --- a/3rdparty/OpenAL/CMakeLists.txt +++ b/3rdparty/OpenAL/CMakeLists.txt @@ -1,11 +1,13 @@ # OpenAL -if (WIN32) - find_path(OPENAL_INCLUDE_DIR al.h PATHS include/) - find_library(OPENAL_LIBRARY OpenAL32 PATHS libs/Win64/) -else() +if(USE_SYSTEM_OPENAL) find_package(OpenAL REQUIRED) + add_library(3rdparty_openal INTERFACE) + target_include_directories(3rdparty_openal INTERFACE ${OPENAL_INCLUDE_DIR}) + target_link_libraries(3rdparty_openal INTERFACE ${OPENAL_LIBRARY}) +else() + option(ALSOFT_UTILS "Build utility programs" OFF) + option(ALSOFT_EXAMPLES "Build example programs" OFF) + add_subdirectory(openal-soft EXCLUDE_FROM_ALL) + add_library(3rdparty_openal INTERFACE) + target_link_libraries(3rdparty_openal INTERFACE OpenAL::OpenAL) endif() - -add_library(3rdparty_openal INTERFACE) -target_include_directories(3rdparty_openal INTERFACE ${OPENAL_INCLUDE_DIR}) -target_link_libraries(3rdparty_openal INTERFACE ${OPENAL_LIBRARY}) diff --git a/3rdparty/curl/CMakeLists.txt b/3rdparty/curl/CMakeLists.txt index 837461adc5..f7e904781d 100644 --- a/3rdparty/curl/CMakeLists.txt +++ b/3rdparty/curl/CMakeLists.txt @@ -29,6 +29,7 @@ else() set(SSL_ENABLED ON) set(USE_WOLFSSL ON) set(SHARE_LIB_OBJECT OFF) + set(CURL_DISABLE_TESTS ON) add_subdirectory(curl EXCLUDE_FROM_ALL) diff --git a/3rdparty/llvm/CMakeLists.txt b/3rdparty/llvm/CMakeLists.txt index a5fe885f44..ed28aa576f 100644 --- a/3rdparty/llvm/CMakeLists.txt +++ b/3rdparty/llvm/CMakeLists.txt @@ -14,7 +14,7 @@ if(WITH_LLVM) option(LLVM_INCLUDE_TESTS OFF) option(LLVM_INCLUDE_TOOLS OFF) option(LLVM_INCLUDE_UTILS OFF) - option(LLVM_CCACHE_BUILD ON) + option(LLVM_CCACHE_BUILD OFF) set(LLVM_ENABLE_WARNINGS OFF CACHE BOOL "Enable compiler warnings.") if(WIN32) diff --git a/3rdparty/rtmidi/CMakeLists.txt b/3rdparty/rtmidi/CMakeLists.txt index 073f362b58..610f858c6d 100644 --- a/3rdparty/rtmidi/CMakeLists.txt +++ b/3rdparty/rtmidi/CMakeLists.txt @@ -1,3 +1,4 @@ option(RTMIDI_API_JACK "Compile with JACK support." OFF) +option(RTMIDI_BUILD_TESTING "Build test programs" OFF) set(RTMIDI_TARGETNAME_UNINSTALL "uninstall-rpcs3-rtmidi") add_subdirectory(rtmidi EXCLUDE_FROM_ALL) diff --git a/3rdparty/wolfssl/CMakeLists.txt b/3rdparty/wolfssl/CMakeLists.txt index 777ce5b4ea..f74f604269 100644 --- a/3rdparty/wolfssl/CMakeLists.txt +++ b/3rdparty/wolfssl/CMakeLists.txt @@ -4,21 +4,21 @@ if(USE_SYSTEM_WOLFSSL) add_library(wolfssl INTERFACE) target_link_libraries(wolfssl INTERFACE PkgConfig::WolfSSL) else() - set(WOLFSSL_TLS13 OFF CACHE STRING "Enable wolfSSL TLS v1.3 (default: enabled)") + option(WOLFSSL_TLS13 "Enable wolfSSL TLS v1.3 (default: enabled)" OFF) set(WOLFSSL_SHA3 ON CACHE STRING "Enable wolfSSL SHA-3 support (default: enabled on x86_64/aarch64)") set(WOLFSSL_SHAKE256 ON CACHE STRING "Enable wolfSSL SHAKE256 support (default: enabled on x86_64/aarch64)") - set(WOLFSSL_BASE64_ENCODE OFF CACHE STRING "Enable Base64 encoding (default: enabled on x86_64)") - set(WOLFSSL_DES3 ON CACHE STRING "Enable DES3 (default: disabled)") - set(WOLFSSL_PWDBASED ON CACHE STRING "Enable PWDBASED (default: disabled)") - set(WOLFSSL_FAST_MATH ON CACHE STRING "Enable fast math ops (default: disabled)") - set(WOLFSSL_EXAMPLES OFF CACHE STRING "Enable examples (default: enabled)") - set(WOLFSSL_CRYPT_TESTS OFF CACHE STRING "Enable Crypt Bench/Test (default: enabled)") - set(WOLFSSL_ASYNC_THREADS OFF CACHE STRING "Enable Asynchronous Threading (default: enabled)") - set(WOLFSSL_BUILD_OUT_OF_TREE ON CACHE STRING "Don't generate files in the source tree (default: no)") - set(WOLFSSL_SNI ON CACHE STRING "Enable SNI (default: disabled)") - set(WOLFSSL_OPENSSLEXTRA ON CACHE STRING "Enable extra OpenSSL API, size+ (default: disabled)") - set(WOLFSSL_HARDEN OFF CACHE STRING "Enable Hardened build, Enables Timing Resistance and Blinding (default: enabled)") - set(WOLFSSL_ALT_CERT_CHAINS ON CACHE STRING "Enable support for Alternate certification chains (default: disabled)") + option(WOLFSSL_BASE64_ENCODE "Enable Base64 encoding (default: enabled on x86_64)" OFF) + option(WOLFSSL_DES3 "Enable DES3 (default: disabled)" ON) + option(WOLFSSL_PWDBASED "Enable PWDBASED (default: disabled)" ON) + option(WOLFSSL_FAST_MATH "Enable fast math ops (default: disabled)" ON) + option(WOLFSSL_EXAMPLES "Enable examples (default: enabled)" OFF) + option(WOLFSSL_CRYPT_TESTS "Enable Crypt Bench/Test (default: enabled)" OFF) + option(WOLFSSL_ASYNC_THREADS "Enable Asynchronous Threading (default: enabled)" OFF) + option(WOLFSSL_BUILD_OUT_OF_TREE "Don't generate files in the source tree (default: yes)" ON) + option(WOLFSSL_SNI "Enable SNI (default: disabled)" ON) + option(WOLFSSL_OPENSSLEXTRA "Enable extra OpenSSL API, size+ (default: disabled)" ON) + option(WOLFSSL_HARDEN "Enable Hardened build, Enables Timing Resistance and Blinding (default: enabled)" OFF) + option(WOLFSSL_ALT_CERT_CHAINS "Enable support for Alternate certification chains (default: disabled)" ON) add_subdirectory(wolfssl EXCLUDE_FROM_ALL) diff --git a/3rdparty/zlib/CMakeLists.txt b/3rdparty/zlib/CMakeLists.txt index 243a883654..d9dffb07be 100644 --- a/3rdparty/zlib/CMakeLists.txt +++ b/3rdparty/zlib/CMakeLists.txt @@ -6,6 +6,7 @@ if (USE_SYSTEM_ZLIB) target_link_libraries(3rdparty_zlib INTERFACE ZLIB::ZLIB) target_compile_definitions(3rdparty_zlib INTERFACE -DZLIB_CONST=1) else() + option(ZLIB_BUILD_EXAMPLES "Enable Zlib Examples" OFF) message(STATUS "RPCS3: Using builtin ZLIB") set(SKIP_INSTALL_ALL ON) add_subdirectory(zlib EXCLUDE_FROM_ALL) @@ -14,8 +15,4 @@ else() target_link_libraries(3rdparty_zlib INTERFACE zlibstatic) target_include_directories(3rdparty_zlib INTERFACE zlib ${CMAKE_CURRENT_BINARY_DIR}/zlib) target_compile_definitions(3rdparty_zlib INTERFACE -DZLIB_CONST=1) - - if(NOT MSVC) - set(ZLIB_ROOT ${CMAKE_CURRENT_BINARY_DIR}/zlib PARENT_SCOPE) - endif() endif() diff --git a/3rdparty/zstd/CMakeLists.txt b/3rdparty/zstd/CMakeLists.txt index 2835a99f77..5a8b6f3d90 100644 --- a/3rdparty/zstd/CMakeLists.txt +++ b/3rdparty/zstd/CMakeLists.txt @@ -1,6 +1,7 @@ option(ZSTD_BUILD_PROGRAMS "BUILD PROGRAMS" OFF) option(ZSTD_BUILD_SHARED "BUILD SHARED LIBRARIES" OFF) option(ZSTD_BUILD_STATIC "BUILD STATIC LIBRARIES" ON) +option(ZSTD_BUILD_TESTS "BUILD TESTS" OFF) add_subdirectory(zstd/build/cmake EXLUDE_FROM_ALL) add_library(3rdparty_zstd INTERFACE) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4aa13efff4..b0fe9829f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,7 @@ option(USE_PRECOMPILED_HEADERS "Use precompiled headers" OFF) option(USE_SDL "Enables SDL input handler" OFF) option(USE_SYSTEM_SDL "Prefer system SDL instead of the builtin one" OFF) option(USE_SYSTEM_FFMPEG "Prefer system ffmpeg instead of the prebuild one" OFF) +option(USE_SYSTEM_OPENAL "Prefer system OpenAL instead of the prebuild one" ON) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/buildfiles/cmake") diff --git a/rpcs3/CMakeLists.txt b/rpcs3/CMakeLists.txt index 7ee5e005ea..a8675d945e 100644 --- a/rpcs3/CMakeLists.txt +++ b/rpcs3/CMakeLists.txt @@ -96,8 +96,7 @@ target_link_libraries(rpcs3 PRIVATE ${ADDITIONAL_LIBS}) # Unix display manager if(X11_FOUND) - target_include_directories(rpcs3 PUBLIC ${X11_INCLUDE_DIR}) - target_link_libraries(rpcs3 PRIVATE ${X11_LIBRARIES}) + target_link_libraries(rpcs3 PRIVATE X11::X11) elseif(USE_VULKAN AND UNIX AND NOT WAYLAND_FOUND AND NOT APPLE) # Wayland has been checked in 3rdparty/CMakeLists.txt already. message(FATAL_ERROR "RPCS3 requires either X11 or Wayland (or both) for Vulkan.") diff --git a/rpcs3/Emu/CMakeLists.txt b/rpcs3/Emu/CMakeLists.txt index 8133c5bf67..526bec0e7a 100644 --- a/rpcs3/Emu/CMakeLists.txt +++ b/rpcs3/Emu/CMakeLists.txt @@ -132,7 +132,7 @@ target_sources(rpcs3_emu PRIVATE if(USE_FAUDIO) find_package(SDL2) - if(SDL2_FOUND AND NOT SDL2_VERSION VERSION_LESS 2.0.9) + if(SDL2_FOUND AND SDL2_VERSION VERSION_GREATER_EQUAL 2.0.9) target_sources(rpcs3_emu PRIVATE Audio/FAudio/FAudioBackend.cpp Audio/FAudio/faudio_enumerator.cpp