function(IDL_GENERATE_SOURCE)
	cmake_parse_arguments(IDL_GENERATE_SOURCE
		"" "SOURCES_DIR;DESTINATION;IDLC_PATH;TARGET" "SOURCES" ${ARGN}
	)
	if (NOT IDL_GENERATE_SOURCE_TARGET)
		message(FATAL_ERROR "TARGET is required argument for IDL_GENERATE_SOURCE macro")
	endif()

	message(STATUS "TARGET ${IDL_GENERATE_SOURCE_TARGET}")
	message(STATUS "SOURCES_DIR ${IDL_GENERATE_SOURCE_SOURCES_DIR}")
	message(STATUS "DESTINATION ${IDL_GENERATE_SOURCE_DESTINATION}")
	message(STATUS "IDLC_PATH ${IDL_GENERATE_SOURCE_IDLC_PATH}")
	file(GLOB_RECURSE _DEPS ${IDL_GENERATE_SOURCE_IDLC_PATH}/*.h ${IDL_GENERATE_SOURCE_IDLC_PATH}/*.cpp ${IDL_GENERATE_SOURCE_IDLC_PATH}/*.py)
	set(_OUTPUT)
	foreach(_INPUT ${IDL_GENERATE_SOURCE_SOURCES})
		get_filename_component(_NAME ${_INPUT} NAME)
		get_filename_component(_PACKAGE ${_INPUT} DIRECTORY)
		string(LENGTH ${_NAME} _NAME_LEN)
		math(EXPR _NAME_LEN_NOEXT "${_NAME_LEN} - 4")
		string(SUBSTRING ${_NAME} 0 ${_NAME_LEN_NOEXT} _NAME)
		message(STATUS "INPUT NAME ${_PACKAGE}::${_NAME}")
		set(_INPUT_FILE "${IDL_GENERATE_SOURCE_SOURCES_DIR}/${_INPUT}")
		add_custom_command(OUTPUT
			${IDL_GENERATE_SOURCE_DESTINATION}/${_PACKAGE}/I${_NAME}.h
			${IDL_GENERATE_SOURCE_DESTINATION}/${_PACKAGE}/I${_NAME}.cpp
			${IDL_GENERATE_SOURCE_DESTINATION}/${_PACKAGE}/${_NAME}.h
			${IDL_GENERATE_SOURCE_DESTINATION}/${_PACKAGE}/${_NAME}.cpp
			DEPENDS ${_INPUT_FILE} ${_DEPS} ${IDL_GENERATE_SOURCE_IDLC_PATH}/idlc
			COMMAND ${IDL_GENERATE_SOURCE_IDLC_PATH}/idlc ${_INPUT_FILE} cpp ${IDL_GENERATE_SOURCE_DESTINATION}
			COMMENT "generating sources for ${_NAME}"
		)
		list(APPEND _OUTPUT ${IDL_GENERATE_SOURCE_DESTINATION}/${_PACKAGE}/I${_NAME}.cpp)
		list(APPEND _OUTPUT ${IDL_GENERATE_SOURCE_DESTINATION}/${_PACKAGE}/${_NAME}.cpp)
	endforeach()
	message(STATUS "idl shared library: ${IDL_GENERATE_SOURCE_TARGET}")
	add_library(${IDL_GENERATE_SOURCE_TARGET} SHARED ${_OUTPUT})
	set_target_properties(${IDL_GENERATE_SOURCE_TARGET} PROPERTIES VERSION 1.0) #fixme: use shared version?
	install(TARGETS ${IDL_GENERATE_SOURCE_TARGET} DESTINATION lib)
endfunction(IDL_GENERATE_SOURCE)
