dragon8899 2011-11-02 10:03
浏览 743
已采纳

如何使CMake与go编程语言一起使用?

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.

  • 写回答

2条回答 默认 最新

  • dspym82000 2011-11-02 11:28
    关注

    You might wish to implement CMake' support for Go. Roughly speaking it involves following steps:

    1. Create CMakeDetermineGoCompiler.cmake module, which would find Go compiler for the current system.
    2. Create CMakeGoCompiler.cmake.in - a template, which would be configured by CMakeDetermineGoCompiler.

    3. Create CMakeTestGoCompiler.cmake, module which would compile a simple go source to check if the compiler works.

    4. 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).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 kali环境运行volatility分析android内存文件,缺profile
  • ¥15 写uniapp时遇到的问题
  • ¥15 vs 2008 安装遇到问题
  • ¥15 matlab有限元法求解梁带有若干弹簧质量系统的固有频率
  • ¥15 找一个网络防御专家,外包的
  • ¥100 能不能让两张不同的图片md5值一样,(有尝)
  • ¥15 informer代码训练自己的数据集,改参数怎么改
  • ¥15 请看一下,学校实验要求,我需要具体代码
  • ¥50 pc微信3.6.0.18不能登陆 有偿解决问题
  • ¥20 MATLAB绘制两隐函数曲面的交线