Mercurial > hg > orthanc
comparison Resources/CMake/AutoGeneratedCode.cmake @ 1469:bf9b8bfea0e7
more generic EmbedResources.py
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 30 Jul 2015 14:12:12 +0200 |
parents | efc448de0899 |
children | 100fbe970762 |
comparison
equal
deleted
inserted
replaced
1468:332af9bcabc8 | 1469:bf9b8bfea0e7 |
---|---|
4 file(MAKE_DIRECTORY ${AUTOGENERATED_DIR}) | 4 file(MAKE_DIRECTORY ${AUTOGENERATED_DIR}) |
5 include_directories(${AUTOGENERATED_DIR}) | 5 include_directories(${AUTOGENERATED_DIR}) |
6 | 6 |
7 macro(EmbedResources) | 7 macro(EmbedResources) |
8 # Convert a semicolon separated list to a whitespace separated string | 8 # Convert a semicolon separated list to a whitespace separated string |
9 set(SCRIPT_OPTIONS) | |
9 set(SCRIPT_ARGUMENTS) | 10 set(SCRIPT_ARGUMENTS) |
10 set(DEPENDENCIES) | 11 set(DEPENDENCIES) |
11 set(IS_PATH_NAME false) | 12 set(IS_PATH_NAME false) |
13 | |
14 # Loop over the arguments of the function | |
12 foreach(arg ${ARGN}) | 15 foreach(arg ${ARGN}) |
13 if (${IS_PATH_NAME}) | 16 # Extract the first character of the argument |
14 list(APPEND SCRIPT_ARGUMENTS "${arg}") | 17 string(SUBSTRING "${arg}" 0 1 FIRST_CHAR) |
15 list(APPEND DEPENDENCIES "${arg}") | 18 if (${FIRST_CHAR} STREQUAL "-") |
16 set(IS_PATH_NAME false) | 19 # If the argument starts with a dash "-", this is an option to |
20 # EmbedResources.py | |
21 list(APPEND SCRIPT_OPTIONS ${arg}) | |
17 else() | 22 else() |
18 list(APPEND SCRIPT_ARGUMENTS "${arg}") | 23 if (${IS_PATH_NAME}) |
19 set(IS_PATH_NAME true) | 24 list(APPEND SCRIPT_ARGUMENTS "${arg}") |
25 list(APPEND DEPENDENCIES "${arg}") | |
26 set(IS_PATH_NAME false) | |
27 else() | |
28 list(APPEND SCRIPT_ARGUMENTS "${arg}") | |
29 set(IS_PATH_NAME true) | |
30 endif() | |
20 endif() | 31 endif() |
21 endforeach() | 32 endforeach() |
22 | 33 |
23 set(TARGET_BASE "${AUTOGENERATED_DIR}/EmbeddedResources") | 34 set(TARGET_BASE "${AUTOGENERATED_DIR}/EmbeddedResources") |
24 add_custom_command( | 35 add_custom_command( |
26 "${TARGET_BASE}.h" | 37 "${TARGET_BASE}.h" |
27 "${TARGET_BASE}.cpp" | 38 "${TARGET_BASE}.cpp" |
28 COMMAND | 39 COMMAND |
29 ${PYTHON_EXECUTABLE} | 40 ${PYTHON_EXECUTABLE} |
30 "${ORTHANC_ROOT}/Resources/EmbedResources.py" | 41 "${ORTHANC_ROOT}/Resources/EmbedResources.py" |
42 ${SCRIPT_OPTIONS} | |
31 "${AUTOGENERATED_DIR}/EmbeddedResources" | 43 "${AUTOGENERATED_DIR}/EmbeddedResources" |
32 ${SCRIPT_ARGUMENTS} | 44 ${SCRIPT_ARGUMENTS} |
33 DEPENDS | 45 DEPENDS |
34 "${ORTHANC_ROOT}/Resources/EmbedResources.py" | 46 "${ORTHANC_ROOT}/Resources/EmbedResources.py" |
35 ${DEPENDENCIES} | 47 ${DEPENDENCIES} |