Skip to content

Commit

Permalink
Merge branch 'master' into sse-flags-apple
Browse files Browse the repository at this point in the history
  • Loading branch information
jslee02 authored Feb 1, 2017
2 parents 873d480 + 6cfdd83 commit 7a61891
Show file tree
Hide file tree
Showing 8 changed files with 150 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
150 changes: 101 additions & 49 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand All @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions CMakeModules/CompilerSettings.cmake
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# 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()
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()
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion fcl.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -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}
4 changes: 2 additions & 2 deletions include/fcl/math/bv/OBB-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ template <typename S>
bool obbDisjoint(const Matrix3<S>& B, const Vector3<S>& T,
const Vector3<S>& a, const Vector3<S>& b)
{
register S t, s;
S t, s;
const S reps = 1e-6;

Matrix3<S> Bf = B.cwiseAbs();
Expand Down Expand Up @@ -521,7 +521,7 @@ bool obbDisjoint(
const Vector3<S>& a,
const Vector3<S>& b)
{
register S t, s;
S t, s;
const S reps = 1e-6;

Matrix3<S> Bf = tf.linear().cwiseAbs();
Expand Down
14 changes: 7 additions & 7 deletions include/fcl/math/motion/taylor_model/taylor_model-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ template <typename S>
TaylorModel<S>& TaylorModel<S>::operator *= (const TaylorModel<S>& 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<S>& rb = other.r_;

Expand All @@ -286,7 +286,7 @@ TaylorModel<S>& TaylorModel<S>::operator *= (const TaylorModel<S>& other)
c3 = coeffs_[0] * c3b + coeffs_[1] * c2b + coeffs_[2] * c1b + coeffs_[3] * c0b;

Interval<S> 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;
Expand Down Expand Up @@ -368,12 +368,12 @@ Interval<S> TaylorModel<S>::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<S> 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]);
Expand All @@ -392,7 +392,7 @@ Interval<S> TaylorModel<S>::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]);
Expand All @@ -405,7 +405,7 @@ Interval<S> TaylorModel<S>::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]));
Expand Down
2 changes: 1 addition & 1 deletion include/fcl/narrowphase/distance-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::size_t>(-1);
S max_pen_depth = std::numeric_limits<S>::min();
for (auto i = 0u; i < collision_result.numContacts(); ++i)
{
Expand Down
40 changes: 34 additions & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include>)

target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC
${EIGEN3_INCLUDE_DIR})

export(TARGETS ${PROJECT_NAME}
FILE "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake")

Expand Down

0 comments on commit 7a61891

Please sign in to comment.