diff --git a/.appveyor.yml b/.appveyor.yml index e75d122e1..7b25a506d 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -48,7 +48,7 @@ before_build: - cmd: set - cmd: mkdir build - cmd: cd build - - cmd: cmake -G "%CMAKE_GENERATOR_NAME%" -DCMAKE_BUILD_TYPE=%Configuration% -DCCD_INCLUDE_DIRS="C:\%PROGRAM_FILES_PATH%\libccd\include" -DCCD_LIBRARY="C:\%PROGRAM_FILES_PATH%\libccd\lib\ccd.lib" -DEIGEN3_INCLUDE_DIR="C:\%PROGRAM_FILES_PATH%\Eigen\include\eigen3" .. + - cmd: cmake -G "%CMAKE_GENERATOR_NAME%" -DCMAKE_BUILD_TYPE=%Configuration% -DCCD_INCLUDE_DIR="C:\%PROGRAM_FILES_PATH%\libccd\include" -DCCD_LIBRARY="C:\%PROGRAM_FILES_PATH%\libccd\lib\ccd.lib" -DEIGEN3_INCLUDE_DIR="C:\%PROGRAM_FILES_PATH%\Eigen\include\eigen3" .. build: project: C:\projects\fcl\build\fcl.sln diff --git a/CMakeLists.txt b/CMakeLists.txt index d3f5b143d..599d398e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -99,83 +99,134 @@ if(FCL_COVERALLS) endif() find_package(PkgConfig QUIET) +set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH ON) -# Find Eigen3 -find_package(Eigen3 3.0.5 QUIET) -if(EIGEN3_FOUND) +#=============================================================================== +# Find required dependency Eigen3 (>= 3.0.5) +# +# If Eigen3 is not found, manually set the cache variable EIGEN3_INCLUDE_DIR +#=============================================================================== +find_package(Eigen3 3.0.5 QUIET CONFIG) + +# If Eigen3Config.cmake is not found, use the FindEigen3.cmake module +if(NOT Eigen3_FOUND) + find_package(Eigen3 3.0.5 QUIET MODULE) + set(Eigen3_FOUND ON) +endif() + +if(Eigen3_FOUND) set(FCL_HAVE_EIGEN TRUE) - include_directories(SYSTEM ${EIGEN3_INCLUDE_DIR}) else() message(SEND_ERROR "EIGEN3 (>= 3.0.5) is required by FCL") set(FCL_HAVE_EIGEN FALSE) endif() -# Find libccd +#=============================================================================== +# Find required dependency libccd +# +# If libccd is not found, manually set the cache variables CCD_INCLUDE_DIR and +# CCD_LIBRARY +#=============================================================================== find_package(ccd QUIET) -if(NOT CCD_FOUND AND PKG_CONFIG_FOUND) - pkg_check_modules(CCD ccd) - # check to see if the pkg is installed under the libccd name - if(NOT CCD_FOUND) - pkg_check_modules(CCD libccd) +# If ccd-config.cmake is not found, use pkg-config and/or find_path() and +# find_library() +if(NOT ccd_FOUND) + if(PKG_CONFIG_FOUND) + pkg_check_modules(PC_CCD ccd) + pkg_check_modules(PC_LIBCCD libccd) + endif() + + find_path(CCD_INCLUDE_DIR ccd/ccd.h + HINTS "${PC_CCD_INCLUDE_DIRS}" "${PC_LIBCCD_INCLUDE_DIRS}") + + # Using find_library() even if pkg-config is available ensures that the full + # path to the ccd library is available in CCD_LIBRARIES + find_library(CCD_LIBRARY ccd + HINTS "${PC_CCD_LIBRARY_DIRS}" "${PC_LIBCCD_LIBRARY_DIRS}") + + # libccd links to LibM on UNIX. + if(CYGWIN OR NOT WIN32) + find_library(M_LIBRARY m) + endif() + + if(CCD_INCLUDE_DIR AND CCD_LIBRARY) + set(CCD_INCLUDE_DIRS "${CCD_INCLUDE_DIR}") + set(CCD_LIBRARIES "${CCD_LIBRARY}" "${M_LIBRARY}") + set(ccd_FOUND ON) + + mark_as_advanced(CCD_INCLUDE_DIR CCD_LIBRARY) endif() endif() -if(NOT CCD_FOUND) - # if pkgconfig is not installed, then fall back on more fragile detection - # of ccd - find_path(CCD_INCLUDE_DIRS ccd/ccd.h) - find_library(CCD_LIBRARY - ${CMAKE_SHARED_LIBRARY_PREFIX}ccd${CMAKE_SHARED_LIBRARY_SUFFIX}) - if(CCD_INCLUDE_DIRS AND CCD_LIBRARY) - set(CCD_LIBRARIES "${CCD_LIBRARY}") - else() - message(FATAL_ERROR "Libccd is required by FCL") - endif() +if(NOT ccd_FOUND) + message(FATAL_ERROR "CCD (>= 3.0.5) is required by FCL") endif() -include_directories(SYSTEM ${CCD_INCLUDE_DIRS}) -link_directories(${CCD_LIBRARY_DIRS}) -# Find Octomap (optional) -option(FCL_WITH_OCTOMAP "octomap library support" ON) +set(PKG_EXTERNAL_DEPS "ccd eigen3") + +#=============================================================================== +# Find optional dependency OctoMap +# +# If OctoMap is not found, manually set the cache variables OCTOMAP_INCLUDE_DIR +# and OCTOMAP_LIBRARY, OCTOMATH_LIBRARY, and OCTOMAP_VERSION +#=============================================================================== +option(FCL_WITH_OCTOMAP "OctoMap library support" ON) set(FCL_HAVE_OCTOMAP 0) + if(FCL_WITH_OCTOMAP) find_package(octomap QUIET) - # octomap-config.cmake may not define OCTOMAP_VERSION so fall back to - # pkgconfig - if(NOT OCTOMAP_VERSION AND PKG_CONFIG_FOUND) - pkg_check_modules(OCTOMAP QUIET octomap) - endif() - # whether octomap_FOUND and/or OCTOMAP_FOUND are set is inconsistent, but - # OCTOMAP_INCLUDE_DIRS and OCTOMAP_LIBRARY_DIRS should always be set when - # octomap is found - if(NOT OCTOMAP_INCLUDE_DIRS AND NOT OCTOMAP_LIBRARY_DIRS) - # if pkgconfig is not installed, then fall back on more fragile detection - # of octomap - find_path(OCTOMAP_INCLUDE_DIRS octomap.h - PATH_SUFFIXES octomap) - find_library(OCTOMAP_LIBRARY_DIRS - ${CMAKE_SHARED_LIBRARY_PREFIX}octomap${CMAKE_SHARED_LIBRARY_SUFFIX}) - if(OCTOMAP_INCLUDE_DIRS AND OCTOMAP_LIBRARY_DIRS) - set(OCTOMAP_LIBRARIES "octomap;octomath") - endif() + + # Older versions of octomap-config.cmake may not define OCTOMAP_VERSION so + # fall back to pkg-config + if(NOT octomap_FOUND OR NOT OCTOMAP_VERSION) + if(PKG_CONFIG_FOUND) + pkg_check_modules(PC_OCTOMAP octomap) + endif() + + find_path(OCTOMAP_INCLUDE_DIR octomap/octomap.h + HINTS "${PC_OCTOMAP_INCLUDE_DIRS}") + + # Using find_library() even if pkg-config is available ensures that the full + # paths to the octomap and octomath libraries are set in OCTOMAP_LIBRARIES + find_library(OCTOMAP_LIBRARY octomap + HINTS "${PC_OCTOMAP_LIBRARY_DIRS}") + + find_library(OCTOMATH_LIBRARY octomath + HINTS "${PC_OCTOMAP_LIBRARY_DIRS}") + + # Use a cache variable so that the version can be manually set if pkg-config + # is not available + set(OCTOMAP_VERSION "${PC_OCTOMAP_VERSION}" + CACHE STRING "octomap version (major.minor.patch)") + + if(OCTOMAP_INCLUDE_DIR AND OCTOMAP_LIBRARY AND OCTOMATH_LIBRARY AND OCTOMAP_VERSION) + set(OCTOMAP_INCLUDE_DIRS "${OCTOMAP_INCLUDE_DIR}") + set(OCTOMAP_LIBRARIES "${OCTOMAP_LIBRARY}" "${OCTOMATH_LIBRARY}") + set(octomap_FOUND ON) + + mark_as_advanced(OCTOMAP_INCLUDE_DIR OCTOMAP_LIBRARY OCTOMATH_LIBRARY OCTOMAP_VERSION) + else() + set(octomap_FOUND OFF) + endif() endif() - if(OCTOMAP_INCLUDE_DIRS AND OCTOMAP_LIBRARY_DIRS AND OCTOMAP_VERSION) + + if(octomap_FOUND) if(NOT OCTOMAP_MAJOR_VERSION AND NOT OCTOMAP_MINOR_VERSION AND NOT OCTOMAP_PATCH_VERSION) string(REPLACE "." ";" VERSION_LIST "${OCTOMAP_VERSION}") list(GET VERSION_LIST 0 OCTOMAP_MAJOR_VERSION) list(GET VERSION_LIST 1 OCTOMAP_MINOR_VERSION) list(GET VERSION_LIST 2 OCTOMAP_PATCH_VERSION) endif() - include_directories(SYSTEM ${OCTOMAP_INCLUDE_DIRS}) - link_directories(${OCTOMAP_LIBRARY_DIRS}) + set(FCL_HAVE_OCTOMAP 1) - message(STATUS "FCL uses Octomap") + message(STATUS "FCL uses OctoMap") + set(PKG_EXTERNAL_DEPS "${PKG_EXTERNAL_DEPS} octomap") else() - message(STATUS "FCL does not use Octomap") + message(STATUS "FCL does not use OctoMap") endif() else() - message(STATUS "FCL does not use Octomap (as requested)") + message(STATUS "FCL does not use OctoMap (as requested)") endif() @@ -188,6 +239,7 @@ add_subdirectory(src) set(pkg_conf_file_in "${CMAKE_CURRENT_SOURCE_DIR}/fcl.pc.in") set(pkg_conf_file_out "${CMAKE_CURRENT_BINARY_DIR}/fcl.pc") +set(PKG_DESC "Flexible Collision Library") if(NOT MSVC) set(PKG_CFLAGS "-std=c++11") endif() diff --git a/CMakeModules/CompilerSettings.cmake b/CMakeModules/CompilerSettings.cmake index c62219e61..b2c0ee6fe 100644 --- a/CMakeModules/CompilerSettings.cmake +++ b/CMakeModules/CompilerSettings.cmake @@ -1,6 +1,6 @@ # GCC if(CMAKE_COMPILER_IS_GNUCXX) - add_definitions(-std=c++11 -W -Wall -g -Wextra -Wpedantic -Wno-missing-field-initializers -Wno-unused-parameter) + add_definitions(-std=c++11 -W -Wall -Wextra -Wpedantic -Wno-unused-parameter) if(FCL_TREAT_WARNINGS_AS_ERRORS) add_definitions(-Werror) endif() @@ -8,7 +8,7 @@ endif() # Clang if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - add_definitions(-std=c++11 -W -Wall -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -Wno-delete-non-virtual-dtor -Wno-overloaded-virtual -Wno-deprecated-register) + add_definitions(-std=c++11 -W -Wall -Wextra -Wno-unused-parameter) if(FCL_TREAT_WARNINGS_AS_ERRORS) add_definitions(-Werror) endif() @@ -20,7 +20,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.1) message(FATAL_ERROR "AppleClang version must be at least 6.1!") endif() - add_definitions(-std=c++11 -W -Wall -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -Wno-delete-non-virtual-dtor -Wno-overloaded-virtual -Wno-deprecated-register) + add_definitions(-std=c++11 -W -Wall -Wextra -Wno-unused-parameter) if(FCL_TREAT_WARNINGS_AS_ERRORS) add_definitions(-Werror) endif() diff --git a/fcl.pc.in b/fcl.pc.in index 0986fa9e0..cb5ad784d 100644 --- a/fcl.pc.in +++ b/fcl.pc.in @@ -8,5 +8,5 @@ Name: @PROJECT_NAME@ Description: @PKG_DESC@ Version: @FCL_VERSION@ Requires: @PKG_EXTERNAL_DEPS@ -Libs: -L${libdir} -lfcl +Libs: -L${libdir} -l@PROJECT_NAME@ Cflags: @PKG_CFLAGS@ -I${includedir} diff --git a/include/fcl/math/bv/OBB-inl.h b/include/fcl/math/bv/OBB-inl.h index 7560a79d0..0b9b132bc 100644 --- a/include/fcl/math/bv/OBB-inl.h +++ b/include/fcl/math/bv/OBB-inl.h @@ -391,7 +391,7 @@ template bool obbDisjoint(const Matrix3& B, const Vector3& T, const Vector3& a, const Vector3& b) { - register S t, s; + S t, s; const S reps = 1e-6; Matrix3 Bf = B.cwiseAbs(); @@ -521,7 +521,7 @@ bool obbDisjoint( const Vector3& a, const Vector3& b) { - register S t, s; + S t, s; const S reps = 1e-6; Matrix3 Bf = tf.linear().cwiseAbs(); diff --git a/include/fcl/math/motion/taylor_model/taylor_model-inl.h b/include/fcl/math/motion/taylor_model/taylor_model-inl.h index ed83d09d0..2ebb086e6 100644 --- a/include/fcl/math/motion/taylor_model/taylor_model-inl.h +++ b/include/fcl/math/motion/taylor_model/taylor_model-inl.h @@ -275,8 +275,8 @@ template TaylorModel& TaylorModel::operator *= (const TaylorModel& other) { assert(other.time_interval_ == time_interval_); - register S c0, c1, c2, c3; - register S c0b = other.coeffs_[0], c1b = other.coeffs_[1], c2b = other.coeffs_[2], c3b = other.coeffs_[3]; + S c0, c1, c2, c3; + S c0b = other.coeffs_[0], c1b = other.coeffs_[1], c2b = other.coeffs_[2], c3b = other.coeffs_[3]; const Interval& rb = other.r_; @@ -286,7 +286,7 @@ TaylorModel& TaylorModel::operator *= (const TaylorModel& other) c3 = coeffs_[0] * c3b + coeffs_[1] * c2b + coeffs_[2] * c1b + coeffs_[3] * c0b; Interval remainder(r_ * rb); - register S tempVal = coeffs_[1] * c3b + coeffs_[2] * c2b + coeffs_[3] * c1b; + S tempVal = coeffs_[1] * c3b + coeffs_[2] * c2b + coeffs_[3] * c1b; remainder += time_interval_->t4_ * tempVal; tempVal = coeffs_[2] * c3b + coeffs_[3] * c2b; @@ -368,12 +368,12 @@ Interval TaylorModel::getTightBound(S t0, S t1) const if(coeffs_[3] == 0) { - register S a = -coeffs_[1] / (2 * coeffs_[2]); + S a = -coeffs_[1] / (2 * coeffs_[2]); Interval polybounds; if(a <= t1 && a >= t0) { S AQ = coeffs_[0] + a * (coeffs_[1] + a * coeffs_[2]); - register S t = t0; + S t = t0; S LQ = coeffs_[0] + t * (coeffs_[1] + t * coeffs_[2]); t = t1; S RQ = coeffs_[0] + t * (coeffs_[1] + t * coeffs_[2]); @@ -392,7 +392,7 @@ Interval TaylorModel::getTightBound(S t0, S t1) const } else { - register S t = t0; + S t = t0; S LQ = coeffs_[0] + t * (coeffs_[1] + t * coeffs_[2]); t = t1; S RQ = coeffs_[0] + t * (coeffs_[1] + t * coeffs_[2]); @@ -405,7 +405,7 @@ Interval TaylorModel::getTightBound(S t0, S t1) const } else { - register S t = t0; + S t = t0; S LQ = coeffs_[0] + t * (coeffs_[1] + t * (coeffs_[2] + t * coeffs_[3])); t = t1; S RQ = coeffs_[0] + t * (coeffs_[1] + t * (coeffs_[2] + t * coeffs_[3])); diff --git a/include/fcl/narrowphase/distance-inl.h b/include/fcl/narrowphase/distance-inl.h index 1372d279c..e27c1d8c9 100644 --- a/include/fcl/narrowphase/distance-inl.h +++ b/include/fcl/narrowphase/distance-inl.h @@ -162,7 +162,7 @@ typename NarrowPhaseSolver::S distance( collide(o1, tf1, o2, tf2, nsolver, collision_request, collision_result); assert(collision_result.isCollision()); - std::size_t index = -1; + std::size_t index = static_cast(-1); S max_pen_depth = std::numeric_limits::min(); for (auto i = 0u; i < collision_result.numContacts(); ++i) { diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4391a3a9c..db2ef861a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,17 +12,45 @@ set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${FCL_VERSION} SOVERSION ${FCL_ABI_VERSION}) -target_link_libraries(${PROJECT_NAME} - PUBLIC ${OCTOMAP_LIBRARIES} - PUBLIC ${CCD_LIBRARIES}) +# Use the IMPORTED target from newer versions of ccd-config.cmake if available, +# otherwise fall back to CCD_INCLUDE_DIRS and CCD_LIBRARIES +if(TARGET ccd) + target_link_libraries(${PROJECT_NAME} PUBLIC ccd) +else() + target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC "${CCD_INCLUDE_DIRS}") + target_link_libraries(${PROJECT_NAME} PUBLIC "${CCD_LIBRARIES}") +endif() + +# Use the IMPORTED target from newer versions of Eigen3Config.cmake if +# available, otherwise fall back to EIGEN3_INCLUDE_DIRS from older versions of +# Eigen3Config.cmake or EIGEN3_INCLUDE_DIR from FindEigen3.cmake +if(TARGET Eigen3::Eigen) + # Note that Eigen3::Eigen is an INTERFACE library, so the INCLUDE_DIRECTORIES + # and INTERFACE_INCLUDE_DIRECTORIES are populated, but nothing is actually + # linked + target_link_libraries(${PROJECT_NAME} PUBLIC Eigen3::Eigen) +elseif(EIGEN3_INCLUDE_DIRS) + target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC "${EIGEN3_INCLUDE_DIRS}") +else() + target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC "${EIGEN3_INCLUDE_DIR}") +endif() + +if(FCL_HAVE_OCTOMAP) + # Use the IMPORTED target from newer versions of octomap-config.cmake if + # available, otherwise fall back to OCTOMAP_INCLUDE_DIRS and OCTOMAP_LIBRARIES + if(TARGET octomap) + target_link_libraries(${PROJECT_NAME} PUBLIC octomap) + elseif(OCTOMAP_INCLUDE_DIRS AND OCTOMAP_LIBRARIES) + target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC "${OCTOMAP_INCLUDE_DIRS}") + target_link_libraries(${PROJECT_NAME} PUBLIC "${OCTOMAP_LIBRARIES}") + endif() +endif() target_include_directories(${PROJECT_NAME} INTERFACE $ + $ $) -target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC - ${EIGEN3_INCLUDE_DIR}) - export(TARGETS ${PROJECT_NAME} FILE "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake")