# Locate apollo library

FIND_PATH(APOLLO_INCLUDE_DIRS "apollo/function.hpp"
  HINTS $ENV{APOLLO_DIR}
  PATH_SUFFIXES apollo/include include
)

FIND_LIBRARY(_APOLLO_LIBRARY_RELEASE
  NAMES apollo
  HINTS $ENV{APOLLO_DIR}
  PATH_SUFFIXES apollo/lib lib
)

FIND_LIBRARY(_APOLLO_LIBRARY_DEBUG
  NAMES apollo-d
  HINTS $ENV{APOLLO_DIR}
  PATH_SUFFIXES apollo/lib lib
)

IF(_APOLLO_LIBRARY_RELEASE OR _APOLLO_LIBRARY_DEBUG)
    IF(_APOLLO_LIBRARY_RELEASE AND _APOLLO_LIBRARY_DEBUG)
        SET(_APOLLO_LIBRARY optimized ${_APOLLO_LIBRARY_RELEASE}
                             debug     ${_APOLLO_LIBRARY_DEBUG})
    ELSEIF(_APOLLO_LIBRARY_RELEASE)
        SET(_APOLLO_LIBRARY ${_APOLLO_LIBRARY_RELEASE})
    ELSE()
        SET(_APOLLO_LIBRARY ${_APOLLO_LIBRARY_DEBUG})
    ENDIF()
ENDIF()

IF(_APOLLO_LIBRARY)
    SET(APOLLO_LIBRARIES
        "${_APOLLO_LIBRARY}" CACHE STRING "apollo Libraries")
ENDIF(_APOLLO_LIBRARY)

INCLUDE(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
# handle the QUIETLY and REQUIRED arguments and set APOLLO_FOUND to TRUE if
# all listed variables are TRUE
FIND_PACKAGE_HANDLE_STANDARD_ARGS(apollo
    REQUIRED_VARS APOLLO_INCLUDE_DIRS APOLLO_LIBRARIES)

MARK_AS_ADVANCED(APOLLO_INCLUDE_DIRS APOLLO_LIBRARIES)
