-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
visrealm_tools.cmake
58 lines (47 loc) · 2.16 KB
/
visrealm_tools.cmake
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
cmake_minimum_required(VERSION 3.12)
set(IMG_CONV ${CMAKE_SOURCE_DIR}/tools/img2carray.py)
set(BIN_CONV ${CMAKE_SOURCE_DIR}/tools/bin2carray.py)
set(PYTHON python3)
# custom function to generate source code from images using tools/img2carray.py
function(visrealm_generate_image_source TARGET DST ROMSRC)
set(fullSrc ${CMAKE_CURRENT_SOURCE_DIR}/${ROMSRC})
cmake_path(GET fullSrc PARENT_PATH srcPath)
set (RAMSRCARG)
set (extra_args ${ARGN})
list(LENGTH extra_args extra_count)
if (${extra_count} GREATER 0)
list(GET extra_args 0 RAMSRC)
set(RAMSRCARG -r ${CMAKE_CURRENT_SOURCE_DIR}/${RAMSRC})
endif()
add_custom_command(
OUTPUT ${DST}.c ${DST}.h
COMMAND ${PYTHON} ${IMG_CONV} -i ${CMAKE_CURRENT_SOURCE_DIR}/${ROMSRC} ${RAMSRCARG} -o ${DST}.c
DEPENDS ${IMG_CONV} ${srcPath}
)
target_include_directories(${TARGET} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_sources(${TARGET} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/${DST}.c)
endfunction()
# custom function to generate source code from images using tools/img2carray.py
function(visrealm_generate_image_source_ram TARGET DST RAMSRC)
set(fullSrc ${CMAKE_CURRENT_SOURCE_DIR}/${RAMSRC})
cmake_path(GET fullSrc PARENT_PATH srcPath)
add_custom_command(
OUTPUT ${DST}.c ${DST}.h
COMMAND ${PYTHON} ${IMG_CONV} -r ${CMAKE_CURRENT_SOURCE_DIR}/${RAMSRC} -o ${DST}.c
DEPENDS ${IMG_CONV} ${srcPath}
)
target_include_directories(${TARGET} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_sources(${TARGET} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/${DST}.c)
endfunction()
# custom function to generate source code from images using tools/img2carray.py
function(visrealm_generate_bindata_source TARGET DST SRC)
set(fullSrc ${CMAKE_CURRENT_SOURCE_DIR}/${SRC})
cmake_path(GET fullSrc PARENT_PATH srcPath)
add_custom_command(
OUTPUT ${DST}.c ${DST}.h
COMMAND ${PYTHON} ${BIN_CONV} -i ${CMAKE_CURRENT_SOURCE_DIR}/${SRC} -o ${DST}.c
DEPENDS ${BIN_CONV} ${srcPath}
)
target_include_directories(${TARGET} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_sources(${TARGET} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/${DST}.c)
endfunction()