diff --git a/cmake/go.cmake b/cmake/go.cmake index c9e8a347a7..c91ee1fbd1 100644 --- a/cmake/go.cmake +++ b/cmake/go.cmake @@ -12,6 +12,22 @@ endif() if(NOT GO_EXECUTABLE AND NOT DISABLE_GO) message(FATAL_ERROR "Could not find Go") +elseif(NOT DISABLE_GO) + execute_process( + COMMAND ${GO_EXECUTABLE} version + OUTPUT_VARIABLE go_version_output + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + # Example: 'go version go1.21.3 darwin/arm64' match any number of '#.' and one '#' + string(REGEX MATCH "([0-9]+\\.)*[0-9]+" go_version ${go_version_output}) + + # This should track /go.mod and /BUILDING.md + set(minimum_go_version "1.18") + if(go_version VERSION_LESS minimum_go_version) + message(FATAL_ERROR "Go compiler version must be at least ${minimum_go_version}. Found version ${go_version}") + else() + message(STATUS "Go compiler ${go_version} found") + endif() endif() function(go_executable dest package) diff --git a/go.mod b/go.mod index 48feb26be3..4307263dec 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,6 @@ module boringssl.googlesource.com/boringssl +// When this changes update /cmake/go.cmake minimum_go_version and /BUILDING.md go 1.18 require (