my-tv/app/CMakeLists.txt

101 lines
2.9 KiB
CMake
Raw Normal View History

2023-12-15 13:04:32 +08:00
# Sets the minimum version of CMake required to build your native library.
# This ensures that a certain set of CMake features is available to
# your build.
cmake_minimum_required(VERSION 3.21.1)
project(MyTV)
# Specifies a path to native header files.
include_directories(src/main/cpp/include)
if (IS_SO_BUILD)
# Specifies a library name, specifies whether the library is STATIC or
# SHARED, and provides relative paths to the source code. You can
# define multiple libraries by adding multiple add_library() commands,
# and CMake builds them for you. When you build your app, Gradle
# automatically packages shared libraries with your APK.
add_library( # Specifies the name of the library.
2023-12-16 15:09:09 +08:00
native
2023-12-15 13:04:32 +08:00
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
2023-12-16 15:09:09 +08:00
src/main/cpp/native.c)
2023-12-15 13:04:32 +08:00
# 设置编译输出路径
set_target_properties(
2023-12-16 15:09:09 +08:00
native
2023-12-15 13:04:32 +08:00
PROPERTIES
LIBRARY_OUTPUT_DIRECTORY
${CMAKE_SOURCE_DIR}/src/main/cpp/${ANDROID_ABI}
)
else ()
add_library(
nothing
SHARED
src/main/cpp/nothing.c)
2023-12-16 15:09:09 +08:00
add_library(native
2023-12-15 13:04:32 +08:00
SHARED
IMPORTED)
set_target_properties( # Specifies the target library.
2023-12-16 15:09:09 +08:00
native
2023-12-15 13:04:32 +08:00
# Specifies the parameter you want to define.
PROPERTIES IMPORTED_LOCATION
# Provides the path to the library you want to import.
2023-12-16 15:09:09 +08:00
${CMAKE_SOURCE_DIR}/src/main/cpp/${ANDROID_ABI}/libnative.so)
2023-12-15 13:04:32 +08:00
endif ()
add_library(libssl
SHARED
IMPORTED)
set_target_properties( # Specifies the target library.
libssl
# Specifies the parameter you want to define.
PROPERTIES IMPORTED_LOCATION
# Provides the path to the library you want to import.
${CMAKE_SOURCE_DIR}/src/main/cpp/${ANDROID_ABI}/libssl.so)
add_library(libcrypto
SHARED
IMPORTED)
set_target_properties( # Specifies the target library.
libcrypto
# Specifies the parameter you want to define.
PROPERTIES IMPORTED_LOCATION
# Provides the path to the library you want to import.
${CMAKE_SOURCE_DIR}/src/main/cpp/${ANDROID_ABI}/libcrypto.so)
find_library( # Defines the name of the path variable that stores the
# location of the NDK library.
log-lib
# Specifies the name of the NDK library that
# CMake needs to locate.
log)
if (IS_SO_BUILD)
# Links your native library against one or more other native libraries.
target_link_libraries( # Specifies the target library.
2023-12-16 15:09:09 +08:00
native
2023-12-15 13:04:32 +08:00
libssl
libcrypto
${log-lib})
else ()
target_link_libraries( # Specifies the target library.
nothing
2023-12-15 14:04:02 +08:00
libssl
libcrypto
2023-12-16 15:09:09 +08:00
native
2023-12-15 14:04:02 +08:00
${log-lib})
2023-12-15 13:04:32 +08:00
endif ()