1# Copyright (c) 2011-2021, The DART development contributors
2# All rights reserved.
3#
4# The list of contributors can be found at:
5#   https://github.com/dartsim/dart/blob/master/LICENSE
6#
7# This file is provided under the "BSD-style" License
8
9# Find FCL
10#
11# This sets the following variables:
12#   FCL_FOUND
13#   FCL_INCLUDE_DIRS
14#   FCL_LIBRARIES
15#   FCL_VERSION
16
17find_package(PkgConfig QUIET)
18
19# Check to see if pkgconfig is installed.
20pkg_check_modules(PC_FCL fcl QUIET)
21
22# Include directories
23find_path(FCL_INCLUDE_DIRS
24    NAMES fcl/collision.h  # for FCL < 0.6
25    NAMES fcl/narrowphase/collision.h
26    HINTS ${PC_FCL_INCLUDEDIR}
27    PATHS "${CMAKE_INSTALL_PREFIX}/include")
28
29# Libraries
30if(MSVC)
31  find_package(fcl QUIET CONFIG)
32  if(TARGET fcl)
33    set(FCL_LIBRARIES fcl)
34  endif()
35else()
36  # Give explicit precedence to ${PC_FCL_LIBDIR}
37  find_library(FCL_LIBRARIES
38      NAMES fcl
39      HINTS ${PC_FCL_LIBDIR}
40      NO_DEFAULT_PATH
41      NO_CMAKE_PATH
42      NO_CMAKE_ENVIRONMENT_PATH
43      NO_SYSTEM_ENVIRONMENT_PATH)
44  find_library(FCL_LIBRARIES
45      NAMES fcl
46      HINTS ${PC_FCL_LIBDIR})
47endif()
48
49# Version
50if(PC_FCL_VERSION)
51  set(FCL_VERSION ${PC_FCL_VERSION})
52endif()
53
54# Set (NAME)_FOUND if all the variables and the version are satisfied.
55include(FindPackageHandleStandardArgs)
56find_package_handle_standard_args(fcl
57    FAIL_MESSAGE  DEFAULT_MSG
58    REQUIRED_VARS FCL_INCLUDE_DIRS FCL_LIBRARIES
59    VERSION_VAR   FCL_VERSION)
60