LooseObjectDepends.cmake 785 B

1234567891011121314151617181920212223242526
  1. cmake_minimum_required(VERSION 3.8)
  2. project(LooseObjectDepends C)
  3. add_custom_command(
  4. OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/command.h"
  5. COMMAND "${CMAKE_COMMAND}" -E touch
  6. "${CMAKE_CURRENT_BINARY_DIR}/command.h"
  7. COMMENT "Creating command.h")
  8. add_custom_target(create-command.h
  9. DEPENDS
  10. "${CMAKE_CURRENT_BINARY_DIR}/command.h")
  11. add_custom_target(create-target.h
  12. BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/target.h"
  13. COMMAND "${CMAKE_COMMAND}" -E touch
  14. "${CMAKE_CURRENT_BINARY_DIR}/target.h"
  15. COMMENT "Creating target.h")
  16. add_library(dep SHARED dep.c)
  17. add_dependencies(dep create-command.h create-target.h)
  18. target_include_directories(dep
  19. PUBLIC
  20. "${CMAKE_CURRENT_BINARY_DIR}")
  21. add_library(top top.c)
  22. target_link_libraries(top PRIVATE dep)