GetPrerequisites: Restore behavior on missing binary of not clearing list

Prior to commit v3.4.0-rc1~264^2~1 (GetPrerequisites: Add error checks
for execute_process() calls, 2015-07-29), `get_prerequisites` would
simply warn on a missing binary and not update the result list at all.
That commit accidentally made the case an error.  This was fixed by
commit v3.8.0-rc1~110^2 (GetPrerequisites: Do not fail on files we
cannot find, 2017-01-10), but the fix also cleared the result list.
Clearing the list is incorrect because it is supposed to be able to
accumulate results over multiple calls.

Remove the list clearing behavior to restore the original behavior on a
missing binary.

Fixes: #17306
This commit is contained in:
Brad King
2017-09-26 07:14:38 -04:00
parent eae3765b67
commit 1a7b8c8321
5 changed files with 11 additions and 1 deletions

View File

@@ -659,7 +659,6 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
if(NOT EXISTS "${target}")
message("warning: target '${target}' does not exist...")
set(${prerequisites_var} "" PARENT_SCOPE)
return()
endif()

View File

@@ -147,6 +147,7 @@ endif()
add_RunCMake_test(GeneratorExpression)
add_RunCMake_test(GeneratorPlatform)
add_RunCMake_test(GeneratorToolset)
add_RunCMake_test(GetPrerequisites)
add_RunCMake_test(GNUInstallDirs -DSYSTEM_NAME=${CMAKE_SYSTEM_NAME})
add_RunCMake_test(GoogleTest) # Note: does not actually depend on Google Test
add_RunCMake_test(TargetPropertyGeneratorExpressions)

View File

@@ -0,0 +1,3 @@
include(RunCMake)
run_cmake_command(TargetMissing ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/TargetMissing.cmake)

View File

@@ -0,0 +1,3 @@
^warning: target 'does_not_exist' is not absolute\.\.\.
warning: target 'does_not_exist' does not exist\.\.\.
result_var='value;before;call'$

View File

@@ -0,0 +1,4 @@
include(GetPrerequisites)
set(result_var value before call)
get_prerequisites(does_not_exist result_var 0 0 "" "")
message("result_var='${result_var}'")