CMake: Tidy up build system

And fix Windows CMake... who knows how long for.
This commit is contained in:
Stenzek
2024-04-20 20:26:53 +10:00
parent a88ee93b4d
commit 8867bb129a
14 changed files with 288 additions and 253 deletions

View File

@ -146,7 +146,7 @@ if(CPU_ARCH_X64)
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
target_link_libraries(core PRIVATE zydis)
endif()
message("Building x64 recompiler")
message(STATUS "Building x64 recompiler.")
endif()
if(CPU_ARCH_ARM32)
target_compile_definitions(core PUBLIC "ENABLE_RECOMPILER=1" "ENABLE_NEWREC=1")
@ -156,7 +156,7 @@ if(CPU_ARCH_ARM32)
cpu_newrec_compiler_aarch32.h
)
target_link_libraries(core PUBLIC vixl)
message("Building AArch32 recompiler")
message(STATUS "Building AArch32 recompiler.")
endif()
if(CPU_ARCH_ARM64)
target_compile_definitions(core PUBLIC "ENABLE_RECOMPILER=1" "ENABLE_NEWREC=1" "ENABLE_MMAP_FASTMEM=1")
@ -166,7 +166,7 @@ if(CPU_ARCH_ARM64)
cpu_newrec_compiler_aarch64.h
)
target_link_libraries(core PUBLIC vixl)
message("Building AArch64 recompiler")
message(STATUS "Building AArch64 recompiler.")
endif()
if(CPU_ARCH_RISCV64)
target_compile_definitions(core PUBLIC "ENABLE_NEWREC=1" "ENABLE_MMAP_FASTMEM=1")
@ -175,10 +175,10 @@ if(CPU_ARCH_RISCV64)
cpu_newrec_compiler_riscv64.h
)
target_link_libraries(core PUBLIC biscuit::biscuit riscv-disas)
message("Building RISC-V 64-bit recompiler")
message(STATUS "Building RISC-V 64-bit recompiler.")
endif()
if(ENABLE_DISCORD_PRESENCE)
if(NOT ANDROID)
target_compile_definitions(core PUBLIC -DENABLE_DISCORD_PRESENCE=1)
target_link_libraries(core PRIVATE discord-rpc)
endif()

View File

