mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-09 23:30:35 -06:00
ExternalProject: Fix env mods with empty command
Fixes a bug when working with external projects with empty commands and environment modifications. This change ensures that we are only applying environment modifications when there is a command to apply the modification to. Fixes: #27113
This commit is contained in:
@@ -2306,15 +2306,18 @@ function(ExternalProject_Add_Step name step)
|
||||
list(JOIN environment ";--modify;" environment)
|
||||
list(PREPEND environment "--modify")
|
||||
|
||||
set(_result "")
|
||||
list(APPEND _result "${CMAKE_COMMAND}" -E env ${environment} --)
|
||||
foreach(element IN LISTS command)
|
||||
list(APPEND _result "${element}")
|
||||
if("${element}" STREQUAL COMMAND)
|
||||
list(APPEND _result "${CMAKE_COMMAND}" -E env ${environment} --)
|
||||
string(REPLACE ";" "\;" command "${command}")
|
||||
string(REPLACE "COMMAND" ";" command "${command}")
|
||||
|
||||
set(__cmd)
|
||||
foreach(__item IN LISTS command)
|
||||
list(APPEND __cmd "COMMAND")
|
||||
if(__item AND NOT "x${__item}" STREQUAL "x;;")
|
||||
list(APPEND __cmd "${CMAKE_COMMAND}" -E env ${environment} --)
|
||||
endif()
|
||||
list(APPEND __cmd "${__item}")
|
||||
endforeach()
|
||||
set(command ${_result})
|
||||
set(command ${__cmd})
|
||||
endif()
|
||||
|
||||
# Replace location tags.
|
||||
|
||||
@@ -11,8 +11,10 @@ ExternalProject_Add(CustomCommandEnvVars
|
||||
UPDATE_COMMAND ""
|
||||
PATCH_COMMAND ""
|
||||
LIST_SEPARATOR ,
|
||||
CONFIGURE_COMMAND "${CMAKE_COMMAND}" -P ${ScriptPath}
|
||||
CONFIGURE_COMMAND ""
|
||||
COMMAND "${CMAKE_COMMAND}" -P ${ScriptPath}
|
||||
COMMAND "${CMAKE_COMMAND}" -DVARNAME=Stage -P ${ScriptPath}
|
||||
COMMAND ""
|
||||
COMMAND "${CMAKE_COMMAND}" -DVARNAME=ListVar -P ${ScriptPath}
|
||||
CONFIGURE_ENVIRONMENT_MODIFICATION
|
||||
Stage=set:config
|
||||
|
||||
Reference in New Issue
Block a user