summaryrefslogtreecommitdiff
path: root/cmake/modules/AddResources.cmake
blob: b59258ebc0c060dd5537d9739b794a0008d27d01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function(add_resources RESOURCES_TARGET)
	cmake_parse_arguments(
		PARSE_ARGV 1
		RESOURCES
		""
		"PREFIX"
		"FILES"
	)
	if(NOT DEFINED RESOURCES_PREFIX)
		set(RESOURCES_PREFIX ${CMAKE_BINARY_DIR})
	endif()
	foreach(RESOURCES_SOURCE IN ITEMS ${RESOURCES_FILES})
		add_custom_command(
			OUTPUT "${RESOURCES_PREFIX}/${RESOURCES_SOURCE}"
			DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${RESOURCES_SOURCE}"
			COMMAND
				${CMAKE_COMMAND} -E copy
				"${CMAKE_CURRENT_SOURCE_DIR}/${RESOURCES_SOURCE}"
				"${RESOURCES_PREFIX}/${RESOURCES_SOURCE}"
			COMMENT "Moving ${RESOURCES_SOURCE}"
		)
	endforeach()
	list(TRANSFORM RESOURCES_FILES PREPEND "${RESOURCES_PREFIX}/")
	add_custom_target(
		${RESOURCES_TARGET} ALL
		DEPENDS ${RESOURCES_FILES}
	)
endfunction()