IncludeTest.cmake.in 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # this one must silently fail
  2. include(I_am_not_here OPTIONAL)
  3. # this one must be found and the result must be put into _includedFile
  4. include(CMake RESULT_VARIABLE _includedFile)
  5. set(fileOne "${_includedFile}")
  6. set(fileTwo "${CMAKE_ROOT}/Modules/CMake.cmake")
  7. if(WIN32)
  8. string(TOLOWER "${fileOne}" fileOne)
  9. string(TOLOWER "${fileTwo}" fileTwo)
  10. endif()
  11. if(NOT "${fileOne}" STREQUAL "${fileTwo}")
  12. message(FATAL_ERROR "Wrong CMake.cmake was included: \"${fileOne}\" expected \"${fileTwo}\"")
  13. endif()
  14. # this one must return NOTFOUND in _includedFile
  15. include(I_do_not_exist OPTIONAL RESULT_VARIABLE _includedFile)
  16. if(_includedFile)
  17. message(FATAL_ERROR "File \"I_do_not_exist\" was included, although it shouldn't exist,\nIncluded file is \"${_includedFile}\"")
  18. endif()
  19. # and this one must succeed too
  20. include(CMake OPTIONAL RESULT_VARIABLE _includedFile)
  21. set(fileOne "${_includedFile}")
  22. set(fileTwo "${CMAKE_ROOT}/Modules/CMake.cmake")
  23. if(WIN32)
  24. string(TOLOWER "${fileOne}" fileOne)
  25. string(TOLOWER "${fileTwo}" fileTwo)
  26. endif()
  27. if(NOT "${fileOne}" STREQUAL "${fileTwo}")
  28. message(FATAL_ERROR "Wrong CMake.cmake was included: \"${fileOne}\" expected \"${fileTwo}\"")
  29. endif()
  30. # Check that CMAKE_CURRENT_LIST_DIR is working:
  31. # Needs to be a file in the build tree, which is correct cmake script
  32. # but doesn't do a lot, if possible only set() commands:
  33. include(${CMAKE_CURRENT_LIST_DIR}/../../CTestCustom.cmake)