From adc088052098823e72f053bfa0c190bb3a46ed0c Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Thu, 9 Nov 2023 02:56:37 +0100 Subject: [PATCH] cmake: also install pdb files of static libraries --- CMakeLists.txt | 13 +++++++++++-- cmake/macros.cmake | 20 ++++++++++++++++++++ test/CMakeLists.txt | 2 +- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2dba6ca6d..42a50609f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 $ 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 ##### diff --git a/cmake/macros.cmake b/cmake/macros.cmake index 69a5d5464..2087e54b6 100644 --- a/cmake/macros.cmake +++ b/cmake/macros.cmake @@ -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 $ DESTINATION "${DIRECTORY}" OPTIONAL) + endif() + elseif(type STREQUAL "STATIC_LIBRARY") + if(NOT CMAKE_VERSION VERSION_LESS 3.15) + # FIXME: Use $ DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}/installed-tests/SDL2" OPTIONAL) + SDL_install_pdb(${test} "${CMAKE_INSTALL_LIBEXECDIR}/installed-tests/SDL2") endforeach() endif() install(