summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/find_library
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-12-08 20:12:51 (GMT)
committerBrad King <brad.king@kitware.com>2014-12-08 20:35:50 (GMT)
commitce331bab929c5a38e048ba15d7393dcf96fad9e1 (patch)
tree21357d2d12d5b425b596bca81cbd70e91b912ba0 /Tests/RunCMake/find_library
parent09498b2ead29a64816e5c301b7465164cec25c1c (diff)
downloadCMake-ce331bab929c5a38e048ba15d7393dcf96fad9e1.zip
CMake-ce331bab929c5a38e048ba15d7393dcf96fad9e1.tar.gz
CMake-ce331bab929c5a38e048ba15d7393dcf96fad9e1.tar.bz2
find_library: Fix repeat call after changing directory content (#15293)
We use cmGlobalGenerator::GetDirectoryContent to avoid repeating directory listings. However, GetDirectoryContent loads content from disk at most once. This breaks find_library calls that occur when disk content has changed since preceding find_library calls. Teach cmGlobalGenerator::GetDirectoryContent to save the directory modification time when content is loaded and re-load content if it changes. Create a RunCMake.find_library test with a case covering this.
Diffstat (limited to 'Tests/RunCMake/find_library')
-rw-r--r--Tests/RunCMake/find_library/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/find_library/Created-stderr.txt2
-rw-r--r--Tests/RunCMake/find_library/Created.cmake16
-rw-r--r--Tests/RunCMake/find_library/RunCMakeTest.cmake3
4 files changed, 24 insertions, 0 deletions
diff --git a/Tests/RunCMake/find_library/CMakeLists.txt b/Tests/RunCMake/find_library/CMakeLists.txt
new file mode 100644
index 0000000..ef2163c
--- /dev/null
+++ b/Tests/RunCMake/find_library/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.1)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/find_library/Created-stderr.txt b/Tests/RunCMake/find_library/Created-stderr.txt
new file mode 100644
index 0000000..67b3474
--- /dev/null
+++ b/Tests/RunCMake/find_library/Created-stderr.txt
@@ -0,0 +1,2 @@
+CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND'
+CREATED_LIBRARY='[^']*/Tests/RunCMake/find_library/Created-build/lib/libcreated.a'
diff --git a/Tests/RunCMake/find_library/Created.cmake b/Tests/RunCMake/find_library/Created.cmake
new file mode 100644
index 0000000..c0fd823
--- /dev/null
+++ b/Tests/RunCMake/find_library/Created.cmake
@@ -0,0 +1,16 @@
+list(APPEND CMAKE_FIND_LIBRARY_PREFIXES lib)
+list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .a)
+find_library(CREATED_LIBRARY
+ NAMES created
+ PATHS ${CMAKE_CURRENT_BINARY_DIR}/lib
+ NO_DEFAULT_PATH
+ )
+message("CREATED_LIBRARY='${CREATED_LIBRARY}'")
+file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/lib/libcreated.a" "created")
+find_library(CREATED_LIBRARY
+ NAMES created
+ PATHS ${CMAKE_CURRENT_BINARY_DIR}/lib
+ NO_DEFAULT_PATH
+ )
+message("CREATED_LIBRARY='${CREATED_LIBRARY}'")
diff --git a/Tests/RunCMake/find_library/RunCMakeTest.cmake b/Tests/RunCMake/find_library/RunCMakeTest.cmake
new file mode 100644
index 0000000..4000679
--- /dev/null
+++ b/Tests/RunCMake/find_library/RunCMakeTest.cmake
@@ -0,0 +1,3 @@
+include(RunCMake)
+
+run_cmake(Created)