zl程序教程

您现在的位置是:首页 >  其他

当前栏目

cmake下cmake_c_flags,add_definitions详解编程语言

编程语言 详解 add CMake Flags definitions
2023-06-13 09:11:47 时间

add_definitions

添加编译参数,比如add_definitions(-DDEBUG)将在gcc命令行添加DEBUG宏定义

 

ADD_LIBRARY (hello SHARED ${LIBHELLO_SRC})

# 添加静态库,关键词为static,

# ADD_LIBRARY (hello STATIC ${LIBHELLO_SRC})

# 仍然用hello作为target名时,是不能成功创建所需的静态库的,

# 因为hello作为一个target是不能重名的, 故把上面的hello修改为hello_static

# 同理,你不需要写全libhello_static.a

# 只需要填写hello即可,cmake系统会自动为你生成 libhello_static.X

ADD_LIBRARY (hello_static STATIC ${LIBHELLO_SRC})

 

# 按照一般的习惯,静态库名字跟动态库名字应该是一致的,只是扩展名不同;

# 即:静态库名为 libhello.a; 动态库名为libhello.so ;

# 所以,希望  hello_static  在输出时,不是 hello_static ,而是以 hello 的名字显示,故设置如下:

SET_TARGET_PROPERTIES (hello_static PROPERTIES OUTPUT_NAME  hello )

 

GET_TARGET_PROPERTY (OUTPUT_VALUE hello_static OUTPUT_NAME)

17585.html

c