###########################################################################
#
#  Library:   CTK
# 
#  Copyright (c) 2010  Kitware Inc.
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#      http://www.commontk.org/LICENSE
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.
# 
###########################################################################

#
# This script is configured and executed by ctkFunctionExecuteProcess
#

SET(PATH_LIST @CONFIG_PATH_LIST@)

FOREACH(p ${PATH_LIST})
  IF(WIN32)
    SET(ENV{PATH} ${p};$ENV{PATH})
  ELSEIF(APPLE)
    SET(ENV{DYLD_LIBRARY_PATH} ${p}:$ENV{DYLD_LIBRARY_PATH})
  ELSE()
    SET(ENV{LD_LIBRARY_PATH} ${p}:$ENV{LD_LIBRARY_PATH})
  ENDIF()
ENDFOREACH()

EXECUTE_PROCESS(
  @CONFIG_COMMAND@
  @CONFIG_WORKING_DIRECTORY@
  @CONFIG_TIMEOUT@
  @CONFIG_RESULT_VARIABLE@
  @CONFIG_OUTPUT_VARIABLE@
  @CONFIG_ERROR_VARIABLE@
  @CONFIG_INPUT_FILE@
  @CONFIG_OUTPUT_FILE@
  @CONFIG_ERROR_FILE@
  @CONFIG_OUTPUT_QUIET@
  @CONFIG_ERROR_QUIET@
  @CONFIG_OUTPUT_STRIP_TRAILING_WHITESPACE@
  @CONFIG_ERROR_STRIP_TRAILING_WHITESPACE@
  )

SET(var "@VARNAME_RESULT_VARIABLE@")
IF (NOT var STREQUAL "")
  SET(SETTER_RESULT_VARIABLE "SET(@VARNAME_RESULT_VARIABLE@ ${@VARNAME_RESULT_VARIABLE@} PARENT_SCOPE)")
ENDIF()

SET(var "@VARNAME_OUTPUT_VARIABLE@")
IF (NOT var STREQUAL "")
  SET(SETTER_OUTPUT_VARIABLE "SET(@VARNAME_OUTPUT_VARIABLE@ ${@VARNAME_OUTPUT_VARIABLE@} PARENT_SCOPE)")
ENDIF()

SET(var "@VARNAME_ERROR_VARIABLE@")
IF (NOT var STREQUAL "")
  SET(SETTER_ERROR_VARIABLE "SET(@VARNAME_ERROR_VARIABLE@ ${@VARNAME_ERROR_VARIABLE@} PARENT_SCOPE)")
ENDIF()

file(WRITE "@CMAKE_CURRENT_BINARY_DIR@/CMake/ctkExecuteProcess-@EXECUTABLE_NAME@-output.cmake" "
#
# File auto-generated by @CMAKE_CURRENT_BINARY_DIR@/CMake/ctkExecuteProcess-@EXECUTABLE_NAME@-output.cmake
#

${SETTER_RESULT_VARIABLE}
${SETTER_OUTPUT_VARIABLE}
${SETTER_ERROR_VARIABLE}
")