CMake: Install pdb files to proper directories in multi-config build

In multi-config build, for different configs, the pdb files of EXEs
should have different installation directories.

For example, when CMAKE_CONFIGURATION_TYPES=RelWithDebInfo;Debug,
<build_dir>/bin/moc.pdb will be installed to <install_dir>/bin/moc.pdb.
<build_dir>/bin/Debug/moc.pdb should be installed to
<install_dir>/bin/Debug/moc.pdb, not <install_dir>/bin/moc.pdb.

Fixes: QTBUG-88268
Change-Id: Idc7c92ca8d44bb81d990656af2b309306a4f5c6b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Li Xinwei 2020-11-13 17:27:12 +08:00
parent 654156fb79
commit 215400e153

View File

@ -554,8 +554,22 @@ function(qt_internal_install_pdb_files target install_dir_path)
if(MSVC)
get_target_property(target_type ${target} TYPE)
if(target_type STREQUAL "SHARED_LIBRARY"
OR target_type STREQUAL "EXECUTABLE"
if(target_type STREQUAL "EXECUTABLE")
qt_get_cmake_configurations(cmake_configs)
list(LENGTH cmake_configs all_configs_count)
list(GET cmake_configs 0 first_config)
foreach(cmake_config ${cmake_configs})
set(suffix "")
if(all_configs_count GREATER 1 AND NOT cmake_config STREQUAL first_config)
set(suffix "/${cmake_config}")
endif()
qt_install(FILES "$<TARGET_PDB_FILE:${target}>"
CONFIGURATIONS ${cmake_config}
DESTINATION "${install_dir_path}${suffix}"
OPTIONAL)
endforeach()
elseif(target_type STREQUAL "SHARED_LIBRARY"
OR target_type STREQUAL "MODULE_LIBRARY")
qt_install(FILES "$<TARGET_PDB_FILE:${target}>"
DESTINATION "${install_dir_path}"