diff options
author | Brad King <brad.king@kitware.com> | 2021-06-03 12:10:58 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-06-03 12:11:04 (GMT) |
commit | 9c33ff4dda643f8a93d55f9895e31dce9056134f (patch) | |
tree | 0edad6fc79d8c3351a17ad118178a729d84fee4c /Tests/RunCMake/find_path/NO_CACHE.cmake | |
parent | e6bcd5e45a3ff81815ef8bfba86388da1d0b0255 (diff) | |
parent | 87b71eec6257b0d9c43b446205d61f334278fe7d (diff) | |
download | CMake-9c33ff4dda643f8a93d55f9895e31dce9056134f.zip CMake-9c33ff4dda643f8a93d55f9895e31dce9056134f.tar.gz CMake-9c33ff4dda643f8a93d55f9895e31dce9056134f.tar.bz2 |
Merge topic 'find_item-NO_CACHE'
87b71eec62 find_*: Add support for option NO_CACHE
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Ben Boeckel <ben.boeckel@kitware.com>
Merge-request: !6181
Diffstat (limited to 'Tests/RunCMake/find_path/NO_CACHE.cmake')
-rw-r--r-- | Tests/RunCMake/find_path/NO_CACHE.cmake | 131 |
1 files changed, 131 insertions, 0 deletions
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}'") |