## ---------------------------------------------------------------------
##
## Copyright (C) 2012 - 2023 by the deal.II authors
##
## This file is part of the deal.II library.
##
## The deal.II library is free software; you can use it, redistribute
## it, and/or modify it under the terms of the GNU Lesser General
## Public License as published by the Free Software Foundation; either
## version 2.1 of the License, or (at your option) any later version.
## The full text of the license can be found in the file LICENSE.md at
## the top level directory of deal.II.
##
## ---------------------------------------------------------------------


########################################################################
##                                                                    ##
##               The deal.II project configuration file               ##
##                                                                    ##
########################################################################

#
# General information
#

set(DEAL_II_PACKAGE_NAME "@DEAL_II_PACKAGE_NAME@")
set(DEAL_II_PACKAGE_VERSION "@DEAL_II_PACKAGE_VERSION@")
set(DEAL_II_PACKAGE_VENDOR "@DEAL_II_PACKAGE_VENDOR@")
set(DEAL_II_PACKAGE_DESCRIPTION "@DEAL_II_PACKAGE_DESCRIPTION@")

set(DEAL_II_VERSION_MAJOR "@DEAL_II_VERSION_MAJOR@")
set(DEAL_II_VERSION_MINOR "@DEAL_II_VERSION_MINOR@")
set(DEAL_II_VERSION_SUBMINOR "@DEAL_II_VERSION_SUBMINOR@")
set(DEAL_II_VERSION "@DEAL_II_VERSION@")

set(DEAL_II_GIT_BRANCH "@DEAL_II_GIT_BRANCH@")
set(DEAL_II_GIT_REVISION "@DEAL_II_GIT_REVISION@")
set(DEAL_II_GIT_SHORTREV "@DEAL_II_GIT_SHORTREV@")
set(DEAL_II_GIT_TAG "@DEAL_II_GIT_TAG@")

set(DEAL_II_PROJECT_CONFIG_NAME "@DEAL_II_PROJECT_CONFIG_NAME@")

set(DEAL_II_BUILD_TYPE "@CMAKE_BUILD_TYPE@")
set(DEAL_II_BUILD_TYPES "@DEAL_II_BUILD_TYPES@")

#
# Information about the project location
#

set(DEAL_II_DOCHTML_RELDIR "@DEAL_II_DOCHTML_RELDIR@")
set(DEAL_II_DOCREADME_RELDIR "@DEAL_II_DOCREADME_RELDIR@")
set(DEAL_II_EXAMPLES_RELDIR "@DEAL_II_EXAMPLES_RELDIR@")
set(DEAL_II_EXECUTABLE_RELDIR "@DEAL_II_EXECUTABLE_RELDIR@")
set(DEAL_II_INCLUDE_RELDIR "@DEAL_II_INCLUDE_RELDIR@")
set(DEAL_II_LIBRARY_RELDIR "@DEAL_II_LIBRARY_RELDIR@")
set(DEAL_II_PROJECT_CONFIG_RELDIR "@DEAL_II_PROJECT_CONFIG_RELDIR@")
set(DEAL_II_SHARE_RELDIR "@DEAL_II_SHARE_RELDIR@")

#
# Determine DEAL_II_PATH from CMAKE_CURRENT_LIST_DIR:
#

set(DEAL_II_PATH "${CMAKE_CURRENT_LIST_DIR}")
set(_path "${DEAL_II_PROJECT_CONFIG_RELDIR}")
while(NOT "${_path}" STREQUAL "")
  get_filename_component(DEAL_II_PATH "${DEAL_II_PATH}" PATH)
  get_filename_component(_path "${_path}" PATH)
endwhile()

#
# Print a message after inclusion of this file:
#

set(DEAL_II_PROJECT_CONFIG_INCLUDED TRUE)

set(DEAL_II_BUILD_DIR @CONFIG_BUILD_DIR@)

if(NOT ${DEAL_II_PACKAGE_NAME}_FIND_QUIETLY)
  if(DEAL_II_BUILD_DIR)
    message(STATUS
      "Using the ${DEAL_II_PACKAGE_NAME}-${DEAL_II_PACKAGE_VERSION} build directory found at ${DEAL_II_PATH}"
      )
  else()
    message(STATUS
      "Using the ${DEAL_II_PACKAGE_NAME}-${DEAL_II_PACKAGE_VERSION} installation found at ${DEAL_II_PATH}"
      )
  endif()
endif()

#
# Include all convenience macros:
#

file(GLOB _macro_files
  "${DEAL_II_PATH}/${DEAL_II_SHARE_RELDIR}/macros/*.cmake"
  )
foreach(file ${_macro_files})
  if(NOT ${DEAL_II_PACKAGE_NAME}_FIND_QUIETLY)
    message(STATUS "Include macro ${file}")
  endif()
  include(${file})
endforeach()

#
# Compiler and linker configuration
#

set(DEAL_II_CXX_COMPILER "@CMAKE_CXX_COMPILER@")
set(DEAL_II_C_COMPILER "@CMAKE_C_COMPILER@")

# used for all targets:
set(DEAL_II_CXX_FLAGS "@DEAL_II_CXX_FLAGS@")

# _additionally_ used for debug targets:
set(DEAL_II_CXX_FLAGS_DEBUG "@DEAL_II_CXX_FLAGS_DEBUG@")

# _additionally_ used for release targets:
set(DEAL_II_CXX_FLAGS_RELEASE "@DEAL_II_CXX_FLAGS_RELEASE@")

# warning flags used for all targets:
set(DEAL_II_WARNING_FLAGS "@DEAL_II_WARNING_FLAGS@")

# used for all targets:
set(DEAL_II_LINKER_FLAGS "@DEAL_II_LINKER_FLAGS@")

# _additionally_ used for debug targets:
set(DEAL_II_LINKER_FLAGS_DEBUG "@DEAL_II_LINKER_FLAGS_DEBUG@")

# _additionally_ used for release targets:
set(DEAL_II_LINKER_FLAGS_RELEASE "@DEAL_II_LINKER_FLAGS_RELEASE@")

#
# MPI runtime:
#

set(DEAL_II_MPIEXEC "@MPIEXEC@")
set(DEAL_II_MPIEXEC_NUMPROC_FLAG "@MPIEXEC_NUMPROC_FLAG@")
set(DEAL_II_MPIEXEC_PREFLAGS "@MPIEXEC_PREFLAGS@")
set(DEAL_II_MPIEXEC_POSTFLAGS "@MPIEXEC_POSTFLAGS@")

#
# Information about library targets and feature configuration
#

set(DEAL_II_TARGET_CONFIG "${DEAL_II_PATH}/${DEAL_II_PROJECT_CONFIG_RELDIR}/${DEAL_II_PROJECT_CONFIG_NAME}Targets.cmake")

#
# We support a rather nonstandard situation where the find_package(deal.II)
# call happens before proper setup of a toolchain via project(). The
# reasoning behind this was to properly initialize the compiler in user
# projects via the deal_ii_initialize_cached_variables():
#
#   find_package(deal.II)
#   deal_ii_initialize_cached_variables()
#   project(...)
#   ...
#   deal_ii_setup_target(...)
#
# This requires that the deal_ii_setup_target() loads the target
# configuration because this has to happen after the call to project().
#
# Unfortunately _not_ automatically including all target definitions is
# non-standard behavior and rather surprising. Therefore, in order to
# support the modern way of searching for a dependency and using it:
#
#   project(...)
#   find_package(deal.II)
#   ...
#   target_link_libraries(... dealii::dealii_[debug|release])
#
# we check whether project(... [CXX]) has been called prior to
# find_package(deal.II) and if yes simply include our target configuration:
#
if(DEFINED CMAKE_CXX_COMPILER_ABI)
  include(${DEAL_II_TARGET_CONFIG})
  set(DEAL_II_TARGET_CONFIG_INCLUDED TRUE)
endif()

# The Debug target:
set(DEAL_II_TARGET_DEBUG "@CONFIG_TARGET_DEBUG@")

# The Release target:
set(DEAL_II_TARGET_RELEASE "@CONFIG_TARGET_RELEASE@")

# Full list of targets with "debug" and "optimized" keywords for easy use with TARGET_LINK_LIBRARIES:
set(DEAL_II_TARGET "@CONFIG_TARGET@")
