3 # This module looks for PowerShell and sets the following:
4 # POWERSHELL_EXECUTABLE - Path to PowerShell.
5 # POWERSHELL_COMMAND - Command suitable for running .ps1 scripts
8 # - Add a version check
11 find_program(POWERSHELL_EXECUTABLE
15 DOC "PowerShell command"
18 INCLUDE(FindPackageHandleStandardArgs)
19 find_package_handle_standard_args(PowerShell DEFAULT_MSG POWERSHELL_EXECUTABLE)
21 set(_powershell_command "POWERSHELL_COMMAND-NOTFOUND")
23 # Calling a script using "-File" doesn't properly return exit codes.
24 # Use dot sourcing instead
25 # https://connect.microsoft.com/PowerShell/feedback/details/777375/powershell-exe-does-not-set-an-exit-code-when-file-is-used
26 set(_powershell_command "${POWERSHELL_EXECUTABLE}" -NoProfile -NonInteractive -executionpolicy bypass .)
28 set(POWERSHELL_COMMAND ${_powershell_command}
29 CACHE STRING "Command suitable for running PowerShell scripts."
32 mark_as_advanced(POWERSHELL_EXECUTABLE POWERSHELL_COMMAND)