Improve CMake backward compatibility

Use code with clear behavior in CMake 2.8.12 (which we try to support in
Mbed TLS 2.28, although that's mostly for the sake of RHEL, not Windows).
The code in the previous commit relied on features introduced in CMake 3.x,
although it worked as desired by accident because `LIST_DIRECTORIES false`
was effectively ignored and `configure_file` on a directory had no
harmful effect.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Signed-off-by: David Horstmann <david.horstmann@arm.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 755ac27..72cc737 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -153,9 +153,11 @@
             endif()
         else()
             if (IS_DIRECTORY ${target})
-                file(GLOB_RECURSE files FOLLOW_SYMLINKS LIST_DIRECTORIES false RELATIVE ${target} "${target}/*")
+                file(GLOB_RECURSE files FOLLOW_SYMLINKS RELATIVE ${target} "${target}/*")
                 foreach(file IN LISTS files)
-                    configure_file("${target}/${file}" "${link}/${file}" COPYONLY)
+                    if(NOT IS_DIRECTORY "${target}/${file}")
+                        configure_file("${target}/${file}" "${link}/${file}" COPYONLY)
+                    endif()
                 endforeach(file)
             else()
                 configure_file(${target} ${link} COPYONLY)