Mercurial > hg > orthanc-stl
comparison Resources/Orthanc/CMake/Compiler.cmake @ 21:42ebec01143b
sync
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 22 Nov 2023 08:01:03 +0100 |
parents | 4e889a8e8be2 |
children | dd0cd39e6259 |
comparison
equal
deleted
inserted
replaced
20:cb7fd3c25f40 | 21:42ebec01143b |
---|---|
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 # Microsoft Visual Studio is extremely slow if using | |
275 # "set_property()", we only enable this feature for gcc and clang | |
276 if (CMAKE_COMPILER_IS_GNUCXX OR | |
277 CMAKE_CXX_COMPILER_ID STREQUAL "Clang") | |
278 get_target_property(source_files "${targetname}" SOURCES) | |
279 foreach(sourcefile ${source_files}) | |
280 get_filename_component(basename "${sourcefile}" NAME) | |
281 set_property( | |
282 SOURCE "${sourcefile}" APPEND | |
283 PROPERTY COMPILE_DEFINITIONS "__ORTHANC_FILE__=\"${basename}\"") | |
284 endforeach() | |
285 endif() | |
286 endfunction() |