cmake: also install pdb files of static libraries

main
Anonymous Maarten 2023-11-09 00:24:10 +01:00
parent 2e3f574f8f
commit a6541166bc
3 changed files with 22 additions and 2 deletions

View File

@ -3310,7 +3310,7 @@ if(NOT SDL_DISABLE_INSTALL)
RESOURCE DESTINATION "${SDL_SDL_INSTALL_RESOURCEDIR}"
)
if(MSVC)
install(FILES $<TARGET_PDB_FILE:SDL3-shared> 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 #####

View File

@ -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 $<TARGET_PDB_FILE:${TARGET}> DESTINATION "${DIRECTORY}" OPTIONAL)
elseif(type STREQUAL "STATIC_LIBRARY")
# FIXME: Use $<TARGET_COMPILE_PDB_FILE:${TARGET} once it becomes available (https://gitlab.kitware.com/cmake/cmake/-/issues/25244)
if(CMAKE_GENERATOR MATCHES "^Visual Studio.*")
install(CODE "file(INSTALL DESTINATION \"\${CMAKE_INSTALL_PREFIX}/${DIRECTORY}\" TYPE FILE OPTIONAL FILES \"${CMAKE_CURRENT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}/$<TARGET_FILE_BASE_NAME:${TARGET}>.pdb\")")
else()
install(CODE "file(INSTALL DESTINATION \"\${CMAKE_INSTALL_PREFIX}/${DIRECTORY}\" TYPE FILE OPTIONAL FILES \"${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${TARGET}.dir/$<TARGET_FILE_BASE_NAME:${TARGET}>.pdb\")")
endif()
endif()
endfunction()

View File

@ -571,7 +571,7 @@ if(SDL_INSTALL_TESTS)
endif()
if(MSVC)
foreach(test IN LISTS SDL_TEST_EXECUTABLES)
install(FILES $<TARGET_PDB_FILE:${test}> DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}/installed-tests/SDL3" OPTIONAL)
SDL_install_pdb(${test} "${CMAKE_INSTALL_LIBEXECDIR}/installed-tests/SDL3")
endforeach()
endif()
install(