unitybuild_relocatable_locations.cmake 801 B

12345678910111213141516171819202122232425
  1. set(CMAKE_INTERMEDIATE_DIR_STRATEGY FULL CACHE STRING "" FORCE)
  2. project(unitybuild_relocatable_locations C)
  3. # Binary path relative source file
  4. set(srcs "")
  5. foreach(s RANGE 1 3)
  6. set(src "${CMAKE_CURRENT_BINARY_DIR}/s${s}.c")
  7. file(WRITE "${src}" "int s${s}(void) { return 0; }\n")
  8. list(APPEND srcs "${src}")
  9. endforeach()
  10. foreach(s RANGE 1 3)
  11. set(src "${CMAKE_CURRENT_BINARY_DIR}/subFolder/sub${s}.c")
  12. file(WRITE "${src}" "int sub${s}(void) { return 0; }\n")
  13. list(APPEND srcs "${src}")
  14. endforeach()
  15. # Source path relative source file
  16. list(APPEND srcs "${CMAKE_SOURCE_DIR}/f.c")
  17. list(APPEND srcs "${CMAKE_SOURCE_DIR}/relocatable/foo.c")
  18. add_library(tgt SHARED ${srcs})
  19. set_target_properties(tgt PROPERTIES UNITY_BUILD ON
  20. UNITY_BUILD_RELOCATABLE TRUE)