mirror of
https://github.com/Kitware/CMake.git
synced 2026-08-04 14:50:23 +00:00
committed by
Craig Scott
parent
52445300d6
commit
08be74bfd7
@@ -660,6 +660,15 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
|
|||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Check for a script by extension (.bat,.sh,...) or if the file starts with "#!" (shebang)
|
||||||
|
file(READ ${target} file_contents LIMIT 5)
|
||||||
|
if(target MATCHES "\\.(bat|c?sh|bash|ksh|cmd)$" OR file_contents MATCHES "^#!")
|
||||||
|
message(STATUS "GetPrequisites(${target}) : ignoring script file")
|
||||||
|
# Clear var
|
||||||
|
set(${prerequisites_var} "" PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
set(gp_cmd_paths ${gp_cmd_paths}
|
set(gp_cmd_paths ${gp_cmd_paths}
|
||||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\14.0;InstallDir]/../../VC/bin"
|
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\14.0;InstallDir]/../../VC/bin"
|
||||||
"$ENV{VS140COMNTOOLS}/../../VC/bin"
|
"$ENV{VS140COMNTOOLS}/../../VC/bin"
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
-- GetPrequisites\(.*script.sh\) : ignoring script file
|
||||||
|
-- GetPrequisites\(.*script.bat\) : ignoring script file
|
||||||
|
-- GetPrequisites\(.*script\) : ignoring script file
|
||||||
19
Tests/RunCMake/GetPrerequisites/ExecutableScripts.cmake
Normal file
19
Tests/RunCMake/GetPrerequisites/ExecutableScripts.cmake
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
include(GetPrerequisites)
|
||||||
|
|
||||||
|
function(check_script script)
|
||||||
|
set(prereqs "")
|
||||||
|
get_prerequisites(${script} prereqs 1 1 "" "")
|
||||||
|
if(NOT "${prereqs}" STREQUAL "")
|
||||||
|
message(FATAL_ERROR "Prerequisites for ${script} not empty")
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# Should not throw any errors
|
||||||
|
# Regular executable
|
||||||
|
get_prerequisites(${CMAKE_COMMAND} cmake_prereqs 1 1 "" "")
|
||||||
|
# Shell script
|
||||||
|
check_script(${CMAKE_CURRENT_LIST_DIR}/script.sh)
|
||||||
|
# Batch script
|
||||||
|
check_script(${CMAKE_CURRENT_LIST_DIR}/script.bat)
|
||||||
|
# Shell script without extension
|
||||||
|
check_script(${CMAKE_CURRENT_LIST_DIR}/script)
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
include(RunCMake)
|
include(RunCMake)
|
||||||
|
|
||||||
run_cmake_command(TargetMissing ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/TargetMissing.cmake)
|
run_cmake_command(TargetMissing ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/TargetMissing.cmake)
|
||||||
|
run_cmake_command(ExecutableScripts ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/ExecutableScripts.cmake)
|
||||||
|
|||||||
3
Tests/RunCMake/GetPrerequisites/script
Executable file
3
Tests/RunCMake/GetPrerequisites/script
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "Hello World"
|
||||||
3
Tests/RunCMake/GetPrerequisites/script.bat
Executable file
3
Tests/RunCMake/GetPrerequisites/script.bat
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
@echo off
|
||||||
|
|
||||||
|
echo "Hello world"
|
||||||
3
Tests/RunCMake/GetPrerequisites/script.sh
Executable file
3
Tests/RunCMake/GetPrerequisites/script.sh
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "Hello World"
|
||||||
Reference in New Issue
Block a user