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