summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/UnityBuild/unitybuild_relocatable_locations.cmake
blob: 5b267fc93ecb8f3a0407f9ec245a000f3aae0c36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
set(CMAKE_INTERMEDIATE_DIR_STRATEGY FULL CACHE STRING "" FORCE)

project(unitybuild_relocatable_locations C)

# Binary path relative source file
set(srcs "")
foreach(s RANGE 1 3)
  set(src "${CMAKE_CURRENT_BINARY_DIR}/s${s}.c")
  file(WRITE "${src}" "int s${s}(void) { return 0; }\n")
  list(APPEND srcs "${src}")
endforeach()
foreach(s RANGE 1 3)
  set(src "${CMAKE_CURRENT_BINARY_DIR}/subFolder/sub${s}.c")
  file(WRITE "${src}" "int sub${s}(void) { return 0; }\n")
  list(APPEND srcs "${src}")
endforeach()

# Source path relative source file
list(APPEND srcs "${CMAKE_SOURCE_DIR}/f.c")
list(APPEND srcs "${CMAKE_SOURCE_DIR}/relocatable/foo.c")

add_library(tgt SHARED ${srcs})

set_target_properties(tgt PROPERTIES UNITY_BUILD ON
                                     UNITY_BUILD_RELOCATABLE TRUE)