From 85e25d93b3b99fbeae8541586252df2cb099081d Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 8 Jul 2021 10:41:59 +0200 Subject: [PATCH] CMake: Set IMPORTED_{SONAME|IMPLIB} for shared libs only In our *AdditionalTargetInfo.cmake we now set above target properties for shared libs only, not executables. IMPORTED_IMPLIB is only set for Windows. IMPORTED_SONAME is only set for non-Windows platforms. Pick-to: 6.2 Change-Id: If7f01e6bf5183cca0ac90f9afffd57c41b34dccd Reviewed-by: Alexandru Croitor --- cmake/QtTargetHelpers.cmake | 41 +++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/cmake/QtTargetHelpers.cmake b/cmake/QtTargetHelpers.cmake index 44328aec3f6..a4114a6eb32 100644 --- a/cmake/QtTargetHelpers.cmake +++ b/cmake/QtTargetHelpers.cmake @@ -488,15 +488,32 @@ endif()\n\n") endif() endif() - # FIXME: Don't add IMPORTED_SOLIB and IMPORTED_SONAME properties for executables. + set(write_implib FALSE) + set(write_soname FALSE) + if(target_type STREQUAL "SHARED_LIBRARY") + if(WINDOWS) + set(write_implib TRUE) + else() + set(write_soname TRUE) + endif() + endif() + if(NOT "${uc_release_cfg}" STREQUAL "") string(APPEND content "get_target_property(_qt_imported_location ${full_target} IMPORTED_LOCATION_${uc_release_cfg})\n") - string(APPEND content "get_target_property(_qt_imported_implib ${full_target} IMPORTED_IMPLIB_${uc_release_cfg})\n") - string(APPEND content "get_target_property(_qt_imported_soname ${full_target} IMPORTED_SONAME_${uc_release_cfg})\n") + if(write_implib) + string(APPEND content "get_target_property(_qt_imported_implib ${full_target} IMPORTED_IMPLIB_${uc_release_cfg})\n") + endif() + if(write_soname) + string(APPEND content "get_target_property(_qt_imported_soname ${full_target} IMPORTED_SONAME_${uc_release_cfg})\n") + endif() endif() string(APPEND content "get_target_property(_qt_imported_location_default ${full_target} IMPORTED_LOCATION_$\\{QT_DEFAULT_IMPORT_CONFIGURATION})\n") - string(APPEND content "get_target_property(_qt_imported_implib_default ${full_target} IMPORTED_IMPLIB_$\\{QT_DEFAULT_IMPORT_CONFIGURATION})\n") - string(APPEND content "get_target_property(_qt_imported_soname_default ${full_target} IMPORTED_SONAME_$\\{QT_DEFAULT_IMPORT_CONFIGURATION})\n") + if(write_implib) + string(APPEND content "get_target_property(_qt_imported_implib_default ${full_target} IMPORTED_IMPLIB_$\\{QT_DEFAULT_IMPORT_CONFIGURATION})\n") + endif() + if(write_soname) + string(APPEND content "get_target_property(_qt_imported_soname_default ${full_target} IMPORTED_SONAME_$\\{QT_DEFAULT_IMPORT_CONFIGURATION})\n") + endif() foreach(config ${configurations_to_export} "") string(TOUPPER "${config}" ucconfig) if("${config}" STREQUAL "") @@ -514,14 +531,20 @@ set_property(TARGET ${full_target} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${ucc string(APPEND content " if(_qt_imported_location${var_suffix}) set_property(TARGET ${full_target} PROPERTY IMPORTED_LOCATION${property_suffix} \"$\\{_qt_imported_location${var_suffix}}\") -endif() +endif()") + if(write_implib) + string(APPEND content " if(_qt_imported_implib${var_suffix}) set_property(TARGET ${full_target} PROPERTY IMPORTED_IMPLIB${property_suffix} \"$\\{_qt_imported_implib${var_suffix}}\") -endif() +endif()") + endif() + if(write_soname) + string(APPEND content " if(_qt_imported_soname${var_suffix}) set_property(TARGET ${full_target} PROPERTY IMPORTED_SONAME${property_suffix} \"$\\{_qt_imported_soname${var_suffix}}\") -endif() -") +endif()") + endif() + string(APPEND content "\n") endforeach() endforeach()