diff options
Diffstat (limited to 'Resources.cmake')
-rw-r--r-- | Resources.cmake | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Resources.cmake b/Resources.cmake new file mode 100644 index 00000000..fc5d20c6 --- /dev/null +++ b/Resources.cmake | |||
@@ -0,0 +1,27 @@ | |||
1 | find_program (ZIP_EXECUTABLE zip DOC "ZIP archiver") | ||
2 | if (NOT ZIP_EXECUTABLE) | ||
3 | message (FATAL_ERROR "Please install 'zip' for packaging resources.") | ||
4 | endif () | ||
5 | |||
6 | function (make_resources dst) | ||
7 | list (REMOVE_AT ARGV 0) | ||
8 | set (files) | ||
9 | foreach (arg ${ARGV}) | ||
10 | get_filename_component (name ${arg} NAME) | ||
11 | if (NOT "${name}" MATCHES "^\\..*") | ||
12 | string (SUBSTRING ${arg} 4 -1 rel) | ||
13 | list (APPEND files ${rel}) | ||
14 | endif () | ||
15 | endforeach (arg) | ||
16 | file (REMOVE ${dst}) | ||
17 | get_filename_component (dstName ${dst} NAME) | ||
18 | message (STATUS " ${dstName}") | ||
19 | set (versionTempPath ${CMAKE_SOURCE_DIR}/res/VERSION) | ||
20 | file (WRITE ${versionTempPath} ${PROJECT_VERSION}) | ||
21 | execute_process ( | ||
22 | COMMAND ${ZIP_EXECUTABLE} -1 ${dst} VERSION ${files} | ||
23 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/res | ||
24 | OUTPUT_QUIET | ||
25 | ) | ||
26 | file (REMOVE ${versionTempPath}) | ||
27 | endfunction () | ||