# (C) Copyright 2013 ECMWF.
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
# In applying this licence, ECMWF does not waive the privileges and immunities
# granted to it by virtue of its status as an intergovernmental organisation nor
# does it submit to any jurisdiction.

if( @PROJECT_NAME@_IS_BUILD_DIR_EXPORT )
  set( FCTEST_GENERATOR @Python3_EXECUTABLE@ @CMAKE_CURRENT_SOURCE_DIR@/tools/fctest-generate-runner.py )
  set( FYPP @FYPP@ )
  if( @HAVE_FCKIT_VENV@ )
     set( FCKIT_VENV_EXE @FCKIT_VENV_EXE@ )
  endif()
else()
  if( @HAVE_FCKIT_VENV@ AND NOT @ECBUILD_INSTALL_LIBRARY_HEADERS@ )
     message( FATAL_ERROR "Installation of fckit python vritual environment was disabled" )
  elseif( @HAVE_FCKIT_VENV@ )
     set( _fckit_eval_script ${fckit_BASE_DIR}/libexec/fckit-eval.sh )
     set( FCKIT_VENV_EXE ${fckit_BASE_DIR}/@rel_venv_exe_path@ )
     set( FYPP ${_fckit_eval_script} ${FCKIT_VENV_EXE} -m fypp )
  else()
     set( FYPP ${fckit_BASE_DIR}/libexec/fckit-eval.sh 
               ${fckit_BASE_DIR}/libexec/fckit-fypp.py )
  endif()

  set( FCTEST_GENERATOR @Python3_EXECUTABLE@ ${fckit_BASE_DIR}/libexec/fctest-generate-runner.py )
endif()

@FCKIT_PREPROCESS_FYPP@

@ADD_FCTEST@

set( fckit_HAVE_ECKIT @fckit_HAVE_ECKIT@ )
set( fckit_ECKIT_FOUND 0 )
if( fckit_HAVE_ECKIT )
  set( fckit_ECKIT_FOUND 1 )

  # Following Required when "ECBUILD_2_COMPAT=OFF" and static linking is used
  include( CMakeFindDependencyMacro )
  find_dependency( eckit HINTS ${CMAKE_CURRENT_LIST_DIR}/../eckit @eckit_DIR@ @eckit_BINARY_DIR@ )
endif()

if( fckit_FIND_REQUIRED_ECKIT AND NOT fckit_ECKIT_FOUND )
  message( FATAL_ERROR "fckit was not compiled with ECKIT enabled" )
endif()

set( FCKIT_LIBRARIES @FCKIT_LIBRARIES@ )
