set(CMU_TEMP_DIR "${CMAKE_BINARY_DIR}/_cmake_cmu_tmp/" CACHE INTERNAL "" FORCE)

macro(cmu_call fn)
  if(NOT COMMAND ${fn})
    message(FATAL_ERROR "Tried to call unexisted function/macros: \"${fn}\"")
  endif()
  #message("Calling ${fn}(${ARGN})")
  set(__cmd "${fn}(")
  set(__cmd_first_arg "1")
  foreach(a ${ARGN})
    if (NOT DEFINED __cmd_first_arg)
      set(__cmd "${__cmd} ")
    else()
      unset(__cmd_first_arg)
    endif()
    set(__cmd "${__cmd}\"${a}\"")
  endforeach()
  set(__cmd "${__cmd})")
  #message(STATUS "Indirect command is: ${__cmd}")
  file(WRITE ${CMU_TEMP_DIR}indirect_call.tmp "${__cmd}")
  include(${CMU_TEMP_DIR}indirect_call.tmp)
  #file(REMOVE ${CMU_TEMP_DIR}indirect_call.tmp)
endmacro()  
