cmake: also install pdb files of static libraries

This commit is contained in:
Anonymous Maarten 2023-11-09 02:56:37 +01:00
parent 509c70c698
commit adc0880520
3 changed files with 32 additions and 3 deletions

View file

@ -3510,8 +3510,8 @@ if(NOT SDL2_DISABLE_INSTALL)
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
if(MSVC AND NOT CMAKE_VERSION VERSION_LESS "3.1")
install(FILES $<TARGET_PDB_FILE:SDL2> DESTINATION "${CMAKE_INSTALL_BINDIR}" OPTIONAL)
if(MSVC)
SDL_install_pdb(SDL2 "${CMAKE_INSTALL_BINDIR}")
endif()
endif()
@ -3520,6 +3520,9 @@ if(NOT SDL2_DISABLE_INSTALL)
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
if(MSVC)
SDL_install_pdb(SDL2main "${CMAKE_INSTALL_LIBDIR}")
endif()
endif()
if(SDL_STATIC)
@ -3527,6 +3530,9 @@ if(NOT SDL2_DISABLE_INSTALL)
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
if(MSVC)
SDL_install_pdb(SDL2-static "${CMAKE_INSTALL_LIBDIR}")
endif()
endif()
if(SDL_TEST)
@ -3534,6 +3540,9 @@ if(NOT SDL2_DISABLE_INSTALL)
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
if(MSVC)
SDL_install_pdb(SDL2_test "${CMAKE_INSTALL_LIBDIR}")
endif()
endif()
##### Export files #####

View file

@ -124,3 +124,23 @@ if(CMAKE_VERSION VERSION_LESS 3.13.0)
link_directories(${ARGN})
endmacro()
endif()
# CMP0087: install(CODE) and install(SCRIPT) support generator expressions.
cmake_policy(SET CMP0087 NEW)
function(SDL_install_pdb TARGET DIRECTORY)
get_property(type TARGET ${TARGET} PROPERTY TYPE)
if(type MATCHES "^(SHARED_LIBRARY|EXECUTABLE)$")
if(NOT CMAKE_VERSION VERSION_LESS 3.1)
install(FILES $<TARGET_PDB_FILE:${TARGET}> DESTINATION "${DIRECTORY}" OPTIONAL)
endif()
elseif(type STREQUAL "STATIC_LIBRARY")
if(NOT CMAKE_VERSION VERSION_LESS 3.15)
# 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}.pdb\")")
else()
install(CODE "file(INSTALL DESTINATION \"\${CMAKE_INSTALL_PREFIX}/${DIRECTORY}\" TYPE FILE OPTIONAL FILES \"${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${TARGET}.dir/${TARGET}.pdb\")")
endif()
endif()
endif()
endfunction()

View file

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