CMakeLists.txt 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # a simple CXX only test case
  2. project (Properties)
  3. # these first three tests really test both properties and the management of
  4. # cmSourceFile objects by CMake.
  5. # test properties on a build tree file that is relative (yuck)
  6. configure_file(properties.h.in "${Properties_BINARY_DIR}/properties.h")
  7. set_source_files_properties(properties.h PROPERTIES TEST1 1)
  8. get_source_file_property(RESULT1 properties.h TEST1)
  9. # test properties on a headerfile in the source tree
  10. # accessed without an extenion (also yuck)
  11. set_source_files_properties(properties2 PROPERTIES TEST2 1)
  12. get_source_file_property(RESULT2 properties2 TEST2)
  13. # test properties on a relative source that is not generated
  14. set_source_files_properties(SubDir/properties3.cxx PROPERTIES TEST3 1)
  15. get_source_file_property(RESULT3 SubDir/properties3.cxx TEST3)
  16. include_directories("${Properties_SOURCE_DIR}" "${Properties_BINARY_DIR}")
  17. # test generic property interfaces
  18. define_property(GLOBALTEST GLOBAL "A test property"
  19. "A long description of this test property" 0)
  20. set_properties(GLOBAL PROPERTIES GLOBALTEST 1)
  21. set_properties(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
  22. PROPERTIES DIRECTORYTEST 1)
  23. set_properties(SOURCE_FILE SubDir/properties3.cxx PROPERTIES SOURCETEST 1)
  24. get_property(GLOBALRESULT GLOBAL GLOBALTEST)
  25. get_property(DIRECTORYRESULT DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
  26. DIRECTORYTEST)
  27. get_property(SOURCE_FILERESULT SOURCE_FILE SubDir/properties3.cxx SOURCETEST)
  28. if (RESULT1 AND RESULT2 AND RESULT3 AND GLOBALRESULT AND
  29. DIRECTORYRESULT AND SOURCE_FILERESULT)
  30. add_executable (Properties SubDir/properties3.cxx)
  31. else (RESULT1 AND RESULT2 AND RESULT3 AND GLOBALRESULT AND
  32. DIRECTORYRESULT AND SOURCE_FILERESULT)
  33. message("Error: test results are RESULT1=${RESULT1} RESULT2=${RESULT2} "
  34. "RESULT3=${RESULT3} GLOBALRESULT=${GLOBALRESULT} "
  35. "DIRECTORYRESULT=${DIRECTORYRESULT} "
  36. "SOURCE_FILERESULT=${SOURCE_FILERESULT}")
  37. endif (RESULT1 AND RESULT2 AND RESULT3 AND GLOBALRESULT AND
  38. DIRECTORYRESULT AND SOURCE_FILERESULT)
  39. # test the target property
  40. set_properties(TARGET Properties PROPERTIES TARGETTEST 1)
  41. get_property(TARGETRESULT TARGET Properties TARGETTEST)
  42. if (NOT TARGETRESULT)
  43. message("Error: target result is TARGETRESULT=${TARGETRESULT}")
  44. endif (NOT TARGETRESULT)