changeset 5359:035ebc5b227c

disable DefineSourceBasenameForTarget for MSVC
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 06 Jul 2023 19:40:13 +0200
parents 0069769cab66
children 165b67c02927
files OrthancFramework/Resources/CMake/Compiler.cmake
diffstat 1 files changed, 12 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancFramework/Resources/CMake/Compiler.cmake	Thu Jul 06 17:04:42 2023 +0200
+++ b/OrthancFramework/Resources/CMake/Compiler.cmake	Thu Jul 06 19:40:13 2023 +0200
@@ -271,11 +271,16 @@
 # 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()
+  # Microsoft Visual Studio is extremely slow if using
+  # "set_property()", we only enable this feature for gcc and clang
+  if (CMAKE_COMPILER_IS_GNUCXX OR
+      CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+    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()
+  endif()
 endfunction()