CMakeList.txt 解析

最近在写新项目的时候,需要用到webrtc-vad,于是用cmake来编译一下。配置CMakeList.txt 在此记录。

在CMakeLists.txt开头设置cmake最小版本

add_library:添加库,三个参数分别设置库的名字“native-lib”,设置类型为“STATIC”或者“SHARED”,如果是第三方的包的话 必须是“SHARE”,设置原文件的相对路径或者如果全部为第三方的文件的话可以写成“IMPORTED”。

add_library( # Sets the name of the library.
             native-lib

             # Sets the library as a shared library.
             SHARED

             # Provides a relative path to your source file(s).
             native-lib.cpp )

include_directories:设置第三方库路径(首图中并未写)

include_directories(src/main/cpp/include/*.c)

find_library:搜索系统库,如果项目里面有用到系统的库就是要把库名写到这个函数里面去找到相对应的so。下面用到了日志库 就需要把日志库引入

find_library( # Sets the name of the path variable.
              log-lib

              # Specifies the name of the NDK library that
              # you want CMake to locate.
              log )
target_link_libraries:指定库CMake链接到目标库中,通俗一点在.so在编译时就是把多个用到的库串联起来才能编译
target_link_libraries( # Specifies the target library.
                       native-lib

                       # Links the target library to the log library
                       # included in the NDK.
                       ${log-lib} )

简单在此做下记录。
 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值