Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Bullet linking on MacOS #1101

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions tesseract_common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,22 @@ endif()
include(cmake/tesseract_macros.cmake)
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/")

find_package(
Boost REQUIRED
COMPONENTS system
filesystem
serialization
stacktrace_noop
OPTIONAL_COMPONENTS stacktrace_backtrace stacktrace_basic)
if(NOT APPLE)
find_package(
Boost REQUIRED
COMPONENTS system
filesystem
serialization
stacktrace_noop
OPTIONAL_COMPONENTS stacktrace_backtrace stacktrace_basic)
else()
find_package(
Boost REQUIRED
COMPONENTS system
filesystem
serialization
stacktrace_noop)
endif()
Levi-Armstrong marked this conversation as resolved.
Show resolved Hide resolved
find_package(Eigen3 REQUIRED)
find_package(TinyXML2 REQUIRED)
find_package(yaml-cpp REQUIRED)
Expand Down
83 changes: 50 additions & 33 deletions tesseract_common/cmake/tesseract_macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -167,29 +167,6 @@ macro(find_bullet)
WARNING "Bullet does not appear to be build with double precision, current definitions: ${BULLET_DEFINITIONS}")
endif()

# Some Bullet installations (vcpkg) use absolute paths instead of relative to BULLET_ROOT_DIR in the CMake vars
set(BULLET_INCLUDE_DIRS_ABS "")
set(BULLET_LIBRARY_DIRS_ABS "")
if(NOT IS_ABSOLUTE "${BULLET_INCLUDE_DIR}")
foreach(dir IN LISTS BULLET_INCLUDE_DIRS)
list(APPEND BULLET_INCLUDE_DIRS_ABS "${BULLET_ROOT_DIR}/${dir}")
endforeach()
foreach(dir IN LISTS BULLET_LIBRARY_DIRS)
list(APPEND BULLET_LIBRARY_DIRS_ABS "${BULLET_ROOT_DIR}/${dir}")
endforeach()
else()
set(BULLET_INCLUDE_DIRS_ABS ${BULLET_INCLUDE_DIRS})
set(BULLET_LIBRARY_DIRS_ABS ${BULLET_LIBRARY_DIRS})
endif()

set(BULLET_LIBRARIES_ABS "")
foreach(BULLET_LIB IN LISTS BULLET_LIBRARIES)
find_library(BULLET_LIB_ABS_${BULLET_LIB} ${BULLET_LIB} PATHS ${BULLET_LIBRARY_DIRS_ABS} NO_DEFAULT_PATH REQUIRED)
list(APPEND BULLET_LIBRARIES_ABS "${BULLET_LIB_ABS_${BULLET_LIB}}")
message(STATUS "BULLET_LIB=${BULLET_LIB} BULLET_LIB_ABS=${BULLET_LIB_ABS_${BULLET_LIB}}")
endforeach()
message(STATUS "BULLET_LIBRARIES_ABS=${BULLET_LIBRARIES_ABS}")

set(BULLET_DEFINITIONS_STRIPED "")
foreach(DEF ${BULLET_DEFINITIONS})
string(STRIP ${DEF} DEF)
Expand All @@ -207,16 +184,56 @@ macro(find_bullet)
endif()
endforeach()

if(NOT TARGET Bullet3::Bullet)
add_library(Bullet3::Bullet INTERFACE IMPORTED)
set_target_properties(Bullet3::Bullet PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${BULLET_INCLUDE_DIRS_ABS}")
set_target_properties(Bullet3::Bullet PROPERTIES INTERFACE_LINK_LIBRARIES "${BULLET_LIBRARIES_ABS}")
set_target_properties(Bullet3::Bullet PROPERTIES INTERFACE_COMPILE_DEFINITIONS "${BULLET_DEFINITIONS_STRIPED}")
endif()
if(TARGET Bullet3Common)
if(NOT TARGET Bullet3::Bullet)
add_library(Bullet3::Bullet INTERFACE IMPORTED)
if(NOT WIN32)
set_target_properties(Bullet3::Bullet PROPERTIES INTERFACE_LINK_LIBRARIES
"BulletCollision;Bullet3Geometry;Bullet3Common;LinearMath")
else()
set_target_properties(Bullet3::Bullet PROPERTIES INTERFACE_LINK_LIBRARIES
"BulletCollision;Bullet3Common;LinearMath")
endif()

find_library(HACD_LIBRARY HACD HINTS ${BULLET_LIBRARY_DIRS_ABS})
if(NOT HACD_LIBRARY)
message(
WARNING "HACD not found! Convex decomposition library will not be built. Install libbullet-extras-dev on Linux.")
set_target_properties(Bullet3::Bullet PROPERTIES INTERFACE_COMPILE_DEFINITIONS "${BULLET_DEFINITIONS_STRIPED}")
endif()
else()

# Some Bullet installations (vcpkg) use absolute paths instead of relative to BULLET_ROOT_DIR in the CMake vars
set(BULLET_INCLUDE_DIRS_ABS "")
set(BULLET_LIBRARY_DIRS_ABS "")
if(NOT IS_ABSOLUTE "${BULLET_INCLUDE_DIR}")
foreach(dir IN LISTS BULLET_INCLUDE_DIRS)
list(APPEND BULLET_INCLUDE_DIRS_ABS "${BULLET_ROOT_DIR}/${dir}")
endforeach()
foreach(dir IN LISTS BULLET_LIBRARY_DIRS)
list(APPEND BULLET_LIBRARY_DIRS_ABS "${BULLET_ROOT_DIR}/${dir}")
endforeach()
else()
set(BULLET_INCLUDE_DIRS_ABS ${BULLET_INCLUDE_DIRS})
set(BULLET_LIBRARY_DIRS_ABS ${BULLET_LIBRARY_DIRS})
endif()

set(BULLET_LIBRARIES_ABS "")
foreach(BULLET_LIB IN LISTS BULLET_LIBRARIES)
find_library(BULLET_LIB_ABS_${BULLET_LIB} ${BULLET_LIB} PATHS ${BULLET_LIBRARY_DIRS_ABS} NO_DEFAULT_PATH REQUIRED)
list(APPEND BULLET_LIBRARIES_ABS "${BULLET_LIB_ABS_${BULLET_LIB}}")
message(STATUS "BULLET_LIB=${BULLET_LIB} BULLET_LIB_ABS=${BULLET_LIB_ABS_${BULLET_LIB}}")
endforeach()
message(STATUS "BULLET_LIBRARIES_ABS=${BULLET_LIBRARIES_ABS}")

if(NOT TARGET Bullet3::Bullet)
add_library(Bullet3::Bullet INTERFACE IMPORTED)
set_target_properties(Bullet3::Bullet PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${BULLET_INCLUDE_DIRS_ABS}")
set_target_properties(Bullet3::Bullet PROPERTIES INTERFACE_LINK_LIBRARIES "${BULLET_LIBRARIES_ABS}")
set_target_properties(Bullet3::Bullet PROPERTIES INTERFACE_COMPILE_DEFINITIONS "${BULLET_DEFINITIONS_STRIPED}")
endif()

find_library(HACD_LIBRARY HACD HINTS ${BULLET_LIBRARY_DIRS_ABS})
if(NOT HACD_LIBRARY)
message(
WARNING "HACD not found! Convex decomposition library will not be built. Install libbullet-extras-dev on Linux."
)
endif()
endif()
endmacro()
Loading