Skip to content

Commit b631e4c

Browse files
rh101minggo
authored andcommitted
Support interface only libraries (#19855)
* Added RenderTexture::saveToFileAsNonPMA() to save images without PMA. Set the PMA parameter to true when calling initWithRawData() inside RenderTexture::newImage(), since textures are PMA. Renamed Image::premultipliedAlpha() to Image::premultiplyAlpha() to better reflect it's action, and made it public. Added Image::reversePremultipliedAlpha() to allow the reversing of the PMA. Updated CCImage-ios.mm to set the correct bitmapInfo for PMA and non-PMA images before saving a file. Updated RenderTextureTest::RenderTextureSave() to cater for non-PMA file saving. * [CCImage-ios.mm] Fixed indentation. * Added support for interface-only libraries being linked to application via target_link_libraries. Certain library properties cannot be accessed if it is an interface only library, so we need to check if they are valid library types before accessing those properties. * Fixed formatting.
1 parent 888682b commit b631e4c

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

cmake/Modules/CocosBuildHelpers.cmake

+24-14
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,23 @@ function(search_depend_libs_recursive cocos_target all_depends_out)
6060
set(targets_prepare_search ${cocos_target})
6161
while(true)
6262
foreach(tmp_target ${targets_prepare_search})
63-
get_target_property(tmp_depend_libs ${tmp_target} LINK_LIBRARIES)
64-
list(REMOVE_ITEM targets_prepare_search ${tmp_target})
65-
list(APPEND tmp_depend_libs ${tmp_target})
66-
foreach(depend_lib ${tmp_depend_libs})
67-
if(TARGET ${depend_lib})
68-
list(APPEND all_depends_inner ${depend_lib})
69-
if(NOT (depend_lib STREQUAL tmp_target))
70-
list(APPEND targets_prepare_search ${depend_lib})
63+
get_target_property(target_type ${tmp_target} TYPE)
64+
if(${target_type} STREQUAL "SHARED_LIBRARY" OR ${target_type} STREQUAL "STATIC_LIBRARY" OR ${target_type} STREQUAL "MODULE_LIBRARY" OR ${target_type} STREQUAL "EXECUTABLE")
65+
#interface-only libraries do not support certain properties such as LINK_LIBRARIES
66+
get_target_property(tmp_depend_libs ${tmp_target} LINK_LIBRARIES)
67+
list(REMOVE_ITEM targets_prepare_search ${tmp_target})
68+
list(APPEND tmp_depend_libs ${tmp_target})
69+
foreach(depend_lib ${tmp_depend_libs})
70+
if(TARGET ${depend_lib})
71+
list(APPEND all_depends_inner ${depend_lib})
72+
if(NOT (depend_lib STREQUAL tmp_target))
73+
list(APPEND targets_prepare_search ${depend_lib})
74+
endif()
7175
endif()
72-
endif()
73-
endforeach()
76+
endforeach()
77+
else()
78+
list(REMOVE_ITEM targets_prepare_search ${tmp_target})
79+
endif()
7480
endforeach()
7581
list(LENGTH targets_prepare_search targets_prepare_search_size)
7682
if(targets_prepare_search_size LESS 1)
@@ -88,10 +94,14 @@ function(get_target_depends_ext_dlls cocos_target all_depend_dlls_out)
8894
search_depend_libs_recursive(${cocos_target} depend_libs)
8995
foreach(depend_lib ${depend_libs})
9096
if(TARGET ${depend_lib})
91-
get_target_property(found_shared_lib ${depend_lib} IMPORTED_IMPLIB)
92-
if(found_shared_lib)
93-
get_target_property(tmp_dlls ${depend_lib} IMPORTED_LOCATION)
94-
list(APPEND all_depend_ext_dlls ${tmp_dlls})
97+
get_target_property(target_type ${depend_lib} TYPE)
98+
if(${target_type} STREQUAL "SHARED_LIBRARY" OR ${target_type} STREQUAL "STATIC_LIBRARY" OR ${target_type} STREQUAL "MODULE_LIBRARY" OR ${target_type} STREQUAL "EXECUTABLE")
99+
#interface-only libraries do not support certain properties such as IMPORTED_IMPLIB
100+
get_target_property(found_shared_lib ${depend_lib} IMPORTED_IMPLIB)
101+
if(found_shared_lib)
102+
get_target_property(tmp_dlls ${depend_lib} IMPORTED_LOCATION)
103+
list(APPEND all_depend_ext_dlls ${tmp_dlls})
104+
endif()
95105
endif()
96106
endif()
97107
endforeach()

0 commit comments

Comments
 (0)