FindBaseTest.cmake.in 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. set(MY_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@")
  2. set(_HEADER cmake_i_do_not_exist_in_the_system.h)
  3. set(_HEADER_FULL "${MY_SOURCE_DIR}/include/${_HEADER}")
  4. # at first check that the header isn't found without special measures
  5. find_file(FOO_H_1 ${_HEADER})
  6. if(FOO_H_1)
  7. message(FATAL_ERROR "${_HEADER} found: ${FOO_H_1}, it should not exist !")
  8. endif(FOO_H_1)
  9. # with this it still should not be found, since the include/ subdir is still missing
  10. set(CMAKE_INCLUDE_PATH "${MY_SOURCE_DIR}")
  11. find_file(FOO_H_2 ${_HEADER})
  12. if(FOO_H_2)
  13. message(FATAL_ERROR "${_HEADER} found: ${FOO_H_2}, it should not exist !")
  14. endif(FOO_H_2)
  15. # now with the PATH_SUFFIX it should be found
  16. find_file(FOO_H_3 NAMES ${_HEADER} PATH_SUFFIXES include )
  17. if(NOT "${FOO_H_3}" STREQUAL "${_HEADER_FULL}")
  18. message(FATAL_ERROR "Did not find \"${_HEADER_FULL}\"\ngot ${FOO_H_3} instead !")
  19. endif(NOT "${FOO_H_3}" STREQUAL "${_HEADER_FULL}")
  20. # without PATH_SUFFIX, but with a CMAKE_INCLUDE_PATH it should not be found
  21. set(CMAKE_INCLUDE_PATH /include)
  22. find_file(FOO_H_4 ${_HEADER})
  23. if(FOO_H_4)
  24. message(FATAL_ERROR "${_HEADER} found: ${FOO_H_4}, it should not exist !")
  25. endif(FOO_H_4)
  26. # when setting CMAKE_FIND_ROOT_PATH to the current source dir,
  27. # together with the CMAKE_INCLUDE_PATH it should be found
  28. set(CMAKE_FIND_ROOT_PATH blub "${MY_SOURCE_DIR}")
  29. find_file(FOO_H_5 ${_HEADER})
  30. if(NOT "${FOO_H_5}" STREQUAL "${_HEADER_FULL}")
  31. message(FATAL_ERROR "Did not find \"${_HEADER_FULL}\"\ngot ${FOO_H_5} instead !")
  32. endif(NOT "${FOO_H_5}" STREQUAL "${_HEADER_FULL}")
  33. # by explicitely disabling CMAKE_FIND_ROOT_PATH again it shouldn't be found
  34. find_file(FOO_H_6 ${_HEADER} NO_CMAKE_FIND_ROOT_PATH)
  35. if(FOO_H_6)
  36. message(FATAL_ERROR "${_HEADER} found: ${FOO_H_6}, it should not exist !")
  37. endif(FOO_H_6)