CMakeLists.txt 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #
  2. # Small utility used to create file
  3. # UTILITY_SOURCE is used for coverage and for getting the exact name
  4. # of the executable.
  5. #
  6. UTILITY_SOURCE(CREATE_FILE_EXE create_file "." create_file.cxx)
  7. ADD_EXECUTABLE(create_file create_file.cxx)
  8. #
  9. # Create static library
  10. # SOURCE_FILES_REMOVE is used for Coverage. empty.h is included for coverage
  11. #
  12. AUX_SOURCE_DIRECTORY(ExtraSources LibrarySources)
  13. SOURCE_FILES(LibrarySources
  14. file2
  15. empty
  16. create_file.cxx
  17. GENERATED
  18. nonexisting_file)
  19. SOURCE_FILES_REMOVE(LibrarySources create_file.cxx GENERATED nonexisting_file)
  20. ADD_LIBRARY(CMakeTestLibrary LibrarySources)
  21. #
  22. # Create shared library
  23. #
  24. SOURCE_FILES(SharedLibrarySources sharedFile fileFlags)
  25. SOURCE_FILES_FLAGS("-DEXTRA_FLAG" fileFlags )
  26. ADD_LIBRARY(CMakeTestLibraryShared SHARED SharedLibrarySources)
  27. #
  28. # Attach a post-build custom-command to the lib.
  29. # It runs ${CREATE_FILE_EXE} which will create a file.
  30. # The 'complex' executable will then test if this file exists and remove it.
  31. #
  32. ADD_DEPENDENCIES(CMakeTestLibraryShared create_file)
  33. ADD_CUSTOM_COMMAND(SOURCE CMakeTestLibraryShared
  34. COMMAND ${CREATE_FILE_EXE}
  35. ARGS "${Complex_BINARY_DIR}/Library/postbuild.txt"
  36. TARGET CMakeTestLibraryShared)
  37. #
  38. # Add a custom target.
  39. # It runs ${CREATE_FILE_EXE} which will create the file
  40. # It runs ${CREATE_FILE_EXE} which will create a file.
  41. # The 'complex' executable will then test if this file exists and remove it.
  42. #
  43. ADD_CUSTOM_TARGET(custom_target1
  44. ALL
  45. ${CREATE_FILE_EXE}
  46. "${Complex_BINARY_DIR}/Library/custom_target1.txt")
  47. ADD_DEPENDENCIES(custom_target1 create_file)
  48. #
  49. # Extra coverage
  50. #
  51. ABSTRACT_FILES(
  52. ExtraSources/file1.cxx
  53. )
  54. INSTALL_FILES(/tmp .h ${Complex_BINARY_DIR}/cmTestConfigure.h)
  55. INSTALL_FILES(/tmp .cxx ${Complex_BINARY_DIR}/cmTestConfigure.h)