@ -195,14 +195,31 @@ if(WIN32)
"${WINDEPLOYQT_EXE}" --libdir="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
--plugindir="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/QtPlugins"
$<IF:$<CONFIG:Debug>,--debug,--release>
--no-translations
--no-compiler-runtime
--no-system-d3d-compiler
--no-system-dxc-compiler
--no-translations
"$<TARGET_FILE:duckstation-qt>"
)
add_custom_command(TARGET duckstation-qt POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/qt.conf.win" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/qt.conf"
)
#set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/translations")
set(DEPS_TO_COPY freetype.dll harfbuzz.dll libjpeg.dll libpng16.dll libsharpyuv.dll libwebp.dll SDL2.dll shaderc_shared.dll zlib1.dll zstd.dll)
foreach(DEP ${DEPS_TO_COPY})
list(APPEND DEP_BINS "${CMAKE_PREFIX_PATH}/bin/${DEP}")
endforeach()
add_custom_command(TARGET duckstation-qt POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${DEP_BINS} "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
)
if(CMAKE_BUILD_TYPE MATCHES "Debug")
get_property(WINPIXEVENTRUNTIME_DLL TARGET WinPixEventRuntime::WinPixEventRuntime PROPERTY IMPORTED_LOCATION)
message(STATUS WP "${WINPIXEVENTRUNTIME_DLL}")
add_custom_command(TARGET duckstation-qt POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${WINPIXEVENTRUNTIME_DLL}" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
)
endif()
elseif(APPLE)
# Don't generate a bundle for XCode, it makes code signing fail...
if(NOT CMAKE_GENERATOR MATCHES "Xcode")
@ -226,21 +243,21 @@ elseif(APPLE)
# Copy icon into the bundle
target_sources(duckstation-qt PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/DuckStation.icns")
set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/DuckStation.icns" PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
endif()
# Translation setup
qt_add_lrelease(duckstation-qt TS_FILES ${TS_FILES} QM_FILES_OUTPUT_VARIABLE QM_FILES)
foreach (QM_FILE IN LISTS QM_FILES)
target_sources(duckstation-qt PRIVATE ${QM_FILE})
set_source_files_properties(${QM_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION Resources/translations)
endforeach()
copy_base_translations(duckstation-qt)
else()
qt_add_lrelease(duckstation-qt TS_FILES ${TS_FILES} QM_FILES_OUTPUT_VARIABLE QM_FILES)
# Translation setup.
qt_add_lrelease(duckstation-qt TS_FILES ${TS_FILES} QM_FILES_OUTPUT_VARIABLE QM_FILES)
if(NOT APPLE)
set(QM_OUTPUT_DIR "$<TARGET_FILE_DIR:duckstation-qt>/translations")
add_custom_command(TARGET duckstation-qt POST_BUILD COMMAND "${CMAKE_COMMAND}" -E make_directory "${QM_OUTPUT_DIR}")
foreach (QM_FILE IN LISTS QM_FILES)
get_filename_component(QM_FILE_NAME ${QM_FILE} NAME)
add_custom_command(TARGET duckstation-qt POST_BUILD COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${QM_FILE}" "${QM_OUTPUT_DIR}/${QM_FILE_NAME}")
endforeach()
copy_base_translations(duckstation-qt)
else()
foreach (QM_FILE IN LISTS QM_FILES)
target_sources(duckstation-qt PRIVATE ${QM_FILE})
set_source_files_properties(${QM_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION Resources/translations)
endforeach()
endif()
copy_base_translations(duckstation-qt)

View File

@ -78,14 +78,6 @@ target_include_directories(util PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..")
target_link_libraries(util PUBLIC common simpleini imgui)
target_link_libraries(util PRIVATE libchdr JPEG::JPEG PNG::PNG WebP::libwebp ZLIB::ZLIB soundtouch xxhash Zstd::Zstd reshadefx)
if(ENABLE_CUBEB)
target_sources(util PRIVATE
cubeb_audio_stream.cpp
)
target_compile_definitions(util PUBLIC "ENABLE_CUBEB=1")
target_link_libraries(util PRIVATE cubeb)
endif()
if(ENABLE_X11)
target_compile_definitions(util PRIVATE "-DENABLE_X11=1")
target_link_libraries(util PRIVATE X11::X11 X11::Xrandr)
@ -180,26 +172,21 @@ if(ENABLE_VULKAN OR APPLE)
target_link_libraries(util PUBLIC Shaderc::shaderc_shared)
endif()
if(ENABLE_SDL2)
if(NOT ANDROID)
target_sources(util PRIVATE
cubeb_audio_stream.cpp
sdl_audio_stream.cpp
sdl_input_source.cpp
sdl_input_source.h
)
target_compile_definitions(util PUBLIC "ENABLE_SDL2=1")
target_link_libraries(util PUBLIC SDL2::SDL2)
# Copy bundled SDL2 to output on Windows.
if(WIN32)
# Copy SDL2 DLL to binary directory.
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
get_property(SDL2_DLL_PATH TARGET SDL2::SDL2 PROPERTY IMPORTED_LOCATION_DEBUG)
else()
get_property(SDL2_DLL_PATH TARGET SDL2::SDL2 PROPERTY IMPORTED_LOCATION_RELEASE)
endif()
add_custom_command(TARGET util POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SDL2_DLL_PATH}" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/SDL2.dll")
endif()
target_compile_definitions(util PUBLIC
"ENABLE_CUBEB=1"
"ENABLE_SDL2=1"
)
target_link_libraries(util PUBLIC
cubeb
SDL2::SDL2
)
endif()
if(WIN32)