From b417be3e5121003cc4dce8cc46dcc7d66d2332d0 Mon Sep 17 00:00:00 2001 From: Joseph Mirabel <jmirabel@laas.fr> Date: Tue, 19 Nov 2019 14:53:18 +0100 Subject: [PATCH] [CMake] Use 'by target' API of CMake --- CMakeLists.txt | 10 ---------- src/CMakeLists.txt | 17 +++++++++++++---- test/CMakeLists.txt | 6 +++++- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index be6e8e18..9addae60 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,7 +55,6 @@ COMPUTE_PROJECT_ARGS(PROJECT_ARGS LANGUAGES CXX) PROJECT(${PROJECT_NAME} ${PROJECT_ARGS}) add_required_dependency("eigen3 >= 3.0.0") -include_directories(SYSTEM ${EIGEN3_INCLUDE_DIRS}) # Add a cache variable to allow not compiling and running tests set (RUN_TESTS TRUE CACHE BOOL "compile and run unit tests") @@ -74,7 +73,6 @@ search_for_boost() # Optional dependencies add_optional_dependency("octomap >= 1.6") if (OCTOMAP_FOUND) - include_directories(SYSTEM ${OCTOMAP_INCLUDE_DIRS}) link_directories(${OCTOMAP_LIBRARY_DIRS}) SET(HPP_FCL_HAVE_OCTOMAP TRUE) add_definitions (-DHPP_FCL_HAVE_OCTOMAP) @@ -92,14 +90,6 @@ else() endif() ADD_REQUIRED_DEPENDENCY("assimp >= 2.0") -if(ASSIMP_FOUND) - if (NOT ${ASSIMP_VERSION} VERSION_LESS "2.0.1150") - add_definitions(-DHPP_FCL_USE_ASSIMP_UNIFIED_HEADER_NAMES) - message(STATUS "Assimp version has unified headers") - else() - message(STATUS "Assimp version does not have unified headers") - endif() -endif() SET(${PROJECT_NAME}_HEADERS include/hpp/fcl/collision_data.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3ffd1688..498332f1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -82,8 +82,6 @@ set(${LIBRARY_NAME}_SOURCES mesh_loader/loader.cpp ) -# Declare boost include directories -include_directories(SYSTEM ${Boost_INCLUDE_DIRS}) link_directories(${Boost_LIBRARY_DIRS}) add_library(${LIBRARY_NAME} @@ -91,11 +89,22 @@ add_library(${LIBRARY_NAME} ${${LIBRARY_NAME}_SOURCES} ) TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${Boost_LIBRARIES}) + +target_include_directories(${LIBRARY_NAME} SYSTEM PUBLIC + ${EIGEN3_INCLUDE_DIRS} + ${Boost_INCLUDE_DIRS} + $<$<BOOL:${HPP_FCL_HAVE_OCTOMAP}>:${OCTOMAP_INCLUDE_DIRS}> + ) + PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} assimp) +if (NOT ${ASSIMP_VERSION} VERSION_LESS "2.0.1150") + target_compile_definitions(${LIBRARY_NAME} PRIVATE -DHPP_FCL_USE_ASSIMP_UNIFIED_HEADER_NAMES) + message(STATUS "Assimp version has unified headers") +else() + message(STATUS "Assimp version does not have unified headers") +endif() IF(OCTOMAP_FOUND) PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} octomap) ENDIF(OCTOMAP_FOUND) -#PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} flann) - install(TARGETS ${LIBRARY_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 2db77cc8..11618f72 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -20,9 +20,13 @@ macro(add_fcl_test test_name) endmacro(add_fcl_test) include_directories(${CMAKE_CURRENT_BINARY_DIR}) -include_directories(SYSTEM ${Boost_INCLUDE_DIRS}) add_library(utility STATIC utility.cpp) +target_include_directories(utility SYSTEM PUBLIC + ${EIGEN3_INCLUDE_DIRS} + ${Boost_INCLUDE_DIRS} + $<$<BOOL:${HPP_FCL_HAVE_OCTOMAP}>:${OCTOMAP_INCLUDE_DIRS}> + ) add_fcl_test(math math.cpp) -- GitLab