summaryrefslogtreecommitdiff
path: root/Resources.cmake
blob: 15ef15ea3c336f7528a19b7dc7a5d233de4d429b (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
find_program (ZIP_EXECUTABLE zip DOC "ZIP archiver")
if (NOT ZIP_EXECUTABLE)
    message (FATAL_ERROR "Please install 'zip' for packaging resources.")
endif ()

function (make_resources dst)
    list (REMOVE_AT ARGV 0)
    set (files)
    foreach (arg ${ARGV})
        get_filename_component (name ${arg} NAME)
        if (NOT "${name}" MATCHES "^\\..*")
            string (SUBSTRING ${arg} 4 -1 rel)
            list (APPEND files ${rel})
        endif ()
    endforeach (arg)
    file (REMOVE ${dst})
    get_filename_component (dstName ${dst} NAME)
    message (STATUS "  ${dstName}")
    set (versionTempPath ${CMAKE_CURRENT_SOURCE_DIR}/res/VERSION)
    file (WRITE ${versionTempPath} ${PROJECT_VERSION})
    execute_process (
        COMMAND ${ZIP_EXECUTABLE} -1 ${dst} VERSION ${files}
        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/res
        OUTPUT_QUIET
    )
    file (REMOVE ${versionTempPath})
endfunction ()