Mercurial > hg > orthanc
diff 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 |
line wrap: on
line diff
--- a/OrthancFramework/Resources/CMake/Compiler.cmake Tue Jul 04 18:39:52 2023 +0200 +++ b/OrthancFramework/Resources/CMake/Compiler.cmake Thu Jul 06 17:04:31 2023 +0200 @@ -263,3 +263,19 @@ # preceding batches. https://cmake.org/Bug/view.php?id=14874 set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> <LINK_FLAGS> q <TARGET> <OBJECTS>") endif() + + +# This function defines macro "__ORTHANC_FILE__" as a replacement to +# macro "__FILE__", as the latter leaks the full path of the source +# files in the binaries +# https://stackoverflow.com/questions/8487986/file-macro-shows-full-path +# https://twitter.com/wget42/status/1676877802375634944?s=20 +function(DefineSourceBasenameForTarget targetname) + get_target_property(source_files "${targetname}" SOURCES) + foreach(sourcefile ${source_files}) + get_filename_component(basename "${sourcefile}" NAME) + set_property( + SOURCE "${sourcefile}" APPEND + PROPERTY COMPILE_DEFINITIONS "__ORTHANC_FILE__=\"${basename}\"") + endforeach() +endfunction()