diff --git a/.gitattributes b/.gitattributes
index 27be6b2a9d6722cb6775eca1f172f2b1d93da365..f564c09a1120063af993145eb83ef2b39eff71f7 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -2196,6 +2196,7 @@ CMake/FindOpenCL.cmake -text
 CMake/FindValgrind.cmake -text
 CMake/LofarPackageList.cmake eol=lf
 CMake/TODO -text
+CMake/get_casacore_deps.sh eol=lf
 CMake/testscripts/assay -text
 CMake/testscripts/checkfloat -text
 CMake/testscripts/default.debug -text
diff --git a/CMake/get_casacore_deps.sh b/CMake/get_casacore_deps.sh
new file mode 100755
index 0000000000000000000000000000000000000000..9dff17dfc3c85efa1b8fc7e95ac822f37413ca02
--- /dev/null
+++ b/CMake/get_casacore_deps.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+# 
+# Derive casacore dependencies from the installed shared libraries.
+
+# Location to search for casacore shared libraries.
+CASACORE_LIBDIR=${1:-/opt/lofar/external/casacore/lib}
+
+# Make sure that we get a deterministic lexicograhical ordering.
+LC_ALL=C
+
+# Expand to null string if no files match glob pattern
+shopt -s nullglob
+
+echo "Searching for libraries in $CASACORE_LIBDIR ..." 1>&2
+
+echo "# Define the Casacore components."
+echo "set(Casacore_components"
+for f in $CASACORE_LIBDIR/*.so
+do
+  comp=$(echo ${f%%.so} | sed 's,^.*libcasa_,,')
+  echo "  $comp"
+done
+echo ")"
+echo
+echo "# Define the Casacore components' inter-dependencies."
+for f in $CASACORE_LIBDIR/*.so
+do
+  comp=$(echo ${f%%.so} | sed 's,^.*libcasa_,,')
+  printf "%-39s" "set(Casacore_${comp}_DEPENDENCIES "
+  libs=$(readelf -d $f | grep 'NEEDED.*libcasa_' | \
+         sed -e 's,^[^\[]*\[libcasa_,,' -e 's,\..*$,,')
+  for l in $libs
+  do
+    printf " %s" "$l"
+  done
+  printf ")\n"
+done