summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/find_library/FromPATHEnv.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/RunCMake/find_library/FromPATHEnv.cmake')
-rw-r--r--Tests/RunCMake/find_library/FromPATHEnv.cmake22
1 files changed, 22 insertions, 0 deletions
diff --git a/Tests/RunCMake/find_library/FromPATHEnv.cmake b/Tests/RunCMake/find_library/FromPATHEnv.cmake
new file mode 100644
index 0000000..fec041d
--- /dev/null
+++ b/Tests/RunCMake/find_library/FromPATHEnv.cmake
@@ -0,0 +1,22 @@
+list(APPEND CMAKE_FIND_LIBRARY_PREFIXES lib)
+list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .a)
+set(ENV_PATH "$ENV{PATH}")
+file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/lib/libcreated.a" "created")
+
+foreach(path "/does_not_exist" "/lib" "")
+ unset(CREATED_LIBRARY CACHE)
+ set(ENV{PATH} "${CMAKE_CURRENT_BINARY_DIR}${path}")
+ find_library(CREATED_LIBRARY NAMES created)
+ message(STATUS "CREATED_LIBRARY='${CREATED_LIBRARY}'")
+endforeach()
+
+set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH OFF)
+foreach(path "/does_not_exist" "/lib" "")
+ unset(CREATED_LIBRARY CACHE)
+ set(ENV{PATH} "${CMAKE_CURRENT_BINARY_DIR}${path}")
+ find_library(CREATED_LIBRARY NAMES created)
+ message(STATUS "CREATED_LIBRARY='${CREATED_LIBRARY}'")
+endforeach()
+set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH ON)
+set(ENV{PATH} "${ENV_PATH}")