summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/File_Generate
diff options
context:
space:
mode:
authorJosef Angstenberger <code@jtxa.de>2020-09-20 15:38:09 (GMT)
committerJosef Angstenberger <code@jtxa.de>2020-09-21 21:02:08 (GMT)
commite02f677f61030f6c74f06ecd56092521dd68cab4 (patch)
treefc2bdece30c187ccf41999c0aab14b6795e0a298 /Tests/RunCMake/File_Generate
parent64901e053ba8fcc7b641819d36510317ea74c282 (diff)
downloadCMake-e02f677f61030f6c74f06ecd56092521dd68cab4.zip
CMake-e02f677f61030f6c74f06ecd56092521dd68cab4.tar.gz
CMake-e02f677f61030f6c74f06ecd56092521dd68cab4.tar.bz2
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.
Diffstat (limited to 'Tests/RunCMake/File_Generate')
-rw-r--r--Tests/RunCMake/File_Generate/GenerateSource.cmake3
-rw-r--r--Tests/RunCMake/File_Generate/GenerateSource/CMakeLists.txt8
2 files changed, 11 insertions, 0 deletions
diff --git a/Tests/RunCMake/File_Generate/GenerateSource.cmake b/Tests/RunCMake/File_Generate/GenerateSource.cmake
index 147a7f6..d5504e3 100644
--- a/Tests/RunCMake/File_Generate/GenerateSource.cmake
+++ b/Tests/RunCMake/File_Generate/GenerateSource.cmake
@@ -10,3 +10,6 @@ file(GENERATE
)
add_executable(mn "${CMAKE_CURRENT_BINARY_DIR}/main.cpp")
+
+add_subdirectory(GenerateSource)
+target_link_libraries(mn PRIVATE ObjLib)
diff --git a/Tests/RunCMake/File_Generate/GenerateSource/CMakeLists.txt b/Tests/RunCMake/File_Generate/GenerateSource/CMakeLists.txt
new file mode 100644
index 0000000..bca8922
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/GenerateSource/CMakeLists.txt
@@ -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 "")