Skip to content

Set up a specific version of Go from a CMake project

License

Notifications You must be signed in to change notification settings

threeal/setup-go-cmake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SetupGo.cmake

Set up a specific version of Go from a CMake project.

The SetupGo.cmake is a CMake module containing a setup_go function. This function sets up a specific version of Go to be used in a CMake project. It downloads a specific Go build based on the current operating system and architecture from the official Go website and extracts the downloaded result to the CMake build directory.

Integration

This module can be integrated into a CMake project in the following ways:

  • Manually download the SetupGo.cmake file and include it in the CMake project:
    include(path/to/SetupGo.cmake)
  • Use file(DOWNLOAD) to automatically download the SetupGo.cmake file:
    file(
      DOWNLOAD https://github.com/threeal/setup-go-cmake/releases/download/v1.1.0/SetupGo.cmake
        ${CMAKE_BINARY_DIR}/SetupGo.cmake)
    include(${CMAKE_BINARY_DIR}/SetupGo.cmake)
  • Use CPM.cmake to add this package to the CMake project:
    cpmaddpackage(gh:threeal/setup-go-cmake@1.1.0)

Example Usages

This example demonstrates how to set up the latest version of Go to be used in a CMake project:

setup_go()

execute_process(COMMAND ${GO_EXECUTABLE} version)

Specify Go Version

Use the VERSION argument to specify the Go version to set up:

setup_go(VERSION 1.21.9)

License

This project is licensed under the terms of the MIT License.

Copyright © 2024 Alfi Maulana

About

Set up a specific version of Go from a CMake project

Resources

License

Stars

Watchers

Forks

Languages