Skip to content

Commit

Permalink
[all] Fix tinyxml2 dependency (#4574)
Browse files Browse the repository at this point in the history
* Create real imported target instead o interface

* test macos install tinyxml2

* fix tinyxml2 rpath

---------

Co-authored-by: Hugo <[email protected]>
  • Loading branch information
bakpaul and hugtalbot committed Mar 11, 2024
1 parent 513a06c commit b27a54d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 3 additions & 3 deletions Sofa/framework/Simulation/Common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
7 changes: 5 additions & 2 deletions cmake/Modules/FindTinyXML2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 3 additions & 0 deletions tools/postinstall-fixup/macos-postinstall-fixup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit b27a54d

Please sign in to comment.