文章目录
- 源码目录
- CMakeList.txt配置
分享一个项目的CMake配置,或许给你的项目配置提供参考:
源码目录
其中,除了include文件夹只包含头文件,其他文件夹都包含c文件和头文件:
CMakeList.txt配置
# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html
# Sets the minimum version of CMake required to build the native library.
cmake_minimum_required(VERSION 3.22.1)
project("security")
file(GLOB_RECURSE SRC_LIST *.cpp *.c)
add_library( # Sets the name of the library.
security
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
nativelib.cpp
${SRC_LIST}
)
target_include_directories(security
PUBLIC
ksnet/ext_crypt
ksnet/include
ksnet/ks_crypt
ksnet/rsarefc
ksnet/source)
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( # Specifies the target library.
security
# Links the target library to the log library
# included in the NDK.
${log-lib})
例子提供参考。