Skip to content

Commit

Permalink
modernize if available
Browse files Browse the repository at this point in the history
  • Loading branch information
nim65s committed Jul 14, 2022
1 parent f0b5fe8 commit c1a21e9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 46 deletions.
14 changes: 1 addition & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,19 +109,7 @@ ELSE(WIN32)
ADD_PROJECT_DEPENDENCY(Boost REQUIRED chrono serialization)
ENDIF(WIN32)
if(BUILD_PYTHON_INTERFACE)
set(PYTHON_COMPONENTS Interpreter)
if(CMAKE_VERSION VERSION_LESS "3.18")
# Development.Module only require headers, so it's best for our module
# But it's not available before CMake 3.18
set(PYTHON_COMPONENTS ${PYTHON_COMPONENTS} Development)
else()
set(PYTHON_COMPONENTS ${PYTHON_COMPONENTS} Development.Module)
endif()
if(NOT CMAKE_VERSION VERSION_LESS "3.14")
# NumPy provides a standard CMake imported target,
# But it's not available before CMake 3.14
set(PYTHON_COMPONENTS ${PYTHON_COMPONENTS} NumPy)
endif()
set(PYTHON_COMPONENTS Interpreter Development.Module NumPy)
FINDPYTHON()
search_for_boost_python(REQUIRED)
find_package(Boost REQUIRED COMPONENTS system)
Expand Down
2 changes: 1 addition & 1 deletion cmake
7 changes: 1 addition & 6 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,7 @@ IF(ENABLE_DOXYGEN_AUTODOC)
TARGET_COMPILE_DEFINITIONS(${LIBRARY_NAME} PRIVATE -DHPP_FCL_HAS_DOXYGEN_AUTODOC)
ENDIF()

if(TARGET Boost::python3${Python3_VERSION_MINOR} AND NOT APPLE)
TARGET_LINK_LIBRARIES(${LIBRARY_NAME} PUBLIC
Boost::python3${Python3_VERSION_MINOR})
else()
TARGET_LINK_BOOST_PYTHON(${LIBRARY_NAME} PUBLIC)
endif()
TARGET_LINK_BOOST_PYTHON(${LIBRARY_NAME} PUBLIC)
TARGET_LINK_LIBRARIES(${LIBRARY_NAME} PUBLIC
${PROJECT_NAME}
eigenpy::eigenpy
Expand Down
33 changes: 7 additions & 26 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -179,18 +179,10 @@ set_target_properties(${PROJECT_NAME} PROPERTIES INSTALL_RPATH "\$ORIGIN")
ADD_SOURCE_GROUP(${LIBRARY_NAME}_SOURCES)
ADD_HEADER_GROUP(PROJECT_HEADERS_FULL_PATH)

if(TARGET assimp::assimp)
TARGET_LINK_LIBRARIES(${LIBRARY_NAME} PRIVATE assimp::assimp)
else()
TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
PRIVATE
${assimp_LIBRARIES}
)
target_include_directories(${LIBRARY_NAME}
SYSTEM PRIVATE
${assimp_INCLUDE_DIR}
)
endif()
MODERNIZE_LINK(${LIBRARY_NAME} SCOPE PRIVATE
TARGETS assimp::assimp
LIBRARIES ${assimp_LIBRARIES}
INCLUDE_DIRS ${assimp_INCLUDE_DIR})

TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
PUBLIC
Expand All @@ -217,27 +209,16 @@ if(HPP_FCL_HAS_QHULL)
endif()
endif()

if(TARGET Eigen3::Eigen)
target_link_libraries(${LIBRARY_NAME} PUBLIC Eigen3::Eigen)
else()
target_include_directories(${LIBRARY_NAME}
SYSTEM PUBLIC
${EIGEN3_INCLUDE_DIR}
)
endif()
MODERNIZE_LINK(${PROJECT_NAME} SCOPE PUBLIC TARGETS Eigen3::Eigen INCLUDE_DIRS ${EIGEN3_INCLUDE_DIR})

target_include_directories(${LIBRARY_NAME}
PUBLIC
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

IF(octomap_FOUND)
if(TARGET octomap)
target_link_libraries(${LIBRARY_NAME} PUBLIC octomap)
else()
target_include_directories(${LIBRARY_NAME} SYSTEM PUBLIC ${OCTOMAP_INCLUDE_DIRS})
target_link_libraries(${LIBRARY_NAME} PUBLIC ${OCTOMAP_LIBRARIES})
endif()
MODERNIZE_LINK(${PROJECT_NAME} SCOPE PUBLIC TARGETS octomap
LIBRARIES ${OCTOMAP_LIBRARIES} INCLUDE_DIRS ${OCTOMAP_INCLUDE_DIRS})
target_compile_definitions (${LIBRARY_NAME} PUBLIC
-DHPP_FCL_HAS_OCTOMAP
-DHPP_FCL_HAVE_OCTOMAP
Expand Down

0 comments on commit c1a21e9

Please sign in to comment.