CMake: set correct COMPILE_PDB_NAME for static libraries

Output names of static libraries might be different from target names.
For example, the library name of Qt6::DeviceDiscoverySupportPrivate is
"Qt6DeviceDiscoverySupport.lib", and the library name of
Qt6::QTlsBackendCertOnlyPlugin is "qcertonlybackend.lib".
This commit make pdb files names consistent with the library names.

And make sure we have set correct OUTPUT_NAME property before calling
qt_set_common_target_properties()/qt_internal_set_compile_pdb_names().

Change-Id: Idb3cacd7a46a4f298fd584b927b5d726956faea8
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Li Xinwei 2022-04-30 23:38:02 +08:00
parent efc02f9cc3
commit 9539c8a7f8
4 changed files with 19 additions and 12 deletions

View File

@ -162,10 +162,6 @@ function(qt_internal_add_3rdparty_library target)
qt_internal_add_common_qt_library_helper(${target} ${library_helper_args})
if(NOT arg_INTERFACE)
qt_set_common_target_properties(${target})
endif()
set_target_properties(${target} PROPERTIES
_qt_module_interface_name "${target}"
)
@ -195,6 +191,10 @@ function(qt_internal_add_3rdparty_library target)
OUTPUT_NAME "${INSTALL_CMAKE_NAMESPACE}${target}"
)
if(NOT arg_INTERFACE)
qt_set_common_target_properties(${target})
endif()
if(NOT arg_SKIP_AUTOMOC)
qt_autogen_tools_initial_setup(${target})
endif()

View File

@ -177,7 +177,6 @@ function(qt_internal_add_module target)
set(property_prefix "INTERFACE_")
if(NOT arg_HEADER_MODULE)
qt_set_common_target_properties(${target})
set(property_prefix "")
endif()
@ -293,6 +292,8 @@ function(qt_internal_add_module target)
)
endif()
qt_set_common_target_properties(${target})
if (WIN32 AND BUILD_SHARED_LIBS)
_qt_internal_generate_win32_rc_file(${target})
endif()

View File

@ -117,7 +117,6 @@ function(qt_internal_add_plugin target)
endif()
endif()
qt_set_common_target_properties(${target})
qt_set_target_info_properties(${target} ${ARGN} TARGET_VERSION "${arg_VERSION}")
# Override the OUTPUT_NAME that qt6_add_plugin() set, we need to account for
@ -139,6 +138,7 @@ function(qt_internal_add_plugin target)
endif()
endif()
qt_set_common_target_properties("${target}")
qt_internal_add_target_aliases("${target}")
qt_skip_warnings_are_errors_when_repo_unclean("${target}")
_qt_internal_apply_strict_cpp("${target}")

View File

@ -650,8 +650,12 @@ function(qt_internal_set_compile_pdb_names target)
if(MSVC)
get_target_property(target_type ${target} TYPE)
if(target_type STREQUAL "STATIC_LIBRARY" OR target_type STREQUAL "OBJECT_LIBRARY")
set_target_properties(${target} PROPERTIES COMPILE_PDB_NAME "${INSTALL_CMAKE_NAMESPACE}${target}")
set_target_properties(${target} PROPERTIES COMPILE_PDB_NAME_DEBUG "${INSTALL_CMAKE_NAMESPACE}${target}d")
get_target_property(output_name ${target} OUTPUT_NAME)
if(NOT output_name)
set(output_name "${INSTALL_CMAKE_NAMESPACE}${target}")
endif()
set_target_properties(${target} PROPERTIES COMPILE_PDB_NAME "${output_name}")
set_target_properties(${target} PROPERTIES COMPILE_PDB_NAME_DEBUG "${output_name}d")
endif()
endif()
endfunction()
@ -712,8 +716,9 @@ function(qt_internal_install_pdb_files target install_dir_path)
"Can't install pdb file for static library ${target}. "
"The ARCHIVE_OUTPUT_DIRECTORY path is not known.")
endif()
set(pdb_name "${INSTALL_CMAKE_NAMESPACE}${target}$<$<CONFIG:Debug>:d>.pdb")
qt_path_join(compile_time_pdb_file_path "${lib_dir}" "${pdb_name}")
get_target_property(pdb_name "${target}" COMPILE_PDB_NAME)
qt_path_join(compile_time_pdb_file_path
"${lib_dir}" "${pdb_name}$<$<CONFIG:Debug>:d>.pdb")
qt_install(FILES "${compile_time_pdb_file_path}"
DESTINATION "${install_dir_path}" OPTIONAL)
@ -725,8 +730,9 @@ function(qt_internal_install_pdb_files target install_dir_path)
qt_path_join(pdb_dir "${pdb_dir}" "$<CONFIG>")
endif()
endif()
set(pdb_name "${INSTALL_CMAKE_NAMESPACE}${target}$<$<CONFIG:Debug>:d>.pdb")
qt_path_join(compile_time_pdb_file_path "${pdb_dir}" "${pdb_name}")
get_target_property(pdb_name "${target}" COMPILE_PDB_NAME)
qt_path_join(compile_time_pdb_file_path
"${pdb_dir}" "${pdb_name}$<$<CONFIG:Debug>:d>.pdb")
qt_install(FILES "${compile_time_pdb_file_path}"
DESTINATION "${install_dir_path}" OPTIONAL)