#
# Copyright 2021 Benjamin Worpitz, Erik Zenker, Axel Huebl, Jan Stephan, Bernhard Manfred Gruber
#
# This file is part of alpaka.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#

@PACKAGE_INIT@

################################################################################
# alpaka.

set(alpaka_DEBUG "0" CACHE STRING "Debug level")
set_property(CACHE alpaka_DEBUG PROPERTY STRINGS "0;1;2")

#-------------------------------------------------------------------------------
# Common.

# This file's directory.
set(_alpaka_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR})
# Normalize the path (e.g. remove ../)
get_filename_component(_alpaka_ROOT_DIR ${_alpaka_ROOT_DIR} ABSOLUTE)

# Compiler feature tests.
set(_alpaka_FEATURE_TESTS_DIR "${_alpaka_ROOT_DIR}/tests")

# Add common functions.
set(_alpaka_COMMON_FILE "${_alpaka_ROOT_DIR}/common.cmake")
include(${_alpaka_COMMON_FILE})

# Add alpaka_ADD_EXECUTABLE function.
set(_alpaka_ADD_EXECUTABLE_FILE "${_alpaka_ROOT_DIR}/addExecutable.cmake")
include(${_alpaka_ADD_EXECUTABLE_FILE})

# Add alpaka_ADD_LIBRARY function.
set(_alpaka_ADD_LIBRARY_FILE "${_alpaka_ROOT_DIR}/addLibrary.cmake")
include(${_alpaka_ADD_LIBRARY_FILE})

# Set found to true initially and set it to false if a required dependency is missing.
set(_alpaka_FOUND TRUE)

set(_alpaka_INCLUDE_DIRECTORY "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@")

include("${CMAKE_CURRENT_LIST_DIR}/alpakaCommon.cmake")

check_required_components("alpaka")

# Unset already set variables if not found.
if(NOT _alpaka_FOUND)
    unset(_alpaka_FOUND)
    unset(_alpaka_COMPILE_OPTIONS_PUBLIC)
    unset(_alpaka_COMPILE_DEFINITIONS_HIP)
    unset(_alpaka_HIP_LIBRARIES)
    unset(_alpaka_INCLUDE_DIRECTORY)
    unset(_alpaka_ADD_EXECUTABLE_FILE)
    unset(_alpaka_ADD_LIBRARY_FILE)
    unset(_alpaka_BOOST_MIN_VER)
else()
    # Make internal variables advanced options in the GUI.
    mark_as_advanced(
        _alpaka_COMPILE_OPTIONS_PUBLIC
        _alpaka_INCLUDE_DIRECTORY
        _alpaka_COMMON_FILE
        _alpaka_ADD_EXECUTABLE_FILE
        _alpaka_ADD_LIBRARY_FILE
        _alpaka_BOOST_MIN_VER)
endif()
