Skip to content

Commit

Permalink
Fix vp_get_interface_link_libraries macro to support VTK 9.2.6 that b…
Browse files Browse the repository at this point in the history
…rings Qt6 when ustk is used as an external contrib module
  • Loading branch information
fspindle committed Jul 15, 2024
1 parent dd1eb6b commit 05d7b43
Showing 1 changed file with 22 additions and 25 deletions.
47 changes: 22 additions & 25 deletions cmake/VISPUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -342,15 +342,6 @@ macro(vp_list_filterout lst regex)
endforeach()
endmacro()

# remove all matching elements from the list
macro(vp_list_filterout lst regex)
foreach(item ${${lst}})
if(item MATCHES "${regex}")
list(REMOVE_ITEM ${lst} "${item}")
endif()
endforeach()
endmacro()

# stable & safe duplicates removal macro
macro(vp_list_unique __lst)
if(${__lst})
Expand All @@ -372,6 +363,17 @@ macro(vp_list_remove_empty __lst)
endif()
endmacro()

# list directory elements removal macro
macro(vp_list_remove_directory lst)
if(${lst})
foreach(item ${${lst}})
if(IS_DIRECTORY ${item})
list(REMOVE_ITEM ${lst} "${item}")
endif()
endforeach()
endif()
endmacro()

# needed by visp-java
if(CMAKE_VERSION VERSION_LESS "3.2")
macro(vp_cmake_byproducts var_name)
Expand Down Expand Up @@ -1391,58 +1393,52 @@ macro(vp_get_interface_link_libraries libs link_libraries)
set(__imported_libs ${${libs}})
set(__libs ${${libs}})
foreach(lib_ ${${libs}})
# message("lib_: ${lib_}")
if(TARGET ${lib_})
get_target_property(imported_libs_ ${lib_} INTERFACE_LINK_LIBRARIES)
if(imported_libs_)
list(APPEND __imported_libs ${imported_libs_})
list(APPEND __libs ${lib_})
foreach(imp_ ${imported_libs_})
if(NOT imp_ MATCHES "^\\$<")
list(APPEND __imported_libs ${imported_libs_})
list(APPEND __libs ${lib_})
endif()
endforeach()

else()
list(APPEND __libs ${lib_})
endif()
else()
list(APPEND __libs ${lib_})
endif()
endforeach()
# message("__imported_libs: ${__imported_libs}")
# message("__libs: ${__libs}")
vp_list_unique(__imported_libs)
vp_list_unique(__libs)
# message("fin __imported_libs: ${__imported_libs}")
# message("fin __libs: ${__libs}")

while(__imported_libs)
# message("begin while __imported_libs: ${__imported_libs}")
vp_list_pop_front(__imported_libs elt)
# message("Process elt: ${elt}")
if(TARGET ${elt} AND NOT elt MATCHES "^-framework") # to avoid precessing -framework ApplicationServices -framework CoreServices
# message("elt is a target and not framework: ${elt}")
get_target_property(imported_libs_ ${elt} INTERFACE_LINK_LIBRARIES)
if(imported_libs_)
list(APPEND __imported_libs ${imported_libs_})
else()
list(APPEND __libs ${elt})
endif()
else()
elseif(NOT elt MATCHES "^\\$<")
list(APPEND __libs ${elt})
endif()

vp_list_unique(__imported_libs)
endwhile()
vp_list_unique(__libs)
# message("fin2 __imported_libs: ${__imported_libs}")
# message("fin2 __libs: ${__libs}")

set(__config "RELEASE" "DEBUG")
foreach(config_ ${__config})
foreach(lib_ ${__libs})
# message("lib_: ${lib_}")
if(TARGET ${lib_})

get_target_property(imported_libs_ ${lib_} IMPORTED_IMPLIB_${config_})
if(NOT EXISTS ${imported_libs_})
get_target_property(lib_location_ ${lib_} IMPORTED_LOCATION_${config_})
endif()
# message("lib_location_: ${lib_location_}")
if(WIN32 AND EXISTS "${lib_location_}" AND "${config_}" MATCHES "RELEASE") # also valid for RELEASEWITHDEBINFO
list(APPEND ${link_libraries} optimized "${lib_location_}")
elseif(WIN32 AND EXISTS "${lib_location_}" AND "${config_}" MATCHES "DEBUG")
Expand All @@ -1452,7 +1448,6 @@ macro(vp_get_interface_link_libraries libs link_libraries)
endif()

get_target_property(lib_deps_ ${lib_} IMPORTED_LINK_INTERFACE_LIBRARIES_${config_})
# message("lib_deps_ ---------: ${lib_deps_}")
if(lib_deps_)
foreach(deps_ ${lib_deps_})
get_target_property(deps_location_ ${deps_} IMPORTED_LOCATION_${config_})
Expand Down Expand Up @@ -1486,6 +1481,8 @@ macro(vp_get_interface_link_libraries libs link_libraries)
endforeach()
endforeach()
vp_list_unique(${link_libraries})
# Additional check to remove directories like /usr/X11R6/lib that can be exported by VTK
vp_list_remove_directory(${link_libraries})
# message("link_libraries: ${link_libraries}")

endmacro()
Expand Down

0 comments on commit 05d7b43

Please sign in to comment.