mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-01-30 04:44:26 +00:00
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.
16 lines
336 B
CMake
16 lines
336 B
CMake
|
|
enable_language(CXX)
|
|
|
|
# Ensure re-generation
|
|
file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp")
|
|
|
|
file(GENERATE
|
|
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/main.cpp"
|
|
CONTENT "int main() { return 0; }\n"
|
|
)
|
|
|
|
add_executable(mn "${CMAKE_CURRENT_BINARY_DIR}/main.cpp")
|
|
|
|
add_subdirectory(GenerateSource)
|
|
target_link_libraries(mn PRIVATE ObjLib)
|