~aleteoryx/muditaos

ref: 1a26cdb407c14dd46d4232e61095999b7bd032e7 muditaos/image/CMakeLists.txt -rw-r--r-- 1.5 KiB
1a26cdb4 — Borys Jelenski [EGD-4527] Add creating update package as CMake target 5 years ago
                                                                                
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
include(Utils)

set(ASSETS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(ASSETS_DEST_DIR "${CMAKE_BINARY_DIR}")

file (GLOB_RECURSE ASSETS_LIST
    LIST_DIRECTORIES false
    RELATIVE ${ASSETS_SOURCE_DIR}
    ${ASSETS_SOURCE_DIR}/*
    )

list(REMOVE_ITEM ASSETS_LIST "CMakeLists.txt")

foreach(ASSET ${ASSETS_LIST})
    set(asset_source "${ASSETS_SOURCE_DIR}/${ASSET}")
    get_filename_component(filename "${ASSET}" NAME)
    get_filename_component(dir "${ASSET}" DIRECTORY)

    if(dir)
        set(destdir "${ASSETS_DEST_DIR}/${dir}")
        multicomp_install(
            FILES ${ASSET}
            DESTINATION ${dir}
            COMPONENTS Standalone Update
            )
    else()
        set(destdir "${ASSETS_DEST_DIR}")
        multicomp_install(
            FILES ${ASSET}
            DESTINATION "./"
            COMPONENTS Standalone Update)
    endif()

    set(outfile "${destdir}/${filename}")
    string(REPLACE "/" "-" target_name ${ASSET})
    string(REPLACE " " "_" target_name ${target_name})
    if(${target_name} STREQUAL ${ASSET})
        set(target_name "file-${target_name}")
    endif()

    add_custom_command(
        COMMENT "Copying resource: ${ASSET}"
        OUTPUT ${outfile}
        DEPENDS ${asset_source}
        COMMAND ${CMAKE_COMMAND} -E copy_if_different
            ${asset_source}
            ${outfile}
        )
    add_custom_target(${target_name} ALL DEPENDS ${outfile})
    if (${ENABLE_TESTS})
        add_dependencies(check ${target_name})
    endif ()
    add_dependencies(assets ${target_name})
endforeach()