generated from threeal/cmake-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# This code is licensed under the terms of the MIT License. | ||
# Copyright (c) 2024 Alfi Maulana | ||
|
||
include_guard(GLOBAL) | ||
|
||
# Sets up the latest version of Go within this project. | ||
# | ||
# This function downloads the latest version of Go build from the remote server and then extracts that | ||
# and makes it available in the project. | ||
# | ||
# This function set `GO_EXECUTABLE` to the location of the Go executable. | ||
function(setup_go) | ||
file(MAKE_DIRECTORY ${CMAKE_BUILD_DIR}/_deps) | ||
file( | ||
DOWNLOAD https://go.dev/dl/go1.22.2.linux-amd64.tar.gz ${CMAKE_BUILD_DIR}/_deps/go.tar.gz | ||
EXPECTED_MD5 f64eb5791a9dab9cbcdf6549b9583280 | ||
) | ||
|
||
execute_process(COMMAND tar -xf ${CMAKE_BUILD_DIR}/_deps/go.tar.gz -C ${CMAKE_BUILD_DIR}/_deps) | ||
|
||
set(GO_EXECUTABLE ${CMAKE_BUILD_DIR}/_deps/go/bin/go PARENT_SCOPE) | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Matches everything if not defined | ||
if(NOT TEST_MATCHES) | ||
set(TEST_MATCHES ".*") | ||
endif() | ||
|
||
set(TEST_COUNT 0) | ||
|
||
if("Set up latest version of Go" MATCHES ${TEST_MATCHES}) | ||
math(EXPR TEST_COUNT "${TEST_COUNT} + 1") | ||
|
||
include(SetupGo) | ||
|
||
setup_go() | ||
endif() | ||
|
||
if(TEST_COUNT LESS_EQUAL 0) | ||
message(FATAL_ERROR "Nothing to test with: ${TEST_MATCHES}") | ||
endif() |