Mercurial > hg > orthanc
comparison OrthancFramework/Resources/CMake/Compiler.cmake @ 5357:fddb5d8d0021
Prevent the leak of the full path of the source files in the binaries
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 06 Jul 2023 17:04:31 +0200 |
parents | 0ea402b4d901 |
children | 035ebc5b227c |
comparison
equal
deleted
inserted
replaced
5354:65b4e6ae2703 | 5357:fddb5d8d0021 |
---|---|
261 # will invoke "ar" several times with several batches of ".o" | 261 # will invoke "ar" several times with several batches of ".o" |
262 # objects, and using "r" would overwrite symbols defined in | 262 # objects, and using "r" would overwrite symbols defined in |
263 # preceding batches. https://cmake.org/Bug/view.php?id=14874 | 263 # preceding batches. https://cmake.org/Bug/view.php?id=14874 |
264 set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> <LINK_FLAGS> q <TARGET> <OBJECTS>") | 264 set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> <LINK_FLAGS> q <TARGET> <OBJECTS>") |
265 endif() | 265 endif() |
266 | |
267 | |
268 # This function defines macro "__ORTHANC_FILE__" as a replacement to | |
269 # macro "__FILE__", as the latter leaks the full path of the source | |
270 # files in the binaries | |
271 # https://stackoverflow.com/questions/8487986/file-macro-shows-full-path | |
272 # https://twitter.com/wget42/status/1676877802375634944?s=20 | |
273 function(DefineSourceBasenameForTarget targetname) | |
274 get_target_property(source_files "${targetname}" SOURCES) | |
275 foreach(sourcefile ${source_files}) | |
276 get_filename_component(basename "${sourcefile}" NAME) | |
277 set_property( | |
278 SOURCE "${sourcefile}" APPEND | |
279 PROPERTY COMPILE_DEFINITIONS "__ORTHANC_FILE__=\"${basename}\"") | |
280 endforeach() | |
281 endfunction() |