summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/find_library/NO_CACHE.cmake
blob: a94b8284c7e1ede67c957fe7c7bbef32f073d818 (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
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}'")