CMakelists样例
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CMakelists样例相关的知识,希望对你有一定的参考价值。
1.cmake版本需求cmake_minimum_required(VERSION 3.4.1)
2.定义目录
set(COMMON_DIR ${PROJECT_DIR}/src/main/cpp/common)
set(TOOLKIT_DIR ${PROJECT_DIR}/src/main/cpp/toolkit)
set(LIBYUV_DIR ${TOOLKIT_DIR}/libyuv/libs)
set(LIBYUV_INCLUDE_DIR ${LIBYUV_DIR}/include)
3.依赖的头文件目录
include_directories(${COMMON_DIR}
${LIBYUV_INCLUDE_DIR}
${TOOLKIT_DIR})
4.链接库目录
link_directories(${LIBYUV_DIR}/${android_ABI})
5.定义生成库
add_library(Toolkits
SHARED
${TOOLKIT_DIR}/jni_interface.cpp)
6.根据cpu类型,设置特殊配置
if( ${ANDROID_ABI} MATCHES "armeabi-v7a" )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -mfloat-abi=softfp -mfpu=neon -march=armv7-a -mtune=cortex-a8")
message(${ANDROID_ABI},当前启用neon设置)
endif(${ANDROID_ABI} MATCHES "armeabi-v7a")
7.设置编译参数
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_JNI_LOG=1")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DANDROID_STL=gnustl_static")
set(CMAKE_VERBOSE_MAKEFILE on)
8.目标链接库
target_link_libraries(Toolkits yuv)
target_link_libraries(Toolkits log)
以上是关于CMakelists样例的主要内容,如果未能解决你的问题,请参考以下文章