From b27a54d778c7c7903f31404d2db55527d76d2525 Mon Sep 17 00:00:00 2001 From: Paul Baksic <30337881+bakpaul@users.noreply.github.com> Date: Fri, 8 Mar 2024 20:32:48 +0100 Subject: [PATCH] [all] Fix tinyxml2 dependency (#4574) * Create real imported target instead o interface * test macos install tinyxml2 * fix tinyxml2 rpath --------- Co-authored-by: Hugo --- Sofa/framework/Simulation/Common/CMakeLists.txt | 6 +++--- cmake/Modules/FindTinyXML2.cmake | 7 +++++-- tools/postinstall-fixup/macos-postinstall-fixup.sh | 3 +++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Sofa/framework/Simulation/Common/CMakeLists.txt b/Sofa/framework/Simulation/Common/CMakeLists.txt index 19ffb4de7c1..0afa122d21d 100644 --- a/Sofa/framework/Simulation/Common/CMakeLists.txt +++ b/Sofa/framework/Simulation/Common/CMakeLists.txt @@ -41,10 +41,10 @@ sofa_find_package(Sofa.Core REQUIRED) sofa_find_package(Sofa.Simulation.Core REQUIRED) sofa_find_package(TinyXML2 REQUIRED) -if(CMAKE_SYSTEM_NAME STREQUAL Windows) - sofa_install_libraries(TARGETS tinyxml2::tinyxml2) -else() +if(UNIX AND NOT APPLE) sofa_install_libraries(PATHS ${TinyXML2_LIBRARY}) +else() + sofa_install_libraries(TARGETS tinyxml2::tinyxml2) endif() add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES}) diff --git a/cmake/Modules/FindTinyXML2.cmake b/cmake/Modules/FindTinyXML2.cmake index 20dc67353c5..6dda44b060d 100644 --- a/cmake/Modules/FindTinyXML2.cmake +++ b/cmake/Modules/FindTinyXML2.cmake @@ -40,8 +40,11 @@ else() set(TinyXML2_INCLUDE_DIRS ${TinyXML2_INCLUDE_DIR}) if(NOT TARGET tinyxml2::tinyxml2) - add_library(tinyxml2::tinyxml2 INTERFACE IMPORTED) - set_property(TARGET tinyxml2::tinyxml2 PROPERTY INTERFACE_LINK_LIBRARIES "${TinyXML2_LIBRARIES}") + add_library(tinyxml2::tinyxml2 SHARED IMPORTED) + set_property(TARGET tinyxml2::tinyxml2 PROPERTY IMPORTED_LOCATION "${TinyXML2_LIBRARIES}") + if(WIN32) + set_property(TARGET tinyxml2::tinyxml2 PROPERTY IMPORTED_IMPLIB "${TinyXML2_LIBRARIES}") + endif() set_property(TARGET tinyxml2::tinyxml2 PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${TinyXML2_INCLUDE_DIR}") endif() else() diff --git a/tools/postinstall-fixup/macos-postinstall-fixup.sh b/tools/postinstall-fixup/macos-postinstall-fixup.sh index 60a17db6c25..d29865ab2c4 100644 --- a/tools/postinstall-fixup/macos-postinstall-fixup.sh +++ b/tools/postinstall-fixup/macos-postinstall-fixup.sh @@ -114,6 +114,7 @@ check-all-deps() { echo "$dependencies" | grep --quiet "/libicu" || echo "$dependencies" | grep --quiet "/libGLEW" || echo "$dependencies" | grep --quiet "/libjpeg" || + echo "$dependencies" | grep --quiet "/libtinyxml2" || echo "$dependencies" | grep --quiet "/libpng" ; then is_fixup_needed="true" fi @@ -134,6 +135,8 @@ check-all-deps() { libname="$libjpeg" elif libpng="$(echo $dep | egrep -o "/libpng[^\/]*?\.dylib$" | cut -c2-)" && [ -n "$libpng" ]; then libname="$libpng" + elif libtinyxml2="$(echo $dep | egrep -o "/libtinyxml2[^\/]*?\.dylib$" | cut -c2-)" && [ -n "$libtinyxml2" ]; then + libname="$libtinyxml2" elif libtiff="$(echo $dep | egrep -o "/libtiff[^\/]*?\.dylib$" | cut -c2-)" && [ -n "$libtiff" ]; then libname="$libtiff" else