From a6541166bcf9da779b6cdb587d47976d5c1d4ea9 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Thu, 9 Nov 2023 00:24:10 +0100 Subject: [PATCH] cmake: also install pdb files of static libraries --- CMakeLists.txt | 8 +++++++- cmake/macros.cmake | 14 ++++++++++++++ test/CMakeLists.txt | 2 +- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e93a84ac..ca03351ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3310,7 +3310,7 @@ if(NOT SDL_DISABLE_INSTALL) RESOURCE DESTINATION "${SDL_SDL_INSTALL_RESOURCEDIR}" ) if(MSVC) - install(FILES $ DESTINATION "${CMAKE_INSTALL_BINDIR}" OPTIONAL) + SDL_install_pdb(SDL3-shared "${CMAKE_INSTALL_BINDIR}") endif() endif() @@ -3320,6 +3320,9 @@ if(NOT SDL_DISABLE_INSTALL) FRAMEWORK DESTINATION "." RESOURCE DESTINATION "${SDL_SDLstatic_INSTALL_RESOURCEDIR}" ) + if(MSVC) + SDL_install_pdb(SDL3-static "${CMAKE_INSTALL_LIBDIR}") + endif() endif() if(SDL_TEST_LIBRARY) @@ -3328,6 +3331,9 @@ if(NOT SDL_DISABLE_INSTALL) FRAMEWORK DESTINATION "." RESOURCE DESTINATION "${SDL_SDLtest_INSTALL_RESOURCEDIR}" ) + if(MSVC) + SDL_install_pdb(SDL3_test "${CMAKE_INSTALL_LIBDIR}") + endif() endif() ##### Install CMake Targets ##### diff --git a/cmake/macros.cmake b/cmake/macros.cmake index f91946425..edc30fcfb 100644 --- a/cmake/macros.cmake +++ b/cmake/macros.cmake @@ -201,3 +201,17 @@ function(SDL_PrintSummary) message(STATUS "") endif() endfunction() + +function(SDL_install_pdb TARGET DIRECTORY) + get_property(type TARGET ${TARGET} PROPERTY TYPE) + if(type MATCHES "^(SHARED_LIBRARY|EXECUTABLE)$") + install(FILES $ DESTINATION "${DIRECTORY}" OPTIONAL) + elseif(type STREQUAL "STATIC_LIBRARY") + # FIXME: Use $.pdb\")") + else() + install(CODE "file(INSTALL DESTINATION \"\${CMAKE_INSTALL_PREFIX}/${DIRECTORY}\" TYPE FILE OPTIONAL FILES \"${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${TARGET}.dir/$.pdb\")") + endif() + endif() +endfunction() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ee4251a47..8d7ff5904 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -571,7 +571,7 @@ if(SDL_INSTALL_TESTS) endif() if(MSVC) foreach(test IN LISTS SDL_TEST_EXECUTABLES) - install(FILES $ DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}/installed-tests/SDL3" OPTIONAL) + SDL_install_pdb(${test} "${CMAKE_INSTALL_LIBEXECDIR}/installed-tests/SDL3") endforeach() endif() install(