CMakeLists.txt 818 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. cmake_minimum_required(VERSION 2.6)
  2. project(Unset C)
  3. # Local variable
  4. set(x 42)
  5. if(NOT x EQUAL 42)
  6. message(FATAL_ERROR "x!=42")
  7. endif(NOT x EQUAL 42)
  8. if(NOT DEFINED x)
  9. message(FATAL_ERROR "x should be defined!")
  10. endif(NOT DEFINED x)
  11. unset(x)
  12. if(DEFINED x)
  13. message(FATAL_ERROR "x should be undefined now!")
  14. endif(DEFINED x)
  15. # Local variable test unset via set()
  16. set(x 43)
  17. if(NOT x EQUAL 43)
  18. message(FATAL_ERROR "x!=43")
  19. endif(NOT x EQUAL 43)
  20. set(x)
  21. if(DEFINED x)
  22. message(FATAL_ERROR "x should be undefined now!")
  23. endif(DEFINED x)
  24. # Cache variable
  25. set(BAR "test" CACHE STRING "documentation")
  26. if(NOT DEFINED BAR)
  27. message(FATAL_ERROR "BAR not defined")
  28. endif(NOT DEFINED BAR)
  29. unset(BAR CACHE)
  30. if(DEFINED BAR)
  31. message(FATAL_ERROR "BAR still defined")
  32. endif(DEFINED BAR)
  33. add_executable(Unset unset.c)