mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
The FASTBuild generator puts source files from different subdirectories into different `FastbuildObjectListNode` instances. This ensures that files with the same name will not write to the same object file. A unity bucket can only contain files from a single `FastbuildObjectListNode` instance, so a side effect of this logic is that unity buckets can only contain files in the same subdirectory. This change fixes the problem by skipping the subdirectory check logic for files with unity enabled. Fixes: #27457
17 lines
658 B
CMake
17 lines
658 B
CMake
# Test that unity build combines files from different subdirectories into the same unity bucket.
|
|
|
|
set(CMAKE_UNITY_BUILD ON)
|
|
|
|
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/subdir1)
|
|
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/subdir2)
|
|
|
|
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/main.cpp "int main() { return 0; }\n")
|
|
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/subdir1/file1.cpp "int file1() { return 1; }\n")
|
|
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/subdir2/file2.cpp "int file2() { return 2; }\n")
|
|
|
|
add_executable(main
|
|
${CMAKE_CURRENT_BINARY_DIR}/main.cpp
|
|
${CMAKE_CURRENT_BINARY_DIR}/subdir1/file1.cpp
|
|
${CMAKE_CURRENT_BINARY_DIR}/subdir2/file2.cpp
|
|
)
|