1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
# FindGo.cmake
if (GO_FOUND)
return()
endif()
# Find the Go program.
find_program(GO_EXECUTABLE go DOC "Go executable")
# Get the Go version.
if (GO_EXECUTABLE)
execute_process(
COMMAND ${GO_EXECUTABLE} version
OUTPUT_VARIABLE GO_VERSION_STRING
RESULT_VARIABLE RESULT
)
if (RESULT EQUAL 0)
string(REGEX MATCH "([0-9]+\\.[0-9]+\(\\.[0-9]+\)?)"
GO_VERSION_STRING "${GO_VERSION_STRING}")
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
Go
REQUIRED_VARS GO_EXECUTABLE
VERSION_VAR GO_VERSION_STRING
FAIL_MESSAGE "Go not found"
)
|