aboutsummaryrefslogtreecommitdiffstats
path: root/cmake/modules/FindPowerShell.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/modules/FindPowerShell.cmake')
-rw-r--r--cmake/modules/FindPowerShell.cmake5
1 files changed, 4 insertions, 1 deletions
diff --git a/cmake/modules/FindPowerShell.cmake b/cmake/modules/FindPowerShell.cmake
index a84039da3d..9e751545d7 100644
--- a/cmake/modules/FindPowerShell.cmake
+++ b/cmake/modules/FindPowerShell.cmake
@@ -18,7 +18,10 @@ find_package_handle_standard_args(POWERSHELL DEFAULT_MSG POWERSHELL_EXECUTABLE)
set(_powershell_command "POWERSHELL_COMMAND-NOTFOUND")
if(POWERSHELL_FOUND)
- set(_powershell_command "${POWERSHELL_EXECUTABLE}" -NoProfile -NonInteractive -executionpolicy bypass -File)
+ # Calling a script using "-File" doesn't properly return exit codes.
+ # Use dot sourcing instead
+ # https://connect.microsoft.com/PowerShell/feedback/details/777375/powershell-exe-does-not-set-an-exit-code-when-file-is-used
+ set(_powershell_command "${POWERSHELL_EXECUTABLE}" -NoProfile -NonInteractive -executionpolicy bypass .)
endif()
set(POWERSHELL_COMMAND ${_powershell_command}
CACHE STRING "Command suitable for running PowerShell scripts."