如何部分禁用cmake C / C ++自定义编译器检查 [英] How to partially disabling cmake C/C++ custom compiler checking

查看:4017
本文介绍了如何部分禁用cmake C / C ++自定义编译器检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用cmake做一些交叉编译。一些是容易与所有的例子在互联网上,我设法在Linux(x86和ARM),Windows和Android上交叉编译我的库。但现在我想在一个自定义平台上做。



我需要实现的过程:


  1. 所有以前的bash经典环境)

  2. 编译cmake

  3. 执行我想要的操作

但是Cmake正在测试我的自定义C / C ++库中的符号,这使我的库无法编译。我有的错误是cmake一些版本的GLIBCXX和CXXABI(没有C问题),但不是所有的。



有没有办法让cmake确定吗?



编辑:



我尝试使用:

 设置(CMAKE_C_COMPILER_WORKS TRUE)
设置(CMAKE_CXX_COMPILER_WORKS TRUE)

并且:

  include(CMakeForceCompiler)
...
cmake_force_c_compiler($ {ENV_PATH} / bin / $ {CC})
cmake_force_cxx_compiler($ {ENV_PATH} / bin / $ { CXX})

但是cmake仍在检查符号。


  1. 如果您没有完整的工具链文件为您的自定义环境创建 - 所以CMake不能链接一个简单的测试程序 - 你可以尝试相对较新的(版本3.6)全局CMake变量名为< a href =https://cmake.org/cmake/help/latest/variable/CMAKE_TRY_COMPILE_TARGET_TYPE.html =nofollow> CMAKE_TRY_COMPILE_TARGET_TYPE



    因此,只需添加以下内容:

      set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 

    然后CMake会尝试建立一个静态库。


  2. 要仅设置最常见的GCC编译器变量并仅进行一些基本检查,请尝试:

      SET(CMAKE_SYSTEM_NAME Generic)

    请参阅 CMake Cross编译:设置系统和工具链


    如果您的目标是没有操作系统的嵌入式系统将CMAKE_SYSTEM_NAME设置为Generic





< 参考




I am trying to do some crosscompilation using cmake. Some are easy with all the examples on Internet, I managed to crosscompile my library on Linux (x86 and ARM), Windows and Android. But now I would like to do it on a custom platform.

The process I need to achieve:

  1. Sourcing my environment (this destroy all previous bash classic environment)
  2. Compile with cmake
  3. Execute what I want

But Cmake is testing for symbols in my custom C/C++ libraries which make my library unable to compile. The errors I have are that cmake some versions of GLIBCXX and CXXABI (no C issues) but not all of them.

Is there a way to make cmake ok with it ?

EDIT:

I tried using:

set(CMAKE_C_COMPILER_WORKS TRUE)
set(CMAKE_CXX_COMPILER_WORKS TRUE)

And with:

include(CMakeForceCompiler)
...
cmake_force_c_compiler(${ENV_PATH}/bin/${CC})
cmake_force_cxx_compiler(${ENV_PATH}/bin/${CXX})

But cmake is still checking for symbols.

解决方案

Without having your environment nor the error message it's not easy to tell the actual root cause but here are two of the common causes and respective fixes:

  1. If you don't have a complete toolchain file created for your custom environment - so CMake can't link a simple test program - you can try the relatively new (version 3.6) global CMake variable named CMAKE_TRY_COMPILE_TARGET_TYPE.

    So just add the following:

    set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
    

    Then CMake would just try to build a static library.

  2. To have only the most common GCC compiler variables set and have only some basic checks, try:

    SET(CMAKE_SYSTEM_NAME Generic)
    

    See CMake Cross Compiling: Setting up the system and toolchain:

    If your target is an embedded system without OS set CMAKE_SYSTEM_NAME to "Generic"

References

这篇关于如何部分禁用cmake C / C ++自定义编译器检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