Add installation of PDB files and debug suffix for MSVC

This commit is contained in:
zero 2024-01-30 12:45:34 +08:00 committed by Gelldur
parent 62046399d4
commit 8e29fb4c53

View File

@ -146,3 +146,21 @@ if(NOT CPACK_GENERATOR STREQUAL "")
include(cmake/EventBus_CPack.cmake) include(cmake/EventBus_CPack.cmake)
enable_cpack(${CPACK_GENERATOR}) enable_cpack(${CPACK_GENERATOR})
endif() endif()
# If the compiler is MSVC, install the PDB file and add the debug suffix
if(MSVC)
set_target_properties(${PROJECT_NAME} PROPERTIES
DEBUG_POSTFIX "d"
PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
COMPILE_PDB_NAME_DEBUG "${PROJECT_NAME}d"
COMPILE_PDB_NAME_RELEASE ${PROJECT_NAME}
COMPILE_PDB_NAME_MINSIZEREL ${PROJECT_NAME}
COMPILE_PDB_NAME_RELWITHDEBINFO ${PROJECT_NAME})
get_target_property(PROJECT_PDB_NAME_DEBUG ${PROJECT_NAME} COMPILE_PDB_NAME_DEBUG)
get_target_property(PROJECT_PDB_NAME_RELEASE ${PROJECT_NAME} COMPILE_PDB_NAME_RELEASE)
get_target_property(PROJECT_PDB_DIRECTORY ${PROJECT_NAME} PDB_OUTPUT_DIRECTORY)
set(PROJECT_PDB_NAME "$<$<CONFIG:Debug>:${PROJECT_PDB_NAME_DEBUG}>$<$<NOT:$<CONFIG:Debug>>:${PROJECT_PDB_NAME_RELEASE}>.pdb")
install(FILES "${PROJECT_PDB_DIRECTORY}/${PROJECT_PDB_NAME}" DESTINATION lib OPTIONAL)
install(FILES "${PROJECT_PDB_DIRECTORY}/\${CMAKE_INSTALL_CONFIG_NAME}/${PROJECT_PDB_NAME}" DESTINATION lib OPTIONAL)
endif()