我正在尝试在其中一个项目的android模块中导入外部C / C ++库。该库称为android-fluidsynth。我正在按照this link上的说明进行集成。以下是我的CMakeLists.txt
的样子:
编辑2:以下一项工作
# 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.4.1)
######################################################################################
######### Adding fluidsynth library from the external code
######################################################################################
# Sets lib_src_DIR to the path of the target CMake project.
set(fluidsynth-lib-name libfluidsynthsrc)
set( lib_DIR /Users/swapnilgupta/work/musicmuni/fluidsynth-android/android/ )
# Sets lib_build_DIR to the path of the desired output directory.
set( lib_build_DIR ${lib_DIR}/outputs )
file(MAKE_DIRECTORY ${lib_build_DIR})
# Adds the CMakeLists.txt file located in the specified directory
# as a build dependency.
add_subdirectory( # Specifies the directory of the CMakeLists.txt file.
${lib_DIR}
# Specifies the directory for the build outputs.
${lib_build_DIR} )
# Adds the output of the additional CMake build as a prebuilt static
# library and names it.
add_library( ${fluidsynth-lib-name}
SHARED
IMPORTED )
set_target_properties( ${fluidsynth-lib-name} PROPERTIES IMPORTED_LOCATION
${lib_build_DIR}/${ANDROID_ABI}/lib${fluidsynth-lib-name}.so )
在尝试构建它时,出现以下错误:
install TARGETS given no RUNTIME DESTINATION for executable target "fluidsynth"
我已经看过一些SO文章,并在
CMakeLists.txt
中添加了以下几行,但仍然收到此错误。if(WIN32)
install(TARGETS fluidsynth
RUNTIME DESTINATION ./)
else()
install(TARGETS fluidsynth
LIBRARY DESTINATION ./)
endif()
谁能帮忙吗?
最佳答案
您不需要为libfluidsynth发明自己的CMakeLists.txt
。您可以将externalNativeBuild指向fluidsynth-android-1.1.10/android/CMakeLists.txt
。
这定义了Fluidsynth库,您可以将其用作其他库的依赖项,例如
target_link_libraries(<mylibname> fluidsynth log)