diff options
Diffstat (limited to 'Tests/RunCMake/find_path')
-rw-r--r-- | Tests/RunCMake/find_path/NO_CACHE-stdout.txt | 18 | ||||
-rw-r--r-- | Tests/RunCMake/find_path/NO_CACHE.cmake | 131 | ||||
-rw-r--r-- | Tests/RunCMake/find_path/RunCMakeTest.cmake | 1 |
3 files changed, 150 insertions, 0 deletions
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) |