MACRO(ADD_WS_TEMPLATES TARGET PREFIX)
    SET(SRC_LIST ${ARGN})
    FOREACH (SRC IN ITEMS ${SRC_LIST})
          GET_FILENAME_COMPONENT(SRC_BASE_NAME ${SRC} NAME_WE)
  	  GET_FILENAME_COMPONENT(SRC_DIR ${SRC} DIRECTORY)
   	  GET_FILENAME_COMPONENT(SRC_ABSOLUTE_PATH ${SRC} ABSOLUTE ${CMAKE_CURRENT_SOURCE_DIR})
	  SET(OUT_PATH "${CMAKE_BINARY_DIR}/${PREFIX}/${SRC_DIR}/${SRC_BASE_NAME}.tpp")
            ADD_CUSTOM_COMMAND(
	      COMMAND tpl2cpp ARGS ${SRC_ABSOLUTE_PATH} ${OUT_PATH}
		  DEPENDS ${SRC_ABSOLUTE_PATH}
		  DEPENDS tpl2cpp
    	  COMMENT "Generating cpp from template ${SRC}"
    	  OUTPUT ${OUT_PATH}
      )
  LIST(APPEND OUT_FILES ${OUT_PATH})
  ENDFOREACH()

  ADD_CUSTOM_TARGET(${TARGET}_templates ALL DEPENDS ${OUT_FILES} SOURCES "${SRC_LIST}")
  ADD_DEPENDENCIES(${TARGET} ${TARGET}_templates)
ENDMACRO()

