From 2485a98d4f1bf0c8a1a84f46000fd62b45942e63 Mon Sep 17 00:00:00 2001 From: oltolm Date: Sat, 30 Aug 2025 20:20:55 +0200 Subject: [PATCH] cmake: simplify code --- 3rdparty/zstd/CMakeLists.txt | 2 +- buildfiles/cmake/ConfigureCompiler.cmake | 1 - buildfiles/cmake/FindFFMPEG.cmake | 2 +- rpcs3/CMakeLists.txt | 34 +++++++++--------------- 4 files changed, 14 insertions(+), 25 deletions(-) diff --git a/3rdparty/zstd/CMakeLists.txt b/3rdparty/zstd/CMakeLists.txt index f4c97d3eeb..431272966d 100644 --- a/3rdparty/zstd/CMakeLists.txt +++ b/3rdparty/zstd/CMakeLists.txt @@ -10,7 +10,7 @@ else() option(ZSTD_BUILD_STATIC "BUILD STATIC LIBRARIES" ON) option(ZSTD_BUILD_TESTS "BUILD TESTS" OFF) - add_subdirectory(zstd/build/cmake EXLUDE_FROM_ALL) + add_subdirectory(zstd/build/cmake EXCLUDE_FROM_ALL) add_library(3rdparty_zstd INTERFACE) target_link_libraries(3rdparty_zstd INTERFACE libzstd_static) endif() diff --git a/buildfiles/cmake/ConfigureCompiler.cmake b/buildfiles/cmake/ConfigureCompiler.cmake index d59d987b9c..be900d13c2 100644 --- a/buildfiles/cmake/ConfigureCompiler.cmake +++ b/buildfiles/cmake/ConfigureCompiler.cmake @@ -5,7 +5,6 @@ if(MSVC) add_compile_definitions( _CRT_SECURE_NO_DEPRECATE=1 _CRT_NON_CONFORMING_SWPRINTFS=1 _SCL_SECURE_NO_WARNINGS=1 NOMINMAX _ENABLE_EXTENDED_ALIGNED_STORAGE=1 _HAS_EXCEPTIONS=0) - add_link_options(/DYNAMICBASE) #TODO: Some of these could be cleaned up add_compile_options(/wd4805) # Comparing boolean and int diff --git a/buildfiles/cmake/FindFFMPEG.cmake b/buildfiles/cmake/FindFFMPEG.cmake index f4f62034a8..55e3fd8d88 100644 --- a/buildfiles/cmake/FindFFMPEG.cmake +++ b/buildfiles/cmake/FindFFMPEG.cmake @@ -66,7 +66,7 @@ else () find_package_handle_standard_args(FFMPEG DEFAULT_MSG - FFMPEG_LIBAVCODEC FFMPEG_LIBAVFORMAT FFMPEG_LIBSWSCALE FFMPEG_LIBSWRESAMPLE + FFMPEG_LIBAVCODEC FFMPEG_LIBAVFORMAT FFMPEG_LIBAVUTIL FFMPEG_LIBSWSCALE FFMPEG_LIBSWRESAMPLE ) if (FFMPEG_FOUND) diff --git a/rpcs3/CMakeLists.txt b/rpcs3/CMakeLists.txt index b1d10d38eb..16147bb8d1 100644 --- a/rpcs3/CMakeLists.txt +++ b/rpcs3/CMakeLists.txt @@ -10,16 +10,6 @@ include(CheckFunctionExists) set(CMAKE_CXX_STANDARD 20) -set(ADDITIONAL_LIBS "") -if(CMAKE_SYSTEM_NAME STREQUAL "Linux") - #on some Linux distros shm_unlink and similar functions are in librt only - list(APPEND ADDITIONAL_LIBS "rt") -elseif(NOT WIN32 AND NOT CMAKE_CXX_FLAGS MATCHES "LIBICONV_PLUG") - #it seems like glibc includes the iconv functions we use but other libc - #implementations like the one on OSX don't seem implement them - list(APPEND ADDITIONAL_LIBS "iconv") -endif() - if(UNIX AND NOT APPLE AND NOT ANDROID) add_compile_definitions(DATADIR="${CMAKE_INSTALL_FULL_DATADIR}/rpcs3") # Optionally enable X11 for window management @@ -78,8 +68,16 @@ if (NOT ANDROID) 3rdparty::libcurl 3rdparty::zlib 3rdparty::opencv - 3rdparty::fusion - ${ADDITIONAL_LIBS}) + 3rdparty::fusion) + + if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + #on some Linux distros shm_unlink and similar functions are in librt only + target_link_libraries(rpcs3_lib PRIVATE rt) + elseif(NOT WIN32 AND NOT CMAKE_CXX_FLAGS MATCHES "LIBICONV_PLUG") + #it seems like glibc includes the iconv functions we use but other libc + #implementations like the one on OSX don't seem implement them + target_link_libraries(rpcs3_lib PRIVATE iconv) + endif() # Unix display manager if(X11_FOUND) @@ -106,19 +104,16 @@ if (NOT ANDROID) endif() # Build rpcs3 executable + add_executable(rpcs3 WIN32 MACOSX_BUNDLE) if(WIN32) - add_executable(rpcs3 WIN32) target_sources(rpcs3 PRIVATE rpcs3.rc) target_compile_definitions(rpcs3 PRIVATE UNICODE _UNICODE) elseif(APPLE) - add_executable(rpcs3 MACOSX_BUNDLE) target_sources(rpcs3 PRIVATE rpcs3.icns update_helper.sh) set_source_files_properties(update_helper.sh PROPERTIES MACOSX_PACKAGE_LOCATION Resources) set_target_properties(rpcs3 PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/rpcs3.plist.in") - else() - add_executable(rpcs3) endif() target_sources(rpcs3 @@ -137,17 +132,12 @@ if (NOT ANDROID) # Copy icons to executable directory if(APPLE) - if (CMAKE_BUILD_TYPE MATCHES "Debug" OR CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo") - set(QT_DEPLOY_FLAGS "-no-strip") - else() - set(QT_DEPLOY_FLAGS "") - endif() qt_finalize_target(rpcs3) add_custom_command(TARGET rpcs3 POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/rpcs3.icns $/../Resources/rpcs3.icns COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/bin/Icons $/../Resources/Icons COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/bin/GuiConfigs $/../Resources/GuiConfigs - COMMAND "${MACDEPLOYQT_EXECUTABLE}" "${PROJECT_BINARY_DIR}/bin/rpcs3.app" "${QT_DEPLOY_FLAGS}") + COMMAND "${MACDEPLOYQT_EXECUTABLE}" "${PROJECT_BINARY_DIR}/bin/rpcs3.app" "$<$:-no-strip>") elseif(UNIX) add_custom_command(TARGET rpcs3 POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/bin/Icons $/Icons