doc/markdown/FindOMPL.cmake
00001 # - Try to find the OMPL library
00002 # Once done this will define:
00003 #
00004 # OMPL_FOUND - OMPL was found
00005 # OMPL_INCLUDE_DIRS - The OMPL include directory
00006 # OMPL_LIBRARIES - The OMPL library
00007 # OMPLAPP_LIBRARIES - The OMPL.app library
00008 # OMPL_VERSION - The OMPL version in the form <major>.<minor>.<patchlevel>
00009 # OMPL_MAJOR_VERSION - Major version
00010 # OMPL_MINOR_VERSION - Minor version
00011 # OMPL_PATCH_VERSION - Patch version
00012 
00013 include(FindPackageHandleStandardArgs)
00014 
00015 # user can set OMPL_PREFIX to specify the prefix path of the OMPL library
00016 # and include directory, either as an environment variable or as an
00017 # argument to cmake ("cmake -DOMPL_PREFIX=...")
00018 if (NOT OMPL_PREFIX)
00019     set(OMPL_PREFIX $ENV{OMPL_PREFIX})
00020 endif()
00021 
00022 if (OMPL_FIND_VERSION)
00023     set(OMPL_SUFFIX "-${OMPL_VERSION}")
00024 else()
00025     set(OMPL_SUFFIX "")
00026 endif()
00027 
00028 # user can set OMPL_LIB_PATH to specify the path for the OMPL library
00029 # (analogous to OMPL_PREFIX)
00030 if (NOT OMPL_LIB_PATH)
00031     set(OMPL_LIB_PATH $ENV{OMPL_LIB_PATH})
00032     if (NOT OMPL_LIB_PATH)
00033         set(OMPL_LIB_PATH ${OMPL_PREFIX})
00034     endif()
00035 endif()
00036 
00037 # user can set OMPL_INCLUDE_PATH to specify the path for the OMPL include
00038 # directory (analogous to OMPL_PREFIX)
00039 if (NOT OMPL_INCLUDE_PATH)
00040     set(OMPL_INCLUDE_PATH $ENV{OMPL_INCLUDE_PATH})
00041     if (NOT OMPL_INCLUDE_PATH)
00042         set(OMPL_INCLUDE_PATH ${OMPL_PREFIX})
00043     endif()
00044 endif()
00045 
00046 # find the OMPL library
00047 find_library(OMPL_LIBRARY ompl
00048     PATHS ${OMPL_LIB_PATH}
00049     PATH_SUFFIXES lib build/lib)
00050 if (OMPL_LIBRARY)
00051     if (OMPL_FIND_VERSION)
00052         get_filename_component(libpath ${OMPL_LIBRARY} PATH)
00053         file(GLOB OMPL_LIBS "${libpath}/libompl.${OMPL_FIND_VERSION}.*")
00054         list(GET OMPL_LIBS -1 OMPL_LIBRARY)
00055     endif()
00056     set(OMPL_LIBRARIES "${OMPL_LIBRARY}" CACHE FILEPATH "Path to OMPL library")
00057 endif()
00058 # find the OMPL.app library
00059 find_library(OMPLAPP_LIBRARY ompl_app
00060     PATHS ${OMPL_LIB_PATH}
00061     PATH_SUFFIXES lib build/lib)
00062 if (OMPLAPP_LIBRARY)
00063     if (OMPL_FIND_VERSION)
00064         get_filename_component(libpath ${OMPLAPP_LIBRARY} PATH)
00065         file(GLOB OMPLAPP_LIBS "${libpath}/libompl_app.${OMPL_FIND_VERSION}.*")
00066         list(GET OMPLAPP_LIBS -1 OMPLAPP_LIBRARY)
00067     endif()
00068     set(OMPLAPP_LIBRARIES "${OMPLAPP_LIBRARY}" CACHE FILEPATH "Path to OMPL.app library")
00069 endif()
00070 
00071 # find include path
00072 find_path(OMPL_INCLUDE_DIRS SpaceInformation.h
00073     PATHS ${OMPL_INCLUDE_PATH}
00074     PATH_SUFFIXES base "ompl${OMPL_SUFFIX}/base" "include/ompl${OMPL_SUFFIX}/base" ompl/base include/ompl/base src/ompl/base)
00075 if (OMPL_INCLUDE_DIRS)
00076     string(REGEX REPLACE "/ompl/base$" "" OMPL_INCLUDE_DIRS ${OMPL_INCLUDE_DIRS})
00077 else()
00078     set(OMPL_INCLUDE_DIRS "")
00079 endif()
00080 
00081 # find version
00082 find_file(OMPL_CONFIG config.h
00083     PATHS ${OMPL_INCLUDE_DIRS}
00084     PATH_SUFFIXES ompl
00085     NO_DEFAULT_PATH)
00086 if(OMPL_CONFIG)
00087     file(READ ${OMPL_CONFIG} OMPL_CONFIG_STR)
00088     string(REGEX REPLACE ".*OMPL_VERSION \"([0-9.]+)\".*" "\\1"
00089         OMPL_VERSION
00090         "${OMPL_CONFIG_STR}")
00091     string(REGEX REPLACE "([0-9]+).([0-9]+).([0-9]+)" "\\1" OMPL_MAJOR_VERSION "${OMPL_VERSION}")
00092     string(REGEX REPLACE "([0-9]+).([0-9]+).([0-9]+)" "\\2" OMPL_MINOR_VERSION "${OMPL_VERSION}")
00093     string(REGEX REPLACE "([0-9]+).([0-9]+).([0-9]+)" "\\3" OMPL_PATCH_VERSION "${OMPL_VERSION}")
00094 endif()
00095 
00096 find_package_handle_standard_args(OMPL DEFAULT_MSG OMPL_LIBRARIES OMPL_INCLUDE_DIRS)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines