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.
CMake project files (such as CMakeLists. txt ) are consumed directly by Visual Studio for the purposes of IntelliSense and browsing. cmake.exe is invoked directly by Visual Studio for CMake configuration and build.
Starting with just C/C++ project support, modern CMake now supports languages like Fortran, C# and CUDA. Over the years a lot of open source projects migrated from Makefile based build system to CMake.
In the C/C++ ecosystem, the best tool for project configuration is CMake. CMake allows you to specify the build of a project, in files named CMakeLists.
You might wish to implement CMake' support for Go. Roughly speaking it involves following steps:
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.
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).
It's in your best interest to not use CMake (or any other build system).
Go has a simple, built-in way to build packages: go build
(which also makes go get
and go install
work). go build
, by design, doesn't require additional tools like make or cmake.
If you use CMake (or any other build system) you'll just make life harder for yourself (if you plan to use libraries developed by others) or for other people (if you plan to develop libraries that are meant to be used by others).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With