CMakeLists.txt 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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)
  25. ADD_LIBRARY(CMakeTestLibraryShared SHARED SharedLibrarySources)
  26. SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DTEST_C_FLAGS")
  27. ADD_LIBRARY(CMakeTestCLibraryShared SHARED testConly.c)
  28. #
  29. # Attach a post-build custom-command to the lib.
  30. # It runs ${CREATE_FILE_EXE} which will create a file.
  31. # The 'complex' executable will then test if this file exists and remove it.
  32. #
  33. ADD_DEPENDENCIES(CMakeTestLibraryShared create_file)
  34. ADD_CUSTOM_COMMAND(SOURCE CMakeTestLibraryShared
  35. COMMAND ${CREATE_FILE_EXE}
  36. ARGS "${Complex_BINARY_DIR}/Library/postbuild.txt"
  37. TARGET CMakeTestLibraryShared)
  38. ADD_CUSTOM_COMMAND(SOURCE CMakeTestLibraryShared
  39. COMMAND ${CCOMMAND_COMMAND}
  40. ARGS copy
  41. "${Complex_BINARY_DIR}/Library/postbuild.txt"
  42. "${Complex_BINARY_DIR}/Library/postbuild2.txt"
  43. TARGET CMakeTestLibraryShared)
  44. #
  45. # Add a custom target.
  46. # It runs ${CREATE_FILE_EXE} which will create a file.
  47. # The 'complex' executable will then test if this file exists and remove it.
  48. #
  49. ADD_CUSTOM_TARGET(custom_target1
  50. ALL
  51. ${CREATE_FILE_EXE}
  52. "${Complex_BINARY_DIR}/Library/custom_target1.txt")
  53. ADD_DEPENDENCIES(custom_target1 create_file)
  54. #
  55. # Extra coverage
  56. #
  57. ABSTRACT_FILES(
  58. file2
  59. )
  60. INSTALL_FILES(/tmp .h ${Complex_BINARY_DIR}/cmTestConfigure.h)
  61. INSTALL_FILES(/tmp .cxx ${Complex_BINARY_DIR}/cmTestConfigure.h)