embed_recursive_into_asm.cmake 1.56 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
20
21
22
23
24
25
26
				COMMAND ${CMAKE_COMMAND} -E copy_if_different "${path}" "${dst}/"
				OUTPUT_QUIET
			)
			list(APPEND local_copied_files "${dst}/${file}") 
		endif()
	endforeach(path)
	
	set(copied_files "${local_copied_files}" PARENT_SCOPE)
endfunction()

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

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

34
35
36
37
38
39
40
41
42
43
44
45
46
if("${EMBED_MODE} " STREQUAL "MSVC ")
	string(TOUPPER "${ID}" RES_ID)
	configure_file(${MIRRAGE_ROOT_DIR}/embedded_assets.rc.in "${CMAKE_CURRENT_BINARY_DIR}/embedded_assets.rc")
	execute_process(COMMAND ${CMAKE_COMMAND} -E touch "${CMAKE_CURRENT_BINARY_DIR}/embedded_assets.rc" OUTPUT_QUIET)
else()
	if("${EMBED_MODE} " STREQUAL "APPLE ")
		set(SECTION ".const_data")
	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()