Skip to content

Commit

Permalink
add option to disable octomap in build
Browse files Browse the repository at this point in the history
This is a quasi-standard pattern to allow users to test
the library without its optional-dependency even if
the dependency is available.
  • Loading branch information
v4hn committed Jun 24, 2016
1 parent 1bcb2c3 commit 15a0d9c
Showing 1 changed file with 30 additions and 24 deletions.
54 changes: 30 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,32 +66,38 @@ endif()

# Find Octomap (optional)
find_package(PkgConfig QUIET)

option(FCL_WITH_OCTOMAP "octomap library support" TRUE)
set(FCL_HAVE_OCTOMAP 0)
if(PKG_CONFIG_FOUND)
pkg_check_modules(OCTOMAP QUIET octomap)
endif()
if(NOT OCTOMAP_FOUND)
# if pkfconfig 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()
endif()
if (OCTOMAP_FOUND OR (OCTOMAP_INCLUDE_DIRS AND OCTOMAP_LIBRARY_DIRS))
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)
include_directories(${OCTOMAP_INCLUDE_DIRS})
link_directories(${OCTOMAP_LIBRARY_DIRS})
set(FCL_HAVE_OCTOMAP 1)
message(STATUS "FCL uses Octomap")
if(FCL_WITH_OCTOMAP)
if(PKG_CONFIG_FOUND)
pkg_check_modules(OCTOMAP QUIET octomap)
endif()
if(NOT OCTOMAP_FOUND)
# 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()
endif()
if (OCTOMAP_FOUND OR (OCTOMAP_INCLUDE_DIRS AND OCTOMAP_LIBRARY_DIRS))
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)
include_directories(${OCTOMAP_INCLUDE_DIRS})
link_directories(${OCTOMAP_LIBRARY_DIRS})
set(FCL_HAVE_OCTOMAP 1)
message(STATUS "FCL uses Octomap")
else()
message(STATUS "FCL does not use Octomap")
endif()
else()
message(STATUS "FCL does not use Octomap")
message(STATUS "FCL does not use Octomap (as requested)")
endif()


Expand Down

0 comments on commit 15a0d9c

Please sign in to comment.