CMake/Tests/RunCMake/UnityBuild/unitybuild_cxx_relocatable_path.cmake
James Moore 84996a65aa Unity: Add option to use relative paths for unity files
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
2024-10-15 09:44:18 -07:00

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)