# - Ad-hoc module to try to find OpenARK headers and libraries.
#
# Note that since OpenARK does not yet have an installation target,
# this works by finding the headers and library from the project root.
# Assumes that the build directory is called build/
# 
# Usage of this module as follows:
#
#     find_package(OpenARK)
#
# Variables used by this module, they can change the default behaviour and need
# to be set before calling find_package:
#
#  OpenARK_DIR  Set this variable to the project root of
#                   OpenARK if the module has problems finding
#                   the proper installation path.
#
# Variables defined by this module:
#
#  OpenARK_FOUND              OpenARK_DIR is set correctly
#
# All that is needed to use OpenARK is that the environment variable 
# OpenARK_DIR is set to the directory of the SDK
# This file simply checks that the environment variable is set correctly
#

if (DEFINED ENV{OPENARK_DIR})
    set(OPENARK_DIR $ENV{OPENARK_DIR})
endif (DEFINED ENV{OPENARK_DIR})

if (NOT DEFINED OPENARK_DIR)
    set(OPENARK_DIR $ENV{OPENARK_DIR})
    message( WARNING "!! Please add -DOPENARK_DIR='openark_repo_root_dir' or set the OPENARK_DIR env var." )
endif (NOT DEFINED OPENARK_DIR)

find_library(OpenARK_LIB NAMES openark_0_9_1 openark_0_9_2 openark_0_9_3.lib openark_0_9_4 openark
    HINTS "${OPENARK_DIR}/build/Release" "${OPENARK_DIR}/build" "${OPENARK_DIR}/Release"
    DOC "OpenARK libraries")

find_path(OpenARK_INCLUDE_DIR
    NAMES FramePlane.h
    PATHS ${OPENARK_DIR}/include
)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OpenARK DEFAULT_MSG
    OpenARK_LIB OpenARK_INCLUDE_DIR
)
