summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2021-06-01 14:05:34 (GMT)
committerBrad King <brad.king@kitware.com>2021-06-02 18:55:00 (GMT)
commit87b71eec6257b0d9c43b446205d61f334278fe7d (patch)
tree727adaa232629c537ca47112fbc3f7fbeec36127 /Tests
parent2104cfe388f5d77b98727c89edff453b1d23fed6 (diff)
downloadCMake-87b71eec6257b0d9c43b446205d61f334278fe7d.zip
CMake-87b71eec6257b0d9c43b446205d61f334278fe7d.tar.gz
CMake-87b71eec6257b0d9c43b446205d61f334278fe7d.tar.bz2
find_*: Add support for option NO_CACHE
Request that find result is stored in a normal variable rather than a cache entry. Fixes: #20687 Issue: #20743
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/find_file/NO_CACHE-stdout.txt18
-rw-r--r--Tests/RunCMake/find_file/NO_CACHE.cmake129
-rw-r--r--Tests/RunCMake/find_file/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/find_library/NO_CACHE-stdout.txt18
-rw-r--r--Tests/RunCMake/find_library/NO_CACHE.cmake133
-rw-r--r--Tests/RunCMake/find_library/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/find_path/NO_CACHE-stdout.txt18
-rw-r--r--Tests/RunCMake/find_path/NO_CACHE.cmake131
-rw-r--r--Tests/RunCMake/find_path/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/find_program/NO_CACHE-stdout.txt18
-rw-r--r--Tests/RunCMake/find_program/NO_CACHE.cmake130
-rw-r--r--Tests/RunCMake/find_program/RunCMakeTest.cmake1
12 files changed, 599 insertions, 0 deletions
diff --git a/Tests/RunCMake/find_file/NO_CACHE-stdout.txt b/Tests/RunCMake/find_file/NO_CACHE-stdout.txt
new file mode 100644
index 0000000..e786321
--- /dev/null
+++ b/Tests/RunCMake/find_file/NO_CACHE-stdout.txt
@@ -0,0 +1,18 @@
+-- FILE_exists='.+/Tests/RunCMake/find_file/include/PrefixInPATH.h'
+-- FILE_doNotExists='FILE_doNotExists-NOTFOUND'
+--[ ]+
+-- Policy CMP0125 = OLD
+-- CACHED FILE_cache='unknown'
+-- FILE_cache='unknown'
+-- CACHED FILE_cache='PrefixInPATH.h'
+-- FILE_cache='PrefixInPATH.h'
+-- CACHED FILE_cache='PrefixInPATH.h'
+-- FILE_cache='PrefixInPATH.h'
+--[ ]+
+-- Policy CMP0125 = NEW
+-- CACHED FILE_cache='unknown'
+-- FILE_cache='unknown'
+-- CACHED FILE_cache='PrefixInPATH.h'
+-- FILE_cache='PrefixInPATH.h'
+-- CACHED FILE_cache='PrefixInPATH.h'
+-- FILE_cache='.+/Tests/RunCMake/find_file/NO_CACHE-build/PrefixInPATH.h'
diff --git a/Tests/RunCMake/find_file/NO_CACHE.cmake b/Tests/RunCMake/find_file/NO_CACHE.cmake
new file mode 100644
index 0000000..65156b9
--- /dev/null
+++ b/Tests/RunCMake/find_file/NO_CACHE.cmake
@@ -0,0 +1,129 @@
+find_file(FILE_exists
+ NAMES PrefixInPATH.h
+ PATHS ${CMAKE_CURRENT_SOURCE_DIR}/include
+ NO_CACHE
+ NO_DEFAULT_PATH
+ )
+if (DEFINED CACHE{FILE_exists})
+ message(SEND_ERROR "Cache variable defined: FILE_exists")
+endif()
+message(STATUS "FILE_exists='${FILE_exists}'")
+
+
+find_file(FILE_doNotExists
+ NAMES doNotExists.h
+ NO_CACHE
+ )
+if (DEFINED CACHE{FILE_doNotExists})
+ message(SEND_ERROR "Cache variable defined: FILE_doNotExists")
+endif()
+message(STATUS "FILE_doNotExists='${FILE_doNotExists}'")
+
+
+cmake_policy(SET CMP0125 OLD)
+message(STATUS "")
+message(STATUS "Policy CMP0125 = OLD")
+file(REMOVE "${CMAKE_BINARY_DIR}/PrefixInPATH.h")
+
+set(FILE_cache "unknown" CACHE FILEPATH "")
+find_file(FILE_cache
+ NAMES PrefixInPATH.h
+ PATHS ${CMAKE_CURRENT_SOURCE_DIR}/include
+ NO_CACHE
+ NO_DEFAULT_PATH
+ )
+if (NOT DEFINED CACHE{FILE_cache})
+ message(SEND_ERROR "Cache variable not defined: FILE_cache")
+endif()
+message(STATUS "CACHED FILE_cache='$CACHE{FILE_cache}'")
+unset(FILE_cache CACHE)
+message(STATUS "FILE_cache='${FILE_cache}'")
+
+
+set(FILE_cache "PrefixInPATH.h" CACHE FILEPATH "")
+unset(FILE_cache)
+find_file(FILE_cache
+ NAMES PrefixInPATH.h
+ PATHS ${CMAKE_CURRENT_SOURCE_DIR}/include
+ NO_CACHE
+ NO_DEFAULT_PATH
+ )
+if (NOT DEFINED CACHE{FILE_cache})
+ message(SEND_ERROR "Cache variable not defined: FILE_cache")
+endif()
+message(STATUS "CACHED FILE_cache='$CACHE{FILE_cache}'")
+unset(FILE_cache CACHE)
+message(STATUS "FILE_cache='${FILE_cache}'")
+
+
+set(FILE_cache "PrefixInPATH.h" CACHE FILEPATH "")
+unset(FILE_cache)
+# simulate cache variable defined in command line
+file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/include/PrefixInPATH.h" DESTINATION "${CMAKE_BINARY_DIR}")
+set_property(CACHE FILE_cache PROPERTY TYPE UNINITIALIZED)
+find_file(FILE_cache
+ NAMES PrefixInPATH.h
+ NO_CACHE
+ NO_DEFAULT_PATH
+ )
+if (NOT DEFINED CACHE{FILE_cache})
+ message(SEND_ERROR "Cache variable not defined: FILE_cache")
+endif()
+message(STATUS "CACHED FILE_cache='$CACHE{FILE_cache}'")
+unset(FILE_cache CACHE)
+message(STATUS "FILE_cache='${FILE_cache}'")
+
+
+cmake_policy(SET CMP0125 NEW)
+message(STATUS "")
+message(STATUS "Policy CMP0125 = NEW")
+file(REMOVE "${CMAKE_BINARY_DIR}/PrefixInPATH.h")
+
+set(FILE_cache "unknown" CACHE FILEPATH "")
+unset(FILE_cache)
+find_file(FILE_cache
+ NAMES PrefixInPATH.h
+ PATHS ${CMAKE_CURRENT_SOURCE_DIR}/include
+ NO_CACHE
+ NO_DEFAULT_PATH
+ )
+if (NOT DEFINED CACHE{FILE_cache})
+ message(SEND_ERROR "Cache variable not defined: FILE_cache")
+endif()
+message(STATUS "CACHED FILE_cache='$CACHE{FILE_cache}'")
+unset(FILE_cache CACHE)
+message(STATUS "FILE_cache='${FILE_cache}'")
+
+
+set(FILE_cache "PrefixInPATH.h" CACHE FILEPATH "")
+unset(FILE_cache)
+find_file(FILE_cache
+ NAMES PrefixInPATH.h
+ PATHS ${CMAKE_CURRENT_SOURCE_DIR}/include
+ NO_CACHE
+ NO_DEFAULT_PATH
+ )
+if (NOT DEFINED CACHE{FILE_cache})
+ message(SEND_ERROR "Cache variable not defined: FILE_cache")
+endif()
+message(STATUS "CACHED FILE_cache='$CACHE{FILE_cache}'")
+unset(FILE_cache CACHE)
+message(STATUS "FILE_cache='${FILE_cache}'")
+
+
+set(FILE_cache "PrefixInPATH.h" CACHE FILEPATH "")
+unset(FILE_cache)
+# simulate cache variable defined in command line
+file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/include/PrefixInPATH.h" DESTINATION "${CMAKE_BINARY_DIR}")
+set_property(CACHE FILE_cache PROPERTY TYPE UNINITIALIZED)
+find_file(FILE_cache
+ NAMES PrefixInPATH.h
+ NO_CACHE
+ NO_DEFAULT_PATH
+ )
+if (NOT DEFINED CACHE{FILE_cache})
+ message(SEND_ERROR "Cache variable not defined: FILE_cache")
+endif()
+message(STATUS "CACHED FILE_cache='$CACHE{FILE_cache}'")
+unset(FILE_cache CACHE)
+message(STATUS "FILE_cache='${FILE_cache}'")
diff --git a/Tests/RunCMake/find_file/RunCMakeTest.cmake b/Tests/RunCMake/find_file/RunCMakeTest.cmake
index 93dfb78..95f55a5 100644
--- a/Tests/RunCMake/find_file/RunCMakeTest.cmake
+++ b/Tests/RunCMake/find_file/RunCMakeTest.cmake
@@ -4,3 +4,4 @@ run_cmake(FromPATHEnv)
run_cmake(FromPrefixPath)
run_cmake(PrefixInPATH)
run_cmake(Required)
+run_cmake(NO_CACHE)
diff --git a/Tests/RunCMake/find_library/NO_CACHE-stdout.txt b/Tests/RunCMake/find_library/NO_CACHE-stdout.txt
new file mode 100644
index 0000000..1b4c2a9
--- /dev/null
+++ b/Tests/RunCMake/find_library/NO_CACHE-stdout.txt
@@ -0,0 +1,18 @@
+-- LIB_exists='.+/Tests/RunCMake/find_library/lib/libPrefixInPATH.a'
+-- LIB_doNotExists='LIB_doNotExists-NOTFOUND'
+--[ ]+
+-- Policy CMP0125 = OLD
+-- CACHED LIB_cache='unknown'
+-- LIB_cache='unknown'
+-- CACHED LIB_cache='libPrefixInPATH.a'
+-- LIB_cache='libPrefixInPATH.a'
+-- CACHED LIB_cache='libPrefixInPATH.a'
+-- LIB_cache='libPrefixInPATH.a'
+--[ ]+
+-- Policy CMP0125 = NEW
+-- CACHED LIB_cache='unknown'
+-- LIB_cache='unknown'
+-- CACHED LIB_cache='libPrefixInPATH.a'
+-- LIB_cache='libPrefixInPATH.a'
+-- CACHED LIB_cache='libPrefixInPATH.a'
+-- LIB_cache='.+/Tests/RunCMake/find_library/NO_CACHE-build/libPrefixInPATH.a'
diff --git a/Tests/RunCMake/find_library/NO_CACHE.cmake b/Tests/RunCMake/find_library/NO_CACHE.cmake
new file mode 100644
index 0000000..a94b828
--- /dev/null
+++ b/Tests/RunCMake/find_library/NO_CACHE.cmake
@@ -0,0 +1,133 @@
+list(APPEND CMAKE_FIND_LIBRARY_PREFIXES lib)
+list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .a)
+
+find_library(LIB_exists
+ NAMES PrefixInPATH
+ PATHS ${CMAKE_CURRENT_SOURCE_DIR}/lib
+ NO_CACHE
+ NO_DEFAULT_PATH
+ )
+if (DEFINED CACHE{LIB_exists})
+ message(SEND_ERROR "Cache variable defined: LIB_exists")
+endif()
+message(STATUS "LIB_exists='${LIB_exists}'")
+
+
+find_library(LIB_doNotExists
+ NAMES doNotExists
+ NO_CACHE
+ )
+if (DEFINED CACHE{LIB_doNotExists})
+ message(SEND_ERROR "Cache variable defined: LIB_doNotExists")
+endif()
+message(STATUS "LIB_doNotExists='${LIB_doNotExists}'")
+
+
+cmake_policy(SET CMP0125 OLD)
+message(STATUS "")
+message(STATUS "Policy CMP0125 = OLD")
+file(REMOVE "${CMAKE_BINARY_DIR}/libPrefixInPATH.a")
+
+set(LIB_cache "unknown" CACHE FILEPATH "")
+find_library(LIB_cache
+ NAMES PrefixInPATH
+ PATHS ${CMAKE_CURRENT_SOURCE_DIR}/lib
+ NO_CACHE
+ NO_DEFAULT_PATH
+ )
+if (NOT DEFINED CACHE{LIB_cache})
+ message(SEND_ERROR "Cache variable not defined: LIB_cache")
+endif()
+message(STATUS "CACHED LIB_cache='$CACHE{LIB_cache}'")
+unset(LIB_cache CACHE)
+message(STATUS "LIB_cache='${LIB_cache}'")
+
+
+set(LIB_cache "libPrefixInPATH.a" CACHE FILEPATH "")
+unset(LIB_cache)
+find_library(LIB_cache
+ NAMES PrefixInPATH
+ PATHS ${CMAKE_CURRENT_SOURCE_DIR}/lib
+ NO_CACHE
+ NO_DEFAULT_PATH
+ )
+if (NOT DEFINED CACHE{LIB_cache})
+ message(SEND_ERROR "Cache variable not defined: LIB_cache")
+endif()
+message(STATUS "CACHED LIB_cache='$CACHE{LIB_cache}'")
+unset(LIB_cache CACHE)
+message(STATUS "LIB_cache='${LIB_cache}'")
+
+
+set(LIB_cache "libPrefixInPATH.a" CACHE FILEPATH "")
+unset(LIB_cache)
+# simulate cache variable defined in command line
+file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/lib/libPrefixInPATH.a" DESTINATION "${CMAKE_BINARY_DIR}")
+set_property(CACHE LIB_cache PROPERTY TYPE UNINITIALIZED)
+find_library(LIB_cache
+ NAMES PrefixInPATH
+ PATHS ${CMAKE_CURRENT_SOURCE_DIR}/lib
+ NO_CACHE
+ NO_DEFAULT_PATH
+ )
+if (NOT DEFINED CACHE{LIB_cache})
+ message(SEND_ERROR "Cache variable not defined: LIB_cache")
+endif()
+message(STATUS "CACHED LIB_cache='$CACHE{LIB_cache}'")
+unset(LIB_cache CACHE)
+message(STATUS "LIB_cache='${LIB_cache}'")
+
+
+cmake_policy(SET CMP0125 NEW)
+message(STATUS "")
+message(STATUS "Policy CMP0125 = NEW")
+file(REMOVE "${CMAKE_BINARY_DIR}/libPrefixInPATH.a")
+
+set(LIB_cache "unknown" CACHE FILEPATH "")
+find_library(LIB_cache
+ NAMES PrefixInPATH
+ PATHS ${CMAKE_CURRENT_SOURCE_DIR}/lib
+ NO_CACHE
+ NO_DEFAULT_PATH
+ )
+if (NOT DEFINED CACHE{LIB_cache})
+ message(SEND_ERROR "Cache variable not defined: LIB_cache")
+endif()
+message(STATUS "CACHED LIB_cache='$CACHE{LIB_cache}'")
+unset(LIB_cache CACHE)
+message(STATUS "LIB_cache='${LIB_cache}'")
+
+
+set(LIB_cache "libPrefixInPATH.a" CACHE FILEPATH "")
+unset(LIB_cache)
+find_library(LIB_cache
+ NAMES PrefixInPATH
+ PATHS ${CMAKE_CURRENT_SOURCE_DIR}/lib
+ NO_CACHE
+ NO_DEFAULT_PATH
+ )
+if (NOT DEFINED CACHE{LIB_cache})
+ message(SEND_ERROR "Cache variable not defined: LIB_cache")
+endif()
+message(STATUS "CACHED LIB_cache='$CACHE{LIB_cache}'")
+unset(LIB_cache CACHE)
+message(STATUS "LIB_cache='${LIB_cache}'")
+
+
+set(LIB_cache "libPrefixInPATH.a" CACHE FILEPATH "")
+unset(LIB_cache)
+# simulate cache variable defined in command line
+file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/lib/libPrefixInPATH.a" DESTINATION "${CMAKE_BINARY_DIR}")
+set_property(CACHE LIB_cache PROPERTY TYPE UNINITIALIZED)
+find_library(LIB_cache
+ NAMES PrefixInPATH
+ PATHS ${CMAKE_CURRENT_SOURCE_DIR}/lib
+ NO_CACHE
+ NO_DEFAULT_PATH
+ )
+if (NOT DEFINED CACHE{LIB_cache})
+ message(SEND_ERROR "Cache variable not defined: LIB_cache")
+endif()
+message(STATUS "CACHED LIB_cache='$CACHE{LIB_cache}'")
+unset(LIB_cache CACHE)
+message(STATUS "LIB_cache='${LIB_cache}'")
diff --git a/Tests/RunCMake/find_library/RunCMakeTest.cmake b/Tests/RunCMake/find_library/RunCMakeTest.cmake
index c7d69e4..e297173 100644
--- a/Tests/RunCMake/find_library/RunCMakeTest.cmake
+++ b/Tests/RunCMake/find_library/RunCMakeTest.cmake
@@ -9,3 +9,4 @@ if(UNIX AND NOT CYGWIN)
endif()
run_cmake(PrefixInPATH)
run_cmake(Required)
+run_cmake(NO_CACHE)
diff --git a/Tests/RunCMake/find_path/NO_CACHE-stdout.txt b/Tests/RunCMake/find_path/NO_CACHE-stdout.txt
new file mode 100644
index 0000000..a41454e
--- /dev/null
+++ b/Tests/RunCMake/find_path/NO_CACHE-stdout.txt
@@ -0,0 +1,18 @@
+-- PATH_exists='.+/Tests/RunCMake/find_path/include/'
+-- PATH_exists='PATH_doNotExists-NOTFOUND'
+--[ ]+
+-- Policy CMP0125 = OLD
+-- CACHED PATH_cache='unknown'
+-- PATH_cache='unknown'
+-- CACHED PATH_cache='include'
+-- PATH_cache='include'
+-- CACHED PATH_cache='include'
+-- PATH_cache='include'
+--[ ]+
+-- Policy CMP0125 = NEW
+-- CACHED PATH_cache='unknown'
+-- PATH_cache='unknown'
+-- CACHED PATH_cache='include'
+-- PATH_cache='include'
+-- CACHED PATH_cache='include'
+-- PATH_cache='.+/Tests/RunCMake/find_path/NO_CACHE-build/include'
diff --git a/Tests/RunCMake/find_path/NO_CACHE.cmake b/Tests/RunCMake/find_path/NO_CACHE.cmake
new file mode 100644
index 0000000..4779ac8
--- /dev/null
+++ b/Tests/RunCMake/find_path/NO_CACHE.cmake
@@ -0,0 +1,131 @@
+find_path(PATH_exists
+ NAMES PrefixInPATH.h
+ PATHS ${CMAKE_CURRENT_SOURCE_DIR}/include
+ NO_CACHE
+ NO_DEFAULT_PATH
+ )
+if (DEFINED CACHE{PATH_exists})
+ message(SEND_ERROR "Cache variable defined: PATH_exists")
+endif()
+message(STATUS "PATH_exists='${PATH_exists}'")
+
+
+find_path(PATH_doNotExists
+ NAMES doNotExists.h
+ NO_CACHE
+ )
+if (DEFINED CACHE{PATH_doNotExists})
+ message(SEND_ERROR "Cache variable defined: PATH_doNotExists")
+endif()
+message(STATUS "PATH_exists='${PATH_doNotExists}'")
+
+
+cmake_policy(SET CMP0125 OLD)
+message(STATUS "")
+message(STATUS "Policy CMP0125 = OLD")
+file(REMOVE "${CMAKE_BINARY_DIR}/PrefixInPATH.h")
+
+set(PATH_cache "unknown" CACHE PATH "")
+find_path(PATH_cache
+ NAMES PrefixInPATH.h
+ PATHS ${CMAKE_CURRENT_SOURCE_DIR}/include
+ NO_CACHE
+ NO_DEFAULT_PATH
+ )
+if (NOT DEFINED CACHE{PATH_cache})
+ message(SEND_ERROR "Cache variable defined: PATH_cache")
+endif()
+message(STATUS "CACHED PATH_cache='$CACHE{PATH_cache}'")
+unset(PATH_cache CACHE)
+message(STATUS "PATH_cache='${PATH_cache}'")
+
+
+set(PATH_cache "include" CACHE PATH "")
+unset(PATH_cache)
+find_path(PATH_cache
+ NAMES PrefixInPATH.h
+ PATHS ${CMAKE_CURRENT_SOURCE_DIR}/include
+ NO_CACHE
+ NO_DEFAULT_PATH
+ )
+if (NOT DEFINED CACHE{PATH_cache})
+ message(SEND_ERROR "Cache variable defined: PATH_cache")
+endif()
+message(STATUS "CACHED PATH_cache='$CACHE{PATH_cache}'")
+unset(PATH_cache CACHE)
+message(STATUS "PATH_cache='${PATH_cache}'")
+
+
+set(PATH_cache "include" CACHE PATH "")
+unset(PATH_cache)
+# simulate cache variable defined in command line
+file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/include")
+file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/include/PrefixInPATH.h" DESTINATION "${CMAKE_BINARY_DIR}/include")
+set_property(CACHE PATH_cache PROPERTY TYPE UNINITIALIZED)
+find_path(PATH_cache
+ NAMES PrefixInPATH.h
+ NO_CACHE
+ NO_DEFAULT_PATH
+ )
+if (NOT DEFINED CACHE{PATH_cache})
+ message(SEND_ERROR "Cache variable not defined: PATH_cache")
+endif()
+message(STATUS "CACHED PATH_cache='$CACHE{PATH_cache}'")
+unset(PATH_cache CACHE)
+message(STATUS "PATH_cache='${PATH_cache}'")
+
+
+cmake_policy(SET CMP0125 NEW)
+message(STATUS "")
+message(STATUS "Policy CMP0125 = NEW")
+file(REMOVE_RECURSE "${CMAKE_BINARY_DIR}/include")
+
+set(PATH_cache "unknown" CACHE PATH "")
+unset(PATH_cache)
+find_path(PATH_cache
+ NAMES PrefixInPATH.h
+ PATHS ${CMAKE_CURRENT_SOURCE_DIR}/include
+ NO_CACHE
+ NO_DEFAULT_PATH
+ )
+if (NOT DEFINED CACHE{PATH_cache})
+ message(SEND_ERROR "Cache variable defined: PATH_cache")
+endif()
+message(STATUS "CACHED PATH_cache='$CACHE{PATH_cache}'")
+unset(PATH_cache CACHE)
+message(STATUS "PATH_cache='${PATH_cache}'")
+
+
+set(PATH_cache "include" CACHE PATH "")
+unset(PATH_cache)
+find_path(PATH_cache
+ NAMES PrefixInPATH.h
+ PATHS ${CMAKE_CURRENT_SOURCE_DIR}/include
+ NO_CACHE
+ NO_DEFAULT_PATH
+ )
+if (NOT DEFINED CACHE{PATH_cache})
+ message(SEND_ERROR "Cache variable defined: PATH_cache")
+endif()
+message(STATUS "CACHED PATH_cache='$CACHE{PATH_cache}'")
+unset(PATH_cache CACHE)
+message(STATUS "PATH_cache='${PATH_cache}'")
+
+
+set(PATH_cache "include" CACHE PATH "")
+unset(PATH_cache)
+# simulate cache variable defined in command line
+file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/include")
+file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/include/PrefixInPATH.h" DESTINATION "${CMAKE_BINARY_DIR}/include")
+set_property(CACHE PATH_cache PROPERTY TYPE UNINITIALIZED)
+find_path(PATH_cache
+ NAMES PrefixInPATH.h
+ NO_CACHE
+ NO_DEFAULT_PATH
+ )
+if (NOT DEFINED CACHE{PATH_cache})
+ message(SEND_ERROR "Cache variable not defined: PATH_cache")
+endif()
+message(STATUS "CACHED PATH_cache='$CACHE{PATH_cache}'")
+unset(PATH_cache CACHE)
+message(STATUS "PATH_cache='${PATH_cache}'")
diff --git a/Tests/RunCMake/find_path/RunCMakeTest.cmake b/Tests/RunCMake/find_path/RunCMakeTest.cmake
index 5c919bb..90ee768 100644
--- a/Tests/RunCMake/find_path/RunCMakeTest.cmake
+++ b/Tests/RunCMake/find_path/RunCMakeTest.cmake
@@ -4,6 +4,7 @@ run_cmake(EmptyOldStyle)
run_cmake(FromPATHEnv)
run_cmake(PrefixInPATH)
run_cmake(Required)
+run_cmake(NO_CACHE)
if(APPLE)
run_cmake(FrameworksWithSubdirs)
diff --git a/Tests/RunCMake/find_program/NO_CACHE-stdout.txt b/Tests/RunCMake/find_program/NO_CACHE-stdout.txt
new file mode 100644
index 0000000..c235d81
--- /dev/null
+++ b/Tests/RunCMake/find_program/NO_CACHE-stdout.txt
@@ -0,0 +1,18 @@
+-- PROG_A='.+/Tests/RunCMake/find_program/A/testA'
+-- PROG_AandB='PROG_AandB-NOTFOUND'
+--[ ]+
+-- Policy CMP0125 = OLD
+-- CACHED PROG_cache='unknown'
+-- PROG_cache='unknown'
+-- CACHED PROG_cache='testA'
+-- PROG_cache='testA'
+-- CACHED PROG_cache='testA'
+-- PROG_cache='testA'
+--[ ]+
+-- Policy CMP0125 = NEW
+-- CACHED PROG_cache='unknown'
+-- PROG_cache='unknown'
+-- CACHED PROG_cache='testA'
+-- PROG_cache='testA'
+-- CACHED PROG_cache='testA'
+-- PROG_cache='.+/Tests/RunCMake/find_program/NO_CACHE-build/testA'
diff --git a/Tests/RunCMake/find_program/NO_CACHE.cmake b/Tests/RunCMake/find_program/NO_CACHE.cmake
new file mode 100644
index 0000000..77a0582
--- /dev/null
+++ b/Tests/RunCMake/find_program/NO_CACHE.cmake
@@ -0,0 +1,130 @@
+find_program(PROG_A
+ NAMES testA
+ PATHS ${CMAKE_CURRENT_SOURCE_DIR}/A
+ NO_CACHE
+ NO_DEFAULT_PATH
+ )
+if (DEFINED CACHE{PROG_A})
+ message(SEND_ERROR "Cache variable defined: PROG_A")
+endif()
+message(STATUS "PROG_A='${PROG_A}'")
+
+
+find_program(PROG_AandB
+ NAMES testAandB
+ NO_CACHE
+ )
+if (DEFINED CACHE{PROG_AandB})
+ message(SEND_ERROR "Cache variable defined: PROG_AandN")
+endif()
+message(STATUS "PROG_AandB='${PROG_AandB}'")
+
+
+cmake_policy(SET CMP0125 OLD)
+message(STATUS "")
+message(STATUS "Policy CMP0125 = OLD")
+file(REMOVE "${CMAKE_BINARY_DIR}/testA")
+
+set(PROG_cache "unknown" CACHE FILEPATH "")
+find_program(PROG_cache
+ NAMES testA
+ PATHS ${CMAKE_CURRENT_SOURCE_DIR}/A
+ NO_CACHE
+ NO_DEFAULT_PATH
+ )
+if (NOT DEFINED CACHE{PROG_cache})
+ message(SEND_ERROR "Cache variable not defined: PROG_cache")
+endif()
+message(STATUS "CACHED PROG_cache='$CACHE{PROG_cache}'")
+unset(PROG_cache CACHE)
+message(STATUS "PROG_cache='${PROG_cache}'")
+
+
+set(PROG_cache "testA" CACHE FILEPATH "")
+unset(PROG_cache)
+find_program(PROG_cache
+ NAMES testA
+ PATHS ${CMAKE_CURRENT_SOURCE_DIR}/A
+ NO_CACHE
+ NO_DEFAULT_PATH
+ )
+if (NOT DEFINED CACHE{PROG_cache})
+ message(SEND_ERROR "Cache variable not defined: PROG_cache")
+endif()
+message(STATUS "CACHED PROG_cache='$CACHE{PROG_cache}'")
+unset(PROG_cache CACHE)
+message(STATUS "PROG_cache='${PROG_cache}'")
+
+
+set(PROG_cache "testA" CACHE FILEPATH "")
+unset(PROG_cache)
+# simulate cache variable defined in command line
+file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/A/testA" DESTINATION "${CMAKE_BINARY_DIR}")
+set_property(CACHE PROG_cache PROPERTY TYPE UNINITIALIZED)
+find_program(PROG_cache
+ NAMES testA
+ PATHS ${CMAKE_CURRENT_SOURCE_DIR}/A
+ NO_CACHE
+ NO_DEFAULT_PATH
+ )
+if (NOT DEFINED CACHE{PROG_cache})
+ message(SEND_ERROR "Cache variable not defined: PROG_cache")
+endif()
+message(STATUS "CACHED PROG_cache='$CACHE{PROG_cache}'")
+unset(PROG_cache CACHE)
+message(STATUS "PROG_cache='${PROG_cache}'")
+
+
+cmake_policy(SET CMP0125 NEW)
+message(STATUS "")
+message(STATUS "Policy CMP0125 = NEW")
+file(REMOVE "${CMAKE_BINARY_DIR}/testA")
+
+set(PROG_cache "unknown" CACHE FILEPATH "")
+find_program(PROG_cache
+ NAMES testA
+ PATHS ${CMAKE_CURRENT_SOURCE_DIR}/A
+ NO_CACHE
+ NO_DEFAULT_PATH
+ )
+if (NOT DEFINED CACHE{PROG_cache})
+ message(SEND_ERROR "Cache variable not defined: PROG_cache")
+endif()
+message(STATUS "CACHED PROG_cache='$CACHE{PROG_cache}'")
+unset(PROG_cache CACHE)
+message(STATUS "PROG_cache='${PROG_cache}'")
+
+
+set(PROG_cache "testA" CACHE FILEPATH "")
+unset(PROG_cache)
+find_program(PROG_cache
+ NAMES testA
+ PATHS ${CMAKE_CURRENT_SOURCE_DIR}/A
+ NO_CACHE
+ NO_DEFAULT_PATH
+ )
+if (NOT DEFINED CACHE{PROG_cache})
+ message(SEND_ERROR "Cache variable not defined: PROG_cache")
+endif()
+message(STATUS "CACHED PROG_cache='$CACHE{PROG_cache}'")
+unset(PROG_cache CACHE)
+message(STATUS "PROG_cache='${PROG_cache}'")
+
+
+set(PROG_cache "testA" CACHE FILEPATH "")
+unset(PROG_cache)
+# simulate cache variable defined in command line
+file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/A/testA" DESTINATION "${CMAKE_BINARY_DIR}")
+set_property(CACHE PROG_cache PROPERTY TYPE UNINITIALIZED)
+find_program(PROG_cache
+ NAMES testA
+ PATHS ${CMAKE_CURRENT_SOURCE_DIR}/A
+ NO_CACHE
+ NO_DEFAULT_PATH
+ )
+if (NOT DEFINED CACHE{PROG_cache})
+ message(SEND_ERROR "Cache variable not defined: PROG_cache")
+endif()
+message(STATUS "CACHED PROG_cache='$CACHE{PROG_cache}'")
+unset(PROG_cache CACHE)
+message(STATUS "PROG_cache='${PROG_cache}'")
diff --git a/Tests/RunCMake/find_program/RunCMakeTest.cmake b/Tests/RunCMake/find_program/RunCMakeTest.cmake
index 77c021d..34edc19 100644
--- a/Tests/RunCMake/find_program/RunCMakeTest.cmake
+++ b/Tests/RunCMake/find_program/RunCMakeTest.cmake
@@ -5,6 +5,7 @@ run_cmake(DirsPerName)
run_cmake(NamesPerDir)
run_cmake(RelAndAbsPath)
run_cmake(Required)
+run_cmake(NO_CACHE)
if(CMAKE_SYSTEM_NAME MATCHES "^(Windows|CYGWIN|MSYS)$")
run_cmake(WindowsCom)