Skip to content

Commit

Permalink
Use target_link_libraries to handle link-type keywords correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
jslee02 committed May 29, 2022
1 parent 4a52f2a commit cb4b71b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 32 deletions.
18 changes: 2 additions & 16 deletions cmake/DARTFindBullet.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,13 @@
#
# This file is provided under the "BSD-style" License

include(CMakeParseArguments)

# Bullet. Force MODULE mode to use the FindBullet.cmake file distributed with
# CMake. Otherwise, we may end up using the BulletConfig.cmake file distributed
# with Bullet, which uses relative paths and may break transitive dependencies.
find_package(Bullet COMPONENTS BulletMath BulletCollision MODULE QUIET)

if((BULLET_FOUND OR Bullet_FOUND) AND NOT TARGET Bullet)
if(WIN32 AND "optimized" IN_LIST BULLET_LIBRARIES
AND "debug" IN_LIST BULLET_LIBRARIES)
cmake_parse_arguments(BULLET_INTERFACE_LIBRARIES "" "" "debug;optimized"
${BULLET_LIBRARIES})
set(BULLET_INTERFACE_LIBRARIES
$<$<CONFIG:Debug>:${BULLET_INTERFACE_LIBRARIES_debug}>
$<$<NOT:$<CONFIG:Debug>>:${BULLET_INTERFACE_LIBRARIES_optimized}>)
else()
set(BULLET_INTERFACE_LIBRARIES ${BULLET_LIBRARIES})
endif()
add_library(Bullet INTERFACE IMPORTED)
set_target_properties(Bullet PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${BULLET_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${BULLET_INTERFACE_LIBRARIES}"
)
target_include_directories(Bullet INTERFACE ${BULLET_INCLUDE_DIRS})
target_link_libraries(Bullet INTERFACE ${BULLET_LIBRARIES})
endif()
18 changes: 2 additions & 16 deletions cmake/DARTFindOpenSceneGraph.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#
# This file is provided under the "BSD-style" License

include(CMakeParseArguments)

if (CMAKE_VERSION VERSION_LESS 3.12)
get_property(old_find_library_use_lib64_paths GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS TRUE)
Expand Down Expand Up @@ -57,19 +55,7 @@ endif()
# variables contain absolute paths of OpenSceneGraph that could be different in
# where the system that DART is built and where the system that consumes DART.
if((OPENSCENEGRAPH_FOUND OR OpenSceneGraph_FOUND) AND NOT TARGET osg::osg)
if(WIN32 AND "optimized" IN_LIST OPENSCENEGRAPH_LIBRARIES
AND "debug" IN_LIST OPENSCENEGRAPH_LIBRARIES)
cmake_parse_arguments(OPENSCENEGRAPH_INTERFACE_LIBRARIES "" "" "debug;optimized"
${OPENSCENEGRAPH_LIBRARIES})
set(OPENSCENEGRAPH_INTERFACE_LIBRARIES
$<$<CONFIG:Debug>:${OPENSCENEGRAPH_INTERFACE_LIBRARIES_debug}>
$<$<NOT:$<CONFIG:Debug>>:${OPENSCENEGRAPH_INTERFACE_LIBRARIES_optimized}>)
else()
set(OPENSCENEGRAPH_INTERFACE_LIBRARIES ${OPENSCENEGRAPH_LIBRARIES})
endif()
add_library(osg::osg INTERFACE IMPORTED)
set_target_properties(osg::osg PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${OPENSCENEGRAPH_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${OPENSCENEGRAPH_INTERFACE_LIBRARIES}"
)
target_include_directories(osg::osg INTERFACE ${OPENSCENEGRAPH_INCLUDE_DIRS})
target_link_libraries(osg::osg INTERFACE ${OPENSCENEGRAPH_LIBRARIES})
endif()

0 comments on commit cb4b71b

Please sign in to comment.