# Config file for the @PROJECT_NAME@ package
# Defines the following variables:
#
#  @PNAME@_INCLUDE_DIRS   - include directories
#  @PNAME@_DEFINITIONS    - preprocessor definitions
#  @PNAME@_LIBRARIES      - libraries to link against
#  @PNAME@_FEATURES       - list of enabled features
#  @PNAME@_VERSION        - version of the package
#  @PNAME@_GIT_SHA1       - Git revision of the package
#  @PNAME@_GIT_SHA1_SHORT - short Git revision of the package
#
# Also defines @PROJECT_NAME@ third-party library dependencies:
#  @PNAME@_TPLS             - package names of  third-party library dependencies
#  @PNAME@_TPL_INCLUDE_DIRS - include directories
#  @PNAME@_TPL_DEFINITIONS  - preprocessor definitions
#  @PNAME@_TPL_LIBRARIES    - libraries to link against

### compute paths

get_filename_component(@PNAME@_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)

set( @PNAME@_SELF_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@" )
set( @PNAME@_SELF_DEFINITIONS  "@CONF_DEFINITIONS@" )
set( @PNAME@_SELF_LIBRARIES    "@CONF_LIBRARIES@" )

set( @PNAME@_TPLS              "@CONF_TPLS@" )
set( @PNAME@_TPL_INCLUDE_DIRS  "@CONF_TPL_INCLUDE_DIRS@" )
set( @PNAME@_TPL_DEFINITIONS   "@CONF_TPL_DEFINITIONS@" )
set( @PNAME@_TPL_LIBRARIES     "@CONF_TPL_LIBRARIES@" )

set( @PNAME@_VERSION           "@PACKAGE_VERSION@" )
set( @PNAME@_GIT_SHA1          "@PACKAGE_GIT_SHA1@" )
set( @PNAME@_GIT_SHA1_SHORT    "@PACKAGE_GIT_SHA1_SHORT@" )

### export include paths as absolute paths

set( @PNAME@_INCLUDE_DIRS "" )
foreach( path ${@PNAME@_SELF_INCLUDE_DIRS} )
  get_filename_component( abspath ${path} ABSOLUTE )
  list( APPEND @PNAME@_INCLUDE_DIRS ${abspath} )
endforeach()
list( APPEND @PNAME@_INCLUDE_DIRS ${@PNAME@_TPL_INCLUDE_DIRS} )

### export definitions

set( @PNAME@_DEFINITIONS      ${@PNAME@_SELF_DEFINITIONS} ${@PNAME@_TPL_DEFINITIONS} )

### export list of all libraries

set( @PNAME@_LIBRARIES        ${@PNAME@_SELF_LIBRARIES}   ${@PNAME@_TPL_LIBRARIES}   )

### export the features provided by the package

set( @PNAME@_FEATURES    "@CONF_FEATURES@" )
foreach( _f ${@PNAME@_FEATURES} )
  set( @PNAME@_HAVE_${_f} 1 )
endforeach()

# Has this configuration been exported from a build tree?
set( @PNAME@_IS_BUILD_DIR_EXPORT @_is_build_dir_export@ )

if( EXISTS ${@PNAME@_CMAKE_DIR}/@CONF_IMPORT_FILE@ )
  set( @PNAME@_IMPORT_FILE "${@PNAME@_CMAKE_DIR}/@CONF_IMPORT_FILE@" )
  include( ${@PNAME@_IMPORT_FILE} )
endif()

# here goes the imports of the TPL's

include( ${CMAKE_CURRENT_LIST_FILE}.tpls OPTIONAL )

# insert definitions for IMPORTED targets

if( NOT @PROJECT_NAME@_BINARY_DIR )

  if( @PNAME@_IS_BUILD_DIR_EXPORT )
    include( "@TOP_PROJECT_TARGETS_FILE@" OPTIONAL )
  else()
    include( "${@PNAME@_CMAKE_DIR}/@PROJECT_NAME@-targets.cmake" OPTIONAL )
  endif()

endif()

# publish this file as imported

set( @PNAME@_IMPORT_FILE ${CMAKE_CURRENT_LIST_FILE} )
mark_as_advanced( @PNAME@_IMPORT_FILE )

# set @PROJECT_NAME@_BASE_DIR for final installations or build directories

if( NOT @PROJECT_NAME@ )
  if( @PNAME@_IS_BUILD_DIR_EXPORT )
    set( @PROJECT_NAME@_BASE_DIR @CMAKE_BINARY_DIR@ )
  else()
    get_filename_component( abspath ${CMAKE_CURRENT_LIST_DIR}/../../.. ABSOLUTE )
    set( @PROJECT_NAME@_BASE_DIR ${abspath} )
  endif()
endif()
