Tests: Add test for early source lookup of file(GENERATE)

The output file structures of file(GENERATE) have to be created early to
be able to use the generated files in source lists.

This was not done correctly for subdirectories which has been fixed
in commit aee2c51224 (file(GENERATE): Create output file structures for
all directories first, 2020-09-10).

Add a test case to address issue #21144.
This commit is contained in:
Josef Angstenberger
2020-09-20 17:38:09 +02:00
parent 64901e053b
commit e02f677f61
2 changed files with 11 additions and 0 deletions

View File

@@ -10,3 +10,6 @@ file(GENERATE
)
add_executable(mn "${CMAKE_CURRENT_BINARY_DIR}/main.cpp")
add_subdirectory(GenerateSource)
target_link_libraries(mn PRIVATE ObjLib)

View File

@@ -0,0 +1,8 @@
add_library(ObjLib OBJECT)
target_sources(ObjLib PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/ObjLib.cpp")
# Ensure re-generation
file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/ObjLib.cpp")
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/ObjLib.cpp" CONTENT "")