CMakeLists.txt相关笔记

#cmake 版本
cmake_minimum_required(VERSION 3.4.1)
#将cpp加入到native-lib库中
add_library(native-lib SHARED native-lib.cpp)
#导入静态库.a文件,.a文件放入lib目录下即可
set(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -L${CMAKE_SOURCE_DIR}/lib")
#导入头文件
include_directories(${CMAKE_SOURCE_DIR}/include)
#将当前文件夹所有.cpp 打包成my_source_path
file(GLOB my_source_path ${CMAKE_SOURCE_DIR}/*.cpp)或
aux_source_directory(. SOURCE)一样使用
#添加库
add_library(native-lib SHARED ${my_source_path})
add_library(native-lib SHARED ${SOURCE})
#添加动态so库
add_library(libx264 SHARED IMPORTED)
set_target_properties(libx264 PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/include/libx264.so)
#找NDK中的系统库
find_library(log-lib   log)
#动态链接库到项目中
target_link_libraries( native-lib libx264  ${log-lib})

你可能感兴趣的:(CMakeLists.txt相关笔记)