summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/File_Generate
diff options
context:
space:
mode:
authorRaul Tambre <raul@tambre.ee>2020-08-15 18:53:15 (GMT)
committerRaul Tambre <raul@tambre.ee>2020-08-20 14:41:52 (GMT)
commit27a912193bfe77e400784b152b1cd67003915c37 (patch)
tree5919a51c400894c9891720f44b842d347a892b31 /Tests/RunCMake/File_Generate
parent2a8f363a54c77bf1f110deabf1933e71a93ef3f4 (diff)
downloadCMake-27a912193bfe77e400784b152b1cd67003915c37.zip
CMake-27a912193bfe77e400784b152b1cd67003915c37.tar.gz
CMake-27a912193bfe77e400784b152b1cd67003915c37.tar.bz2
file(GENERATE): Add TARGET argument
Adds TARGET argument to file(GENERATE) to make resolving generator expressions requiring a target possible. Implements #21101, fixes #21074.
Diffstat (limited to 'Tests/RunCMake/File_Generate')
-rw-r--r--Tests/RunCMake/File_Generate/RunCMakeTest.cmake7
-rw-r--r--Tests/RunCMake/File_Generate/Target.cmake2
-rw-r--r--Tests/RunCMake/File_Generate/sub1/CMakeLists.txt7
-rw-r--r--Tests/RunCMake/File_Generate/sub2/CMakeLists.txt7
4 files changed, 23 insertions, 0 deletions
diff --git a/Tests/RunCMake/File_Generate/RunCMakeTest.cmake b/Tests/RunCMake/File_Generate/RunCMakeTest.cmake
index 770fc6e..48fb71c 100644
--- a/Tests/RunCMake/File_Generate/RunCMakeTest.cmake
+++ b/Tests/RunCMake/File_Generate/RunCMakeTest.cmake
@@ -33,6 +33,13 @@ foreach(l CXX C)
endif()
endforeach()
+run_cmake(Target)
+file(READ "${RunCMake_BINARY_DIR}/Target-build/sub1/output.txt" sub_1)
+file(READ "${RunCMake_BINARY_DIR}/Target-build/sub2/output.txt" sub_2)
+if(NOT sub_1 MATCHES "first" OR NOT sub_2 MATCHES "second")
+ message(SEND_ERROR "Wrong target used by TARGET argument! ${sub_1} ${sub_2}")
+endif()
+
set(timeformat "%Y%j%H%M%S")
file(REMOVE "${RunCMake_BINARY_DIR}/WriteIfDifferent-build/output_file.txt")
diff --git a/Tests/RunCMake/File_Generate/Target.cmake b/Tests/RunCMake/File_Generate/Target.cmake
new file mode 100644
index 0000000..16e8457
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/Target.cmake
@@ -0,0 +1,2 @@
+add_subdirectory(sub1)
+add_subdirectory(sub2)
diff --git a/Tests/RunCMake/File_Generate/sub1/CMakeLists.txt b/Tests/RunCMake/File_Generate/sub1/CMakeLists.txt
new file mode 100644
index 0000000..34c51a4
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/sub1/CMakeLists.txt
@@ -0,0 +1,7 @@
+add_library(library IMPORTED STATIC)
+set_property(TARGET library PROPERTY COMPILE_DEFINITIONS "first")
+
+file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/output.txt"
+ CONTENT "$<TARGET_PROPERTY:COMPILE_DEFINITIONS>"
+ TARGET library
+)
diff --git a/Tests/RunCMake/File_Generate/sub2/CMakeLists.txt b/Tests/RunCMake/File_Generate/sub2/CMakeLists.txt
new file mode 100644
index 0000000..09b81ac
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/sub2/CMakeLists.txt
@@ -0,0 +1,7 @@
+add_library(library IMPORTED STATIC)
+set_property(TARGET library PROPERTY COMPILE_DEFINITIONS "second")
+
+file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/output.txt"
+ CONTENT "$<TARGET_PROPERTY:COMPILE_DEFINITIONS>"
+ TARGET library
+)