
Add a target property that will be read on unity file generation to attempt to use a relative path to the source file from the CMake Source Directory or the generated unity file. Additionally add the CMake Source Directory and the CMake Binary directory to the include path of the generated unity files. Closes: #26352
14 lines
383 B
CMake
14 lines
383 B
CMake
project(unitybuild_cxx_relocatable_path CXX)
|
|
|
|
set(srcs "")
|
|
foreach(s RANGE 1 3)
|
|
set(src "${CMAKE_CURRENT_BINARY_DIR}/s${s}.cxx")
|
|
file(WRITE "${src}" "int s${s}(void) { return 0; }\n")
|
|
list(APPEND srcs "${src}")
|
|
endforeach()
|
|
|
|
add_library(tgt SHARED ${srcs})
|
|
|
|
set_target_properties(tgt PROPERTIES UNITY_BUILD ON
|
|
UNITY_BUILD_RELOCATABLE TRUE)
|