make & cmake

输出内容为空

https://github.com/rizsotto/Bear/wiki/Troubleshooting#the-output-is-empty

可能需要在configure时也加上bear

cmake 中加入调试信息

cmake 中有一个变量CMAKE_BUILD_TYPE, 可以的取值是:

  • Debug: -g
  • Release: -O3 -DNDEBUG
  • RelWithDebInfo: -O2 -g -DNDEBUG
  • MinSizeRel: -Os -DNDEBUG

cmake 生成 compile command

CMake creates compilation database out of the box. You don’t need to use Bear for that. Just pass -DCMAKE_EXPORT_COMPILE_COMMANDS=ON flag when you call cmake.

https://github.com/rizsotto/Bear/wiki/Usage#cmake

如果是使用gn gen则加上选项:--export-compile-commands

https://blog.csdn.net/cllcsy/article/details/107869780

cmake 大小端检测

CMAKE_<LANG>_BYTE_ORDER

https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_BYTE_ORDER.html

option 选项开关

  1. 在 CMakeLists.txt 中添加选项,默认关闭

option(TEST_DEBUG "option for debug" OFF)

  1. cmake 打开选项

cmake -DTEST_DEBUG=ON

添加编译器选项

  • 添加 C 编译器选项:cmake -DCMAKE_C_FLAGS=xxx
  • 添加链接器选项:CMAKE_EXE_LINKER_FLAGS, CMAKE_SHARED_LINKER_FLAGS, CMAKE_MODULE_LINKER_FLAGS

文档信息

Search

    Table of Contents