comparison Resources/Orthanc/CMake/Compiler.cmake @ 425:c1b0f3c4e1f5

sync Orthanc code
author Alain Mazy <am@osimis.io>
date Mon, 13 Nov 2023 20:37:04 +0100
parents 3d6886f3e5b3
children ecd0b719cff5
comparison
equal deleted inserted replaced
423:7d2ba3ece4ee 425:c1b0f3c4e1f5
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()