diff --git a/cmake/DD4hepBuild.cmake b/cmake/DD4hepBuild.cmake
index 088abfa8c41455e2422989294d1460a2aa7a792c..5b5c88c081ae7d1acce673ba985d2aff4269fc50 100644
--- a/cmake/DD4hepBuild.cmake
+++ b/cmake/DD4hepBuild.cmake
@@ -80,12 +80,28 @@ macro(dd4hep_set_compiler_flags)
     message( STATUS "Unknown thread library: CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS}" )
   endif()
 
-  if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
+  # resolve which linker we use
+  execute_process(COMMAND ${CMAKE_CXX_COMPILER} -Wl,--version OUTPUT_VARIABLE stdout ERROR_QUIET)
+  if("${stdout}" MATCHES "GNU ")
+    set(LINKER_TYPE "GNU")
+    dd4hep_debug("|DDD> Detected GNU compatible linker: ${stdout}" )
+  else()
+    execute_process(COMMAND ${CMAKE_CXX_COMPILER} -Wl,-v ERROR_VARIABLE stderr )
+    if(("${stderr}" MATCHES "PROGRAM:ld") AND ("${stderr}" MATCHES "PROJECT:ld64"))
+      set(LINKER_TYPE "APPLE")
+      dd4hep_debug("|DDD> Detected Apple linker: ${stderr}" )
+    else()
+      set(LINKER_TYPE "unknown")
+      dd4hep_debug("|DDD> Detected unknown linker: ${stdout} ${stderr}" )
+    endif()
+  endif()
+
+  if("${LINKER_TYPE}" STREQUAL "APPLE")
     SET ( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-undefined,error")
-  elseif ( ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") OR ( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" ))
+  elseif("${LINKER_TYPE}" STREQUAL "GNU")
     SET ( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
   else()
-    MESSAGE( WARNING "We do not test with the ${CMAKE_CXX_COMPILER_ID} compiler, use at your own discretion" )
+    MESSAGE( WARNING "No known linker (GNU or Apple) has been detected, pass no flags to linker" )
   endif()
 
  #---RPATH options-------------------------------------------------------------------------------