Mercurial > hg > orthanc-stl
comparison Resources/Orthanc/CMake/AutoGeneratedCode.cmake @ 0:4e889a8e8be2
initial commit of the viewer plugin
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 04 Jul 2023 19:15:27 +0200 |
parents | |
children | dd0cd39e6259 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4e889a8e8be2 |
---|---|
1 # Orthanc - A Lightweight, RESTful DICOM Store | |
2 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
3 # Department, University Hospital of Liege, Belgium | |
4 # Copyright (C) 2017-2023 Osimis S.A., Belgium | |
5 # Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium | |
6 # | |
7 # This program is free software: you can redistribute it and/or | |
8 # modify it under the terms of the GNU Lesser General Public License | |
9 # as published by the Free Software Foundation, either version 3 of | |
10 # the License, or (at your option) any later version. | |
11 # | |
12 # This program is distributed in the hope that it will be useful, but | |
13 # WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 # Lesser General Public License for more details. | |
16 # | |
17 # You should have received a copy of the GNU Lesser General Public | |
18 # License along with this program. If not, see | |
19 # <http://www.gnu.org/licenses/>. | |
20 | |
21 | |
22 set(EMBED_RESOURCES_PYTHON "${CMAKE_CURRENT_LIST_DIR}/../EmbedResources.py" | |
23 CACHE INTERNAL "Path to the EmbedResources.py script from Orthanc") | |
24 set(AUTOGENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}/AUTOGENERATED") | |
25 set(AUTOGENERATED_SOURCES) | |
26 | |
27 file(MAKE_DIRECTORY ${AUTOGENERATED_DIR}) | |
28 include_directories(${AUTOGENERATED_DIR}) | |
29 | |
30 macro(EmbedResources) | |
31 # Convert a semicolon separated list to a whitespace separated string | |
32 set(SCRIPT_OPTIONS) | |
33 set(SCRIPT_ARGUMENTS) | |
34 set(DEPENDENCIES) | |
35 set(IS_PATH_NAME false) | |
36 | |
37 set(TARGET_BASE "${AUTOGENERATED_DIR}/EmbeddedResources") | |
38 | |
39 # Loop over the arguments of the function | |
40 foreach(arg ${ARGN}) | |
41 # Extract the first character of the argument | |
42 string(SUBSTRING "${arg}" 0 1 FIRST_CHAR) | |
43 if (${FIRST_CHAR} STREQUAL "-") | |
44 # If the argument starts with a dash "-", this is an option to | |
45 # EmbedResources.py | |
46 if (${arg} MATCHES "--target=.*") | |
47 # Does the argument starts with "--target="? | |
48 string(SUBSTRING "${arg}" 9 -1 TARGET) # 9 is the length of "--target=" | |
49 set(TARGET_BASE "${AUTOGENERATED_DIR}/${TARGET}") | |
50 else() | |
51 list(APPEND SCRIPT_OPTIONS ${arg}) | |
52 endif() | |
53 else() | |
54 if (${IS_PATH_NAME}) | |
55 list(APPEND SCRIPT_ARGUMENTS "${arg}") | |
56 list(APPEND DEPENDENCIES "${arg}") | |
57 set(IS_PATH_NAME false) | |
58 else() | |
59 list(APPEND SCRIPT_ARGUMENTS "${arg}") | |
60 set(IS_PATH_NAME true) | |
61 endif() | |
62 endif() | |
63 endforeach() | |
64 | |
65 add_custom_command( | |
66 OUTPUT | |
67 "${TARGET_BASE}.h" | |
68 "${TARGET_BASE}.cpp" | |
69 COMMAND ${PYTHON_EXECUTABLE} ${EMBED_RESOURCES_PYTHON} | |
70 ${SCRIPT_OPTIONS} "${TARGET_BASE}" ${SCRIPT_ARGUMENTS} | |
71 DEPENDS | |
72 ${EMBED_RESOURCES_PYTHON} | |
73 ${DEPENDENCIES} | |
74 ) | |
75 | |
76 list(APPEND AUTOGENERATED_SOURCES | |
77 "${TARGET_BASE}.cpp" | |
78 ) | |
79 endmacro() |