summaryrefslogtreecommitdiff
path: root/cmake/modules/AddResources.cmake
blob: 4f4f8007bae47b5bc7575ac56fc25c879e9ea100 (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
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}"
		)
	endforeach()
	list(TRANSFORM RESOURCES_FILES PREPEND "${RESOURCES_PREFIX}/")
	add_custom_target(
		${RESOURCES_TARGET} ALL
		DEPENDS ${RESOURCES_FILES}
	)
endfunction()