embed_recursive_into_asm.cmake 1.58 KB
Newer Older
1
2
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)

3
4
5
6
function(mirrage_copy_recursive src dst)
	foreach(path ${src})
		get_filename_component(file ${path} NAME)
		if(IS_DIRECTORY ${path})
7
			set(files "")
8
9
10
11
12
13
			file(GLOB files ${path}/*)
			mirrage_copy_recursive("${files}" "${dst}/${file}")
			set(local_copied_files ${local_copied_files} ${copied_files}) 
		else()
			execute_process(
				COMMAND ${CMAKE_COMMAND} -E make_directory "${dst}"
Florian Oetke's avatar
Florian Oetke committed
14
15
16
				OUTPUT_QUIET
			)
			execute_process(
17
18
19
				COMMAND ${CMAKE_COMMAND} -E copy_if_different "${path}" "${dst}/"
				OUTPUT_QUIET
			)
20
21
			file(RELATIVE_PATH REL_PATH "${DST_DIR}/embed" "${dst}/${file}")
			list(APPEND local_copied_files ${REL_PATH}) 
22
23
24
25
26
27
		endif()
	endforeach(path)
	
	set(copied_files "${local_copied_files}" PARENT_SCOPE)
endfunction()

28
mirrage_copy_recursive("${SRC_FILES}" "${DST_DIR}/embed")
29

30
execute_process(COMMAND ${CMAKE_COMMAND} -E tar "cfv" "${DST_DIR}/embedded_assets.zip" --format=zip ${copied_files}
31
	WORKING_DIRECTORY "${DST_DIR}/embed"
32
	OUTPUT_QUIET
33
)
34

35
36
if("${EMBED_MODE} " STREQUAL "MSVC ")
	string(TOUPPER "${ID}" RES_ID)
37
38
	configure_file(${MIRRAGE_ROOT_DIR}/embedded_assets.rc.in "${EMBED_SRC_FILE}")
	execute_process(COMMAND ${CMAKE_COMMAND} -E touch "${EMBED_SRC_FILE}" OUTPUT_QUIET)
39
40
else()
	if("${EMBED_MODE} " STREQUAL "APPLE ")
41
		set(SECTION ".const_data, no_dead_strip")
42
43
44
45
46
47
	else()
		set(SECTION ".section .rodata")
	endif()
	configure_file(${MIRRAGE_ROOT_DIR}/embedded_assets.s.in "${CMAKE_CURRENT_BINARY_DIR}/embedded_assets.s")
	execute_process(COMMAND ${CMAKE_COMMAND} -E touch "${CMAKE_CURRENT_BINARY_DIR}/embedded_assets.s" OUTPUT_QUIET)
endif()