Browse Source

ExternalProject: Fix step dependency on mkdir step

When looking at `list(FIND)` result, zero index is ignored due to
incorrect error handling, and users can't set dependencies on mkdir
step.

Fixes: #20605
Vyacheslav Yurkov 5 years ago
parent
commit
e5b33871ed

+ 1 - 1
Modules/ExternalProject.cmake

@@ -2282,7 +2282,7 @@ function(ExternalProject_Add_StepDependencies name step)
 
   get_property(steps TARGET ${name} PROPERTY _EP_STEPS)
   list(FIND steps ${step} is_step)
-  if(NOT is_step)
+  if(is_step LESS 0)
     message(FATAL_ERROR "External project \"${name}\" does not have a step \"${step}\".")
   endif()
 

+ 1 - 1
Tests/RunCMake/ExternalProject/Add_StepDependencies_iface_step-stderr.txt

@@ -1,5 +1,5 @@
 ^CMake Error at .*/Modules/ExternalProject.cmake:[0-9]+ \(message\):
-  Target "MyProj-IFace" was not generated by ExternalProject_Add_StepTargets.
+  External project "MyProj" does not have a step "IFace".
 Call Stack \(most recent call first\):
   Add_StepDependencies_iface_step.cmake:[0-9]+ \(ExternalProject_Add_StepDependencies\)
   CMakeLists.txt:[0-9]+ \(include\)$