summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/find_library/IgnoreInstallPrefix.cmake
blob: 7ca8bcf9d1a52d420cb91759d02002710a5a2b73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
set(ENV_PATH "$ENV{PATH}")
set(ENV_CMAKE_PREFIX_PATH "$ENV{CMAKE_PREFIX_PATH}")
set(ENV{PATH} "")
set(ENV{CMAKE_PREFIX_PATH} "")

list(APPEND CMAKE_FIND_LIBRARY_PREFIXES lib)
list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .a)

file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/lib/libcreated.a" "created")

set(CMAKE_FIND_DEBUG_MODE 1)
set(CMAKE_FIND_USE_INSTALL_PREFIX OFF)

find_library(CREATED_LIBRARY NAMES created)
message(STATUS "CREATED_LIBRARY='${CREATED_LIBRARY}'")

set(CMAKE_FIND_USE_INSTALL_PREFIX ON)
find_library(CREATED_LIBRARY NAMES created)
message(STATUS "CREATED_LIBRARY='${CREATED_LIBRARY}'")

unset(CREATED_LIBRARY)
unset(CREATED_LIBRARY CACHE)

unset(CMAKE_FIND_USE_INSTALL_PREFIX)
find_library(CREATED_LIBRARY NAMES created NO_CMAKE_INSTALL_PREFIX)
message(STATUS "CREATED_LIBRARY='${CREATED_LIBRARY}'")

set(CMAKE_FIND_DEBUG_MODE 0)

set(ENV{PATH} "${ENV_PATH}")
set(ENV{CMAKE_PREFIX_PATH} "${ENV_CMAKE_PREFIX_PATH}")