Skip to content
Snippets Groups Projects
wolflaserConfig.cmake 3.02 KiB
#edit the following line to add the librarie's header files
FIND_PATH(
    wolflaser_INCLUDE_DIRS
    NAMES laser.found
    PATHS /usr/local/include/iri-algorithms/wolf/plugin_laser)
IF(wolflaser_INCLUDE_DIRS)
  MESSAGE("Found laser include dirs: ${wolflaser_INCLUDE_DIRS}")
ELSE(wolflaser_INCLUDE_DIRS)
  MESSAGE("Couldn't find laser include dirs")
ENDIF(wolflaser_INCLUDE_DIRS)

FIND_LIBRARY(
    wolflaser_LIBRARIES
    NAMES libwolflaser.so
    PATHS /usr/local/lib)
IF(wolflaser_LIBRARIES)
  MESSAGE("Found laser lib: ${wolflaser_LIBRARIES}")
ELSE(wolflaser_LIBRARIES)
  MESSAGE("Couldn't find wolf laser lib")
ENDIF(wolflaser_LIBRARIES)

IF (wolflaser_INCLUDE_DIRS AND wolflaser_LIBRARIES)
   SET(wolflaser_FOUND TRUE)
 ELSE(wolflaser_INCLUDE_DIRS AND wolflaser_LIBRARIES)
   set(wolflaser_FOUND FALSE)
ENDIF (wolflaser_INCLUDE_DIRS AND wolflaser_LIBRARIES)

IF (wolflaser_FOUND)
   IF (NOT wolflaser_FIND_QUIETLY)
      MESSAGE(STATUS "Found laser: ${wolflaser_LIBRARIES}")
   ENDIF (NOT wolflaser_FIND_QUIETLY)
ELSE (wolflaser_FOUND)
   IF (wolflaser_FIND_REQUIRED)
      MESSAGE(FATAL_ERROR "Could not find wolf laser")
   ENDIF (wolflaser_FIND_REQUIRED)
ENDIF (wolflaser_FOUND)


macro(wolf_report_not_found REASON_MSG)
  set(wolflaser_FOUND FALSE)
  unset(wolflaser_INCLUDE_DIRS)
  unset(wolflaser_LIBRARIES)

  # Reset the CMake module path to its state when this script was called.
  set(CMAKE_MODULE_PATH ${CALLERS_CMAKE_MODULE_PATH})

  # Note <package>_FIND_[REQUIRED/QUIETLY] variables defined by
  # FindPackage() use the camelcase library name, not uppercase.
  if (wolflaser_FIND_QUIETLY)
    message(STATUS "Failed to find wolf laser- " ${REASON_MSG} ${ARGN})
  else (wolflaser_FIND_REQUIRED)
    message(FATAL_ERROR "Failed to find wolf laser - " ${REASON_MSG} ${ARGN})
  else()
    # Neither QUIETLY nor REQUIRED, use SEND_ERROR which emits an error
    # that prevents generation, but continues configuration.
    message(SEND_ERROR "Failed to find wolf laser - " ${REASON_MSG} ${ARGN})
  endif ()
  return()
endmacro(wolf_report_not_found)

if(NOT wolflaser_FOUND)
  wolf_report_not_found("Something went wrong while setting up wolf vision.")
endif(NOT wolflaser_FOUND)
# Set the include directories for wolf (itself).
set(wolflaser_FOUND TRUE)

# Now we gather all the required dependencies for Wolf Laser

FIND_PACKAGE(laser_scan_utils REQUIRED)
list(APPEND wolflaser_INCLUDE_DIRS ${laser_scan_utils_INCLUDE_DIRS})
list(APPEND wolflaser_LIBRARIES ${laser_scan_utils_LIBRARY})

#Making sure Wolf is looked for
if(NOT wolf_FOUND)
  FIND_PACKAGE(wolfcore REQUIRED)

  #We reverse in order to insert at the start
  list(REVERSE wolflaser_INCLUDE_DIRS)
  list(APPEND wolflaser_INCLUDE_DIRS ${wolfcore_INCLUDE_DIRS})
  list(REVERSE wolflaser_INCLUDE_DIRS)

  list(REVERSE wolflaser_LIBRARIES)
  list(APPEND wolflaser_LIBRARIES ${wolfcore_LIBRARIES})
  list(REVERSE wolflaser_LIBRARIES)

endif()

# provide both INCLUDE_DIR and INCLUDE_DIRS
SET(wolflaser_INCLUDE_DIR ${wolflaser_INCLUDE_DIRS})
# provide both LIBRARY and LIBRARIES 
SET(wolflaser_LIBRARY ${wolflaser_LIBRARIES})