Issue
I have been using CMake with C++ to build libraries and executables and would like to use the same for the go programming language.
What steps do I need to take to configure CMake so it would work with the go programming language?
Essentially, my compiler is 6g which produces a compiled foo.6 - I send it to a linker via 6l foo.6 and I am done. I have the compiler and linker already built and installed.
Obviously, I can just write a simple Makefile for this, but it would be nice to use CMake consistently throughout my project.
TIA for any advice that would help me get started.
Solution
You might wish to implement CMake' support for Go. Roughly speaking it involves following steps:
- Create CMakeDetermineGoCompiler.cmake module, which would find Go compiler for the current system.
Create CMakeGoCompiler.cmake.in - a template, which would be configured by CMakeDetermineGoCompiler.
Create CMakeTestGoCompiler.cmake, module which would compile a simple go source to check if the compiler works.
- Create CMakeGoInformation.cmake, which would set some language-related variables (CMAKE_GO_LINK_EXECUTABLE and so on)
These things should be placed in CMAKE_MODULES_DIR. For reference you can take a look at how Java/CXX support is implemented.
Alternatively, if don't want to mess with such internal stuff, you can solve your task by creating a macro(), which would create a bunch of custom targets/commands (see add_custom_{target,command}() documentation).
Answered By - arrowd Answer Checked By - Timothy Miller (WPSolving Admin)