summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/add_custom_command/generate-once.cmake
diff options
context:
space:
mode:
authorFujii Hironori <fujii.hironori@gmail.com>2018-03-23 06:44:42 (GMT)
committerFujii Hironori <fujii.hironori@gmail.com>2018-04-23 04:31:28 (GMT)
commitf59c33a763ba1483129f0e721bc2394bb7442876 (patch)
tree3ff8c37758ffbe7faebe1e77ec9608e4d619775b /Tests/RunCMake/add_custom_command/generate-once.cmake
parentd58d4daa6b2e36c6e2318e4d67271542dca79ee6 (diff)
downloadCMake-f59c33a763ba1483129f0e721bc2394bb7442876.zip
CMake-f59c33a763ba1483129f0e721bc2394bb7442876.tar.gz
CMake-f59c33a763ba1483129f0e721bc2394bb7442876.tar.bz2
VS: Generate a custom command only in the least dependent target
If a custom command is assigned to multiple targets, generate the build rule only in the least-dependent `.vcxproj` file. Otherwise MSBuild will run the command on the first build of a dependent target even if its dependencies already brought the command up to date (in order to populates its build log). Generate targets in least-to-most-dependent order, and assign a custom command to the least dependent target. Added cmLocalVisualStudio10Generator::GenerateTargetsDepthFirst to call cmVisualStudio10TargetGenerator::Generate in least-dependent order. Moved SourcesVisited from cmVisualStudio10TargetGenerator to cmLocalVisualStudio10Generator to avoid attaching a custom command to multiple targets among the local generator. Fixes: #16767
Diffstat (limited to 'Tests/RunCMake/add_custom_command/generate-once.cmake')
-rw-r--r--Tests/RunCMake/add_custom_command/generate-once.cmake8
1 files changed, 8 insertions, 0 deletions
diff --git a/Tests/RunCMake/add_custom_command/generate-once.cmake b/Tests/RunCMake/add_custom_command/generate-once.cmake
new file mode 100644
index 0000000..2a8e843
--- /dev/null
+++ b/Tests/RunCMake/add_custom_command/generate-once.cmake
@@ -0,0 +1,8 @@
+if (${CMAKE_ARGC} LESS 4)
+ message(FATAL_ERROR "Too few arguments")
+endif()
+set(output "${CMAKE_ARGV3}")
+if(EXISTS ${output})
+ message(FATAL_ERROR "${output} already exists")
+endif()
+file(WRITE ${output} "int main() { return 0; }\n")