How to partially disabling cmake C/C++ custom compiler checking

后端 未结 2 706
暗喜
暗喜 2020-12-10 21:49

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 an

2条回答
  •  眼角桃花
    2020-12-10 22:37

    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 AMRCC + custom linker
    • cmake cross-compile with specific linker doesn't pass arguments to armlink

提交回复
热议问题