summaryrefslogtreecommitdiffstats
path: root/Tests/FindPackageTest/CMakeLists.txt
blob: a77713f27c8321fedb6034d976caf1f0f66675b5 (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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
cmake_minimum_required (VERSION 2.6)
project(FindPackageTest)

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})

# Look for a package which uses FindPackageHandleStandardArgs.cmake with the
# new (as of cmake 2.8.3) syntax. This works only if CMP0017 is set to NEW,
# because otherwise FindPackageHandleStandardArgs.cmake from the current
# directory is included (via CMAKE_MODULE_PATH).
cmake_policy(SET CMP0017 NEW)
find_package(ZLIB QUIET)

# Look for a package that has a find module and may be found.
find_package(OpenGL QUIET)

# Look for a package that has no find module and will not be found.
find_package(NotAPackage QUIET)

# Look for a package that has an advanced find module.
find_package(VTK QUIET)

add_executable(FindPackageTest FindPackageTest.cxx)

# test behaviour of cmFindBase wrt. the CMAKE_PREFIX_PATH variable
# foo.h should be found in ${CMAKE_CURRENT_SOURCE_DIR}/include:

set(CMAKE_PREFIX_PATH /blub /blah "${CMAKE_CURRENT_SOURCE_DIR}")
find_path(FOO_DIR foo.h)

if(NOT FOO_DIR)
  message(FATAL_ERROR "Did not find foo.h which is in ${CMAKE_CURRENT_SOURCE_DIR}/include
  CMAKE_PREFIX_PATH = ${CMAKE_PREFIX_PATH}")
endif()

find_package(VersionTestA 1)
find_package(VersionTestB 1.2)
find_package(VersionTestC 1.2.3)
find_package(VersionTestD 1.2.3.4)


find_package(LotsOfComponents COMPONENTS AComp OPTIONAL_COMPONENTS BComp CComp)
if(NOT LOTSOFCOMPONENTS_FOUND)
  message(SEND_ERROR "LotsOfComponents not found !")
endif()

find_package(SomePackage)
if(NOT SomePackage_FOUND)
  message(SEND_ERROR "SomePackage with FOUND_VAR SomePackage_FOUND not found !")
endif()

find_package(UpperCasePackage)
if(NOT UPPERCASEPACKAGE_FOUND)
  message(SEND_ERROR "UpperCasePackage with FOUND_VAR UPPERCASEPACKAGE_FOUND not found !")
endif()

#-----------------------------------------------------------------------------
# Test system package registry if possible.
set(CMakeTestSystemPackage "")
if(WIN32 AND NOT CYGWIN)
  # Try writing a value to the system package registry.
  set(_data "${FindPackageTest_SOURCE_DIR}/SystemPackage")
  set(_key "HKLM\\Software\\Kitware\\CMake\\Packages\\CMakeTestSystemPackage")
  set(_file "${FindPackageTest_BINARY_DIR}/CMakeTestSystemPackage.data")
  file(WRITE ${_file} "${_data}\n")
  execute_process(
    COMMAND ${CMAKE_COMMAND} -E md5sum ${_file}
    OUTPUT_VARIABLE _output ERROR_VARIABLE _error RESULT_VARIABLE _failed
    OUTPUT_STRIP_TRAILING_WHITESPACE
    )
  string(REGEX REPLACE " .*" "" _value "${_output}")
  if(NOT _failed AND _value)
    execute_process(
      COMMAND reg add "${_key}" /v "${_value}" /t REG_SZ /d "${_data}" /f
      OUTPUT_VARIABLE _output ERROR_VARIABLE _output RESULT_VARIABLE _failed
      )
  endif()
  # If the above worked, add the rest of the test and a rule to
  # cleanup the value.
  if(NOT _failed)
    message(STATUS "HKLM is writable: enabling CMakeTestSystemPackage")
    set(CMakeTestSystemPackage_CLEANUP reg delete "${_key}" /v "${_value}" /f)
    set(CMakeTestSystemPackage CMakeTestSystemPackage)
  else()
    message(STATUS "HKLM is readonly: disabling CMakeTestSystemPackage")
  endif()
endif()

#-----------------------------------------------------------------------------

#set(CMAKE_FIND_DEBUG_MODE 1)

# For purposes of the test wipe out previous find results.
set(PACKAGES
  foo Foo Bar Blub TFramework Tframework TApp Tapp Special
  VersionedA VersionedB VersionedC VersionedD VersionedE
  WrongA WrongB WrongC WrongD
  wibbleA wibbleB
  RecursiveA RecursiveB RecursiveC
  ArchA ArchB ArchC ArchD
  EnvA EnvB
  SetFoundTRUE SetFoundFALSE
  ${CMakeTestSystemPackage}
  )
foreach(p ${PACKAGES})
  set(${p}_DIR "" CACHE FILEPATH "Wipe out find results for testing." FORCE)
endforeach()

# Enable framework and bundle searching.  Make sure bundles are found
# before unix-syle packages.
set(CMAKE_FIND_FRAMEWORK LAST)
set(CMAKE_FIND_APPBUNDLE FIRST)

# Set the wrong answer for a find to make sure it re-finds.
set(VersionedA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/cmake/zot-4.0)

# Test that CMAKE_IGNORE_PATH can ignore the purposely bad package
# files in the lib/cmake/zot-3.1 directory.
set(CMAKE_IGNORE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/lib/cmake/zot-3.1)

# Look for packages with new-style signatures.
find_package(foo NO_MODULE)
find_package(Foo CONFIGS FooConfig.cmake)
find_package(Bar)
set(CMAKE_DISABLE_FIND_PACKAGE_Blub TRUE)
find_package(Blub NO_MODULE)
find_package(TFramework CONFIGS TFrameworkConfig.cmake)
find_package(Tframework)
find_package(TApp)
find_package(Tapp CONFIGS tapp-config.cmake)
find_package(Special NAMES Suffix SuffixTest PATH_SUFFIXES test)
find_package(VersionedA 2 NAMES zot)
find_package(VersionedB 3.1 EXACT NAMES zot)
find_package(VersionedC 4.0 EXACT NAMES zot)
find_package(VersionedD 1.1 EXACT NAMES Baz)
find_package(VersionedE 1.2 EXACT NAMES Baz)

# Test Config files which set Xyz_FOUND themselves:
find_package(SetFoundTRUE NO_MODULE)
find_package(SetFoundFALSE NO_MODULE)

# Test wrong initial path when result is present.
set(WrongA_DIR "${VersionedD_DIR}")
find_package(WrongA 1.2 EXACT NAMES Baz)

# Test wrong initial cache entry of UNINITIALIZED type when result is present.
set(WrongB_DIR "${VersionedD_DIR}" CACHE UNINITIALIZED "Wrong Value" FORCE)
get_property(type CACHE WrongB_DIR PROPERTY TYPE)
find_package(WrongB 1.2 EXACT NAMES Baz)

# Test wrong initial path when result is missing.
set(WrongC_DIR "${VersionedD_DIR}")
find_package(WrongC 1.3 EXACT QUIET NAMES Baz)

# Test wrong initial cache entry of UNINITIALIZED type when result is missing.
set(WrongD_DIR "${VersionedD_DIR}" CACHE UNINITIALIZED "Wrong Value" FORCE)
get_property(type CACHE WrongD_DIR PROPERTY TYPE)
find_package(WrongD 1.3 EXACT QUIET NAMES Baz)

# HINTS should override the system but PATHS should not
list(INSERT CMAKE_SYSTEM_PREFIX_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/A")
find_package(wibbleA NAMES wibble PATHS B)
find_package(wibbleB NAMES wibble HINTS B)

# Look for package with recursive find-modules.
find_package(RecursiveA COMPONENTS A)
find_package(RecursiveB 2)
find_package(RecursiveC 3.1 EXACT)

# Test architecture-specific search directories.
set(CMAKE_LIBRARY_ARCHITECTURE arch)
find_package(ArchA NAMES Bar)
find_package(ArchB NAMES Foo CONFIGS FooConfig.cmake)
find_package(ArchC 3.1 EXACT NAMES zot)
find_package(ArchD 4.0 EXACT NAMES zot)
unset(CMAKE_LIBRARY_ARCHITECTURE)

# Test <Package>_DIR environment variable.
# We erase the main prefix path to ensure the env var is used.
set(CMAKE_PREFIX_PATH)
set(ENV{EnvA_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/lib/zot-3.1")
find_package(EnvA 3.1 EXACT QUIET NAMES zot) # Should Work
find_package(EnvB 3.1 EXACT QUIET NAMES zot) # Should Fail

# Test system package registry if available.
if(CMakeTestSystemPackage)
  find_package(CMakeTestSystemPackage)
  execute_process(COMMAND ${CMakeTestSystemPackage_CLEANUP}
    OUTPUT_VARIABLE _output ERROR_VARIABLE _error)
endif()

# Expected locations at which packages should be found.
set(foo_EXPECTED "lib/foo-1.2/foo-config.cmake")
set(Foo_EXPECTED "lib/foo-1.2/CMake/FooConfig.cmake")
set(Bar_EXPECTED "lib/Bar/BarConfig.cmake")
set(Blub_MISSING "")
set(Special_EXPECTED "lib/suffix/test/SuffixTestConfig.cmake")
set(TFramework_EXPECTED
  "TFramework.framework/Versions/A/Resources/CMake/TFrameworkConfig.cmake")
set(Tframework_EXPECTED
  "TFramework.framework/Versions/A/Resources/tframework-config.cmake")
set(TApp_EXPECTED
  "TApp.app/Contents/Resources/TAppConfig.cmake")
set(Tapp_EXPECTED
  "TApp.app/Contents/Resources/cmake/tapp-config.cmake")
set(VersionedA_EXPECTED "lib/zot-2.0/zot-config.cmake")
set(VersionedB_EXPECTED "lib/zot-3.1/zot-config.cmake")
set(VersionedC_EXPECTED "lib/cmake/zot-4.0/zot-config.cmake")
set(VersionedD_EXPECTED "Baz 1.1/BazConfig.cmake")
set(VersionedE_EXPECTED "Baz 1.2/CMake/BazConfig.cmake")
set(WrongA_EXPECTED "${VersionedE_EXPECTED}")
set(WrongB_EXPECTED "${VersionedE_EXPECTED}")
set(WrongC_MISSING "WrongC_DIR-NOTFOUND")
set(WrongD_MISSING "WrongD_DIR-NOTFOUND")
set(wibbleA_EXPECTED "A/wibble-config.cmake")
set(wibbleB_EXPECTED "B/wibble-config.cmake")
set(RecursiveA_EXPECTED "lib/RecursiveA/recursivea-config.cmake")
set(RecursiveB_EXPECTED "lib/zot-2.0/zot-config.cmake")
set(RecursiveC_EXPECTED "lib/zot-3.1/zot-config.cmake")
set(ArchA_EXPECTED "lib/arch/Bar/BarConfig.cmake")
set(ArchB_EXPECTED "lib/arch/foo-1.2/CMake/FooConfig.cmake")
set(ArchC_EXPECTED "lib/arch/zot-3.1/zot-config.cmake")
set(ArchD_EXPECTED "lib/arch/cmake/zot-4.0/zot-config.cmake")
set(EnvA_EXPECTED "lib/zot-3.1/zot-config.cmake")
set(EnvB_MISSING "EnvB_DIR-NOTFOUND")
set(SetFoundTRUE_EXPECTED "cmake/SetFoundTRUEConfig.cmake")
set(SetFoundFALSE_MISSING "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(CMakeTestSystemPackage_EXPECTED "SystemPackage/CMakeTestSystemPackageConfig.cmake")

# Check the results.
foreach(p ${PACKAGES})
  if(DEFINED ${p}_MISSING)
    # Check and report failure.
    if(NOT "${${p}_DIR}" STREQUAL "${${p}_MISSING}")
      message(SEND_ERROR
        "Package ${p} should have been [${${p}_MISSING}] but "
        "was [${${p}_DIR}]")
    endif()
    if(${p}_FOUND)
      message(SEND_ERROR
        "Package ${p} should not have been found, but ${p}_FOUND is set to "
        "\"${${p}_FOUND}\"")
    endif()
  elseif(${p}_FOUND)
    # Convert to relative path for comparison to expected location.
    file(RELATIVE_PATH REL_${p}_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}"
      "${${p}_CONFIG}")

    # Debugging output.
    if(CMAKE_FIND_DEBUG_MODE)
      message("Package ${p} found [${REL_${p}_CONFIG}]")
    endif()

    # Check and report failure.
    if(NOT "${REL_${p}_CONFIG}" STREQUAL "${${p}_EXPECTED}")
      message(SEND_ERROR
        "Package ${p} should have been [${${p}_EXPECTED}] but "
        "was [${REL_${p}_CONFIG}]")
    endif()
  else()
    message(SEND_ERROR "Package ${p} not found!")
  endif()
endforeach()

# Check that version information was extracted.
if(NOT "${VersionedA_VERSION}" STREQUAL "2.0")
  message(SEND_ERROR
    "Package VersionedA is version [${VersionedA_VERSION}], not [2.0]")
endif()
if(NOT "${VersionedA_VERSION_MAJOR}" STREQUAL "2")
  message(SEND_ERROR
    "Package VersionedA is major version [${VersionedA_VERSION_MAJOR}], not [2]")
endif()
if(NOT "${VersionedA_VERSION_MINOR}" STREQUAL "0")
  message(SEND_ERROR
    "Package VersionedA is minor version [${VersionedA_VERSION_MINOR}], not [0]")
endif()

if(NOT "${VersionedB_VERSION}" STREQUAL "3.1")
  message(SEND_ERROR
    "Package VersionedB is version [${VersionedB_VERSION}], not [3.1]")
endif()
if(NOT "${VersionedB_VERSION_MAJOR}" STREQUAL "3")
  message(SEND_ERROR
    "Package VersionedB is major version [${VersionedB_VERSION_MAJOR}], not [3]")
endif()
if(NOT "${VersionedB_VERSION_MINOR}" STREQUAL "1")
  message(SEND_ERROR
    "Package VersionedB is minor version [${VersionedB_VERSION_MINOR}], not [1]")
endif()

if(NOT "${Special_VERSION}" STREQUAL "1.2")
  message(SEND_ERROR
    "Package Special is version [${Special_VERSION}], not [1.2]")
endif()
if(NOT "${Special_VERSION_MAJOR}" STREQUAL "1")
  message(SEND_ERROR
    "Package Special is major version [${Special_VERSION_MAJOR}], not [1]")
endif()
if(NOT "${Special_VERSION_MINOR}" STREQUAL "2")
  message(SEND_ERROR
    "Package Special is minor version [${Special_VERSION_MINOR}], not [2]")
endif()

# Test version number comparison.
if(NOT "1.2.3.4" VERSION_LESS "1.2.3.5")
  message(SEND_ERROR "1.2.3.4 VERSION_LESS 1.2.3.5 is not true!")
endif()
if(NOT "1.2" VERSION_LESS "1.10")
  message(SEND_ERROR "1.2 VERSION_LESS 1.10 is not true!")
endif()
if(NOT "1.02" VERSION_GREATER "1.1")
  message(SEND_ERROR "1.02 VERSION_GREATER 1.1 is not true!")
endif()
if("1.2.3" VERSION_GREATER "1.2.3.4")
  message(SEND_ERROR "1.2.3 VERSION_GREATER 1.2.3.4 is not false!")
endif()
if(NOT "1.2" VERSION_EQUAL "1.2.0.0")
  message(SEND_ERROR "1.2 VERSION_EQUAL 1.2.0.0 is not true!")
endif()

#-----------------------------------------------------------------------------
# Test export(PACKAGE) with find_package.
message(STATUS "Preparing export(PACKAGE) test project")
try_compile(EXPORTER_COMPILED
  ${FindPackageTest_BINARY_DIR}/Exporter
  ${FindPackageTest_SOURCE_DIR}/Exporter
  CMakeTestExportPackage dummy
  OUTPUT_VARIABLE output)
message(STATUS "Searching for export(PACKAGE) test project")
set(CMakeTestExportPackage_DIR "" CACHE FILEPATH
  "Wipe out find results for testing." FORCE)
string(REGEX REPLACE "-.*$" "" version ${CMAKE_VERSION})
find_package(CMakeTestExportPackage 1.${version} EXACT REQUIRED)

#-----------------------------------------------------------------------------
# Test configure_package_config_file().

include(CMakePackageConfigHelpers)

set(INCLUDE_INSTALL_DIR include )
set(SHARE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/" )
set(CURRENT_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}" )

configure_package_config_file(RelocatableConfig.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/RelocatableConfig.cmake"
                              INSTALL_DESTINATION "${CMAKE_INSTALL_PREFIX}"
                              PATH_VARS INCLUDE_INSTALL_DIR SHARE_INSTALL_DIR CURRENT_BUILD_DIR
                             )

set(Relocatable_FIND_COMPONENTS AComp BComp CComp)
set(Relocatable_FIND_REQUIRED_BComp 1)
include("${CMAKE_CURRENT_BINARY_DIR}/RelocatableConfig.cmake")

if(NOT "${RELOC_INCLUDE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/include")
  message(SEND_ERROR "RELOC_INCLUDE_DIR set by configure_package_config_file() is set to \"${RELOC_INCLUDE_DIR}\" (expected \"${CMAKE_CURRENT_BINARY_DIR}/include\")")
endif()

if(NOT "${RELOC_SHARE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/share/")
  message(SEND_ERROR "RELOC_SHARE_DIR set by configure_package_config_file() is set to \"${RELOC_SHARE_DIR}\" (expected \"${CMAKE_CURRENT_BINARY_DIR}/share/\")")
endif()

if(NOT "${RELOC_BUILD_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
  message(SEND_ERROR "RELOC_BUILD_DIR set by configure_package_config_file() is set to \"${RELOC_BUILD_DIR}\" (expected \"${CMAKE_CURRENT_BINARY_DIR}\")")
endif()

if(NOT DEFINED Relocatable_FOUND)
  message(SEND_ERROR "Relocatable_FOUND not defined !")
endif()

if(Relocatable_FOUND)
  message(SEND_ERROR "Relocatable_FOUND set to TRUE !")
endif()

#-----------------------------------------------------------------------------
# Test write_basic_config_version_file().

# also test that an empty CMAKE_SIZEOF_VOID_P is accepted:
set(_CMAKE_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P})
set(CMAKE_SIZEOF_VOID_P "")

write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/Foo123ConfigVersion.cmake
                                 VERSION 1.2.3
                                 COMPATIBILITY AnyNewerVersion)

set(CMAKE_SIZEOF_VOID_P ${_CMAKE_SIZEOF_VOID_P})

set(PACKAGE_FIND_VERSION 2.3.4)
include(${CMAKE_CURRENT_BINARY_DIR}/Foo123ConfigVersion.cmake)
if(PACKAGE_VERSION_COMPATIBLE)
  message(SEND_ERROR "Found Foo123 with version 1.2.3, but 2.3.4 was requested !")
endif()

set(PACKAGE_FIND_VERSION 0.0.1)
include(${CMAKE_CURRENT_BINARY_DIR}/Foo123ConfigVersion.cmake)
if(NOT PACKAGE_VERSION_COMPATIBLE)
  message(SEND_ERROR "Did not find Foo123 with version 1.2.3 (0.0.1 was requested) !")
endif()

if(PACKAGE_VERSION_UNSUITABLE)
  message(SEND_ERROR "PACKAGE_VERSION_UNSUITABLE set, but must not be !")
endif()

set(PACKAGE_FIND_VERSION 1.0.0)
include(${CMAKE_CURRENT_BINARY_DIR}/Foo123ConfigVersion.cmake)
if(NOT PACKAGE_VERSION_COMPATIBLE)
  message(SEND_ERROR "Did not find Foo123 with version 1.2.3 (1.0.0 was requested) !")
endif()
if(PACKAGE_VERSION_EXACT)
  message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !")
endif()

set(PACKAGE_FIND_VERSION 1.2.3)
include(${CMAKE_CURRENT_BINARY_DIR}/Foo123ConfigVersion.cmake)
if(NOT PACKAGE_VERSION_COMPATIBLE)
  message(SEND_ERROR "Did not find Foo123 with version 1.2.3 (1.2.3 was requested) !")
endif()
if(NOT PACKAGE_VERSION_EXACT)
  message(SEND_ERROR "PACKAGE_VERSION_EXACT not set, although it should be !")
endif()


#######################
include(WriteBasicConfigVersionFile)

write_basic_config_version_file(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.cmake
                                VERSION 1.2.3
                                COMPATIBILITY SameMajorVersion)

unset(PACKAGE_VERSION_UNSUITABLE)
set(PACKAGE_VERSION_EXACT FALSE)
set(PACKAGE_FIND_VERSION 2.3.4)
set(PACKAGE_FIND_VERSION_MAJOR 2)
include(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.cmake)
if(PACKAGE_VERSION_COMPATIBLE)
  message(SEND_ERROR "Found Boo123 with version 1.2.3, but 2.3.4 was requested !")
endif()
if(PACKAGE_VERSION_EXACT)
  message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !")
endif()

set(PACKAGE_FIND_VERSION 0.0.1)
set(PACKAGE_FIND_VERSION_MAJOR 0)
include(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.cmake)
if(PACKAGE_VERSION_COMPATIBLE)
  message(SEND_ERROR "Found Boo123 with version 1.2.3, but 0.0.1 was requested !")
endif()
if(PACKAGE_VERSION_EXACT)
  message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !")
endif()

set(PACKAGE_FIND_VERSION 1.0.0)
set(PACKAGE_FIND_VERSION_MAJOR 1)
include(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.cmake)
if(NOT PACKAGE_VERSION_COMPATIBLE)
  message(SEND_ERROR "Did not find Boo123 with version 1.2.3 (1.0.0 was requested) !")
endif()
if(PACKAGE_VERSION_EXACT)
  message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !")
endif()

set(PACKAGE_FIND_VERSION 1.2.3)
set(PACKAGE_FIND_VERSION_MAJOR 1)
include(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.cmake)
if(NOT PACKAGE_VERSION_COMPATIBLE)
  message(SEND_ERROR "Did not find Boo123 with version 1.2.3 (1.2.3 was requested) !")
endif()
if(NOT PACKAGE_VERSION_EXACT)
  message(SEND_ERROR "PACKAGE_VERSION_EXACT not set, although it should be !")
endif()

if(PACKAGE_VERSION_UNSUITABLE)
  message(SEND_ERROR "PACKAGE_VERSION_UNSUITABLE set, but must not be !")
endif()

#######################

write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/Bar123ConfigVersion.cmake
                                 VERSION 1.2.3.17
                                 COMPATIBILITY ExactVersion)

unset(PACKAGE_VERSION_UNSUITABLE)
set(PACKAGE_VERSION_EXACT FALSE)
set(PACKAGE_FIND_VERSION 2.3.4)
include(${CMAKE_CURRENT_BINARY_DIR}/Bar123ConfigVersion.cmake)
if(PACKAGE_VERSION_COMPATIBLE)
  message(SEND_ERROR "Found Bar123 with version 1.2.3 (2.3.4 was requested) !")
endif()
if(PACKAGE_VERSION_EXACT)
  message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !")
endif()

set(PACKAGE_FIND_VERSION 1.2)
include(${CMAKE_CURRENT_BINARY_DIR}/Bar123ConfigVersion.cmake)
if(PACKAGE_VERSION_COMPATIBLE)
  message(SEND_ERROR "Found Bar123 with version 1.2.3 (1.2 was requested) !")
endif()
if(PACKAGE_VERSION_EXACT)
  message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !")
endif()

set(PACKAGE_FIND_VERSION 1)
include(${CMAKE_CURRENT_BINARY_DIR}/Bar123ConfigVersion.cmake)
if(PACKAGE_VERSION_COMPATIBLE)
  message(SEND_ERROR "Found Bar123 with version 1.2.3 (1 was requested) !")
endif()
if(PACKAGE_VERSION_EXACT)
  message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !")
endif()

set(PACKAGE_FIND_VERSION 1.2.3.4)
include(${CMAKE_CURRENT_BINARY_DIR}/Bar123ConfigVersion.cmake)
if(NOT PACKAGE_VERSION_COMPATIBLE)
  message(SEND_ERROR "Did not find Bar123 with version 1.2.3 (1.2.3.4 was requested) !")
endif()
if(PACKAGE_VERSION_EXACT)
  message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !")
endif()

set(PACKAGE_FIND_VERSION 1.2.3)
set(PACKAGE_VERSION_EXACT FALSE)
set(PACKAGE_VERSION_COMPATIBLE FALSE)
include(${CMAKE_CURRENT_BINARY_DIR}/Bar123ConfigVersion.cmake)
if(NOT PACKAGE_VERSION_COMPATIBLE)
  message(SEND_ERROR "Did not find Bar123 with version 1.2.3 (1.2.3 was requested) !")
endif()
if(PACKAGE_VERSION_EXACT)
  message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !")
endif()


set(PACKAGE_FIND_VERSION 1.2.3.17)
set(PACKAGE_VERSION_EXACT FALSE)
set(PACKAGE_VERSION_COMPATIBLE FALSE)
include(${CMAKE_CURRENT_BINARY_DIR}/Bar123ConfigVersion.cmake)
if(NOT PACKAGE_VERSION_COMPATIBLE)
  message(SEND_ERROR "Did not find Bar123 with version 1.2.3 (1.2.3.17 was requested) !")
endif()
if(NOT PACKAGE_VERSION_EXACT)
  message(SEND_ERROR "PACKAGE_VERSION_EXACT not set, although it should be !")
endif()

if(PACKAGE_VERSION_UNSUITABLE)
  message(SEND_ERROR "PACKAGE_VERSION_UNSUITABLE set, but must not be !")
endif()