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