C - C工程编译那些事【configure-make || cmake-make】

 

一、cofigure是怎么生成的,我们又是怎么使用的

configure和make install背后的故事:

https://azyet.github.io/2015/06/20/configureAndMakeInstall/

二、cmake怎么用的

2.1 cmake参考材料

cmake入门:

http://linghutf.github.io/2016/06/16/cmake/

cmake-book:

https://chenxiaowei.gitbook.io/cmake-cookbook/

cmake option讲解:

https://www.jianshu.com/p/035bc18f8f62

cmake 默认编译选项:

https://www.cnblogs.com/flyinggod/p/8026789.html

https://www.jianshu.com/p/9d246e4071d4

2.2 拓展【cmake编译选项】

使用场景 : 编译脚本传递参数 -> CMake脚本接收option -> 源代码宏

  1. 编译脚本传入参数
    传入一个cmake option TEST_DEBUG
#!/bin/sh

cmake -DTEST_DEBUG=ON .
cmake --build .
  1. CMake脚本接收option
    cmake 脚本定义TEST_DEBUG 默认关闭OFF
1 project(test)
2 
3 option(TEST_DEBUG "option for debug" OFF)
4 if (TEST_DEBUG)
5 add_definitions(-DTEST_DEBUG)
6 endif()
  1. 源代码宏 test.c
1 #include "test.h"
2 
3 #ifdef TEST_DEBUG
4 ...
5 #endif

 

posted @ 2019-11-29 09:51  chiwin  阅读(211)  评论(0编辑  收藏  举报