From 8e29fb4c53cfcc1d58918dfbe5ea6812c34f6df4 Mon Sep 17 00:00:00 2001 From: zero Date: Tue, 30 Jan 2024 12:45:34 +0800 Subject: [PATCH] Add installation of PDB files and debug suffix for MSVC --- lib/CMakeLists.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 3729263..3c34632 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -146,3 +146,21 @@ if(NOT CPACK_GENERATOR STREQUAL "") include(cmake/EventBus_CPack.cmake) enable_cpack(${CPACK_GENERATOR}) 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 "$<$:${PROJECT_PDB_NAME_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() \ No newline at end of file