Files
panopainter/cmake/PanoPainterAutomation.cmake

24 lines
900 B
CMake

find_program(PP_POWERSHELL_COMMAND NAMES pwsh powershell)
function(pp_add_powershell_automation_target target_name)
cmake_parse_arguments(PP_AUTOMATION_TARGET "" "COMMENT" "ARGUMENTS" ${ARGN})
if(PP_POWERSHELL_COMMAND)
add_custom_target(${target_name}
COMMAND "${PP_POWERSHELL_COMMAND}"
-NoProfile
-ExecutionPolicy Bypass
${PP_AUTOMATION_TARGET_ARGUMENTS}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMENT "${PP_AUTOMATION_TARGET_COMMENT}"
USES_TERMINAL
VERBATIM)
else()
add_custom_target(${target_name}
COMMAND "${CMAKE_COMMAND}" -E echo "PowerShell was not found; cannot run ${target_name}."
COMMAND "${CMAKE_COMMAND}" -E false
COMMENT "${PP_AUTOMATION_TARGET_COMMENT}"
VERBATIM)
endif()
endfunction()