【发布时间】:2021-12-25 06:03:38
【问题描述】:
我正在尝试使用跨平台库portaudio 构建便携式声音合成器。该库有自己的 CMake 文件可供构建。我想我已经设法将它构建为我的项目的一部分(构建以退出代码 0 完成),但我不知道如何实际使用它的导入。任何#include 我都尝试使用cannot open source file 中的结果。
这是我项目的 CMake 文件:
cmake_minimum_required(VERSION 3.0.0)
project(sound-synth VERSION 0.1.0)
include(CTest)
enable_testing()
include(ExternalProject)
# first try
# ExternalProject_Add(portaudio
# GIT_REPOSITORY https://github.com/PortAudio/portaudio.git
# )
# second try after using git submodule add https://github.com/PortAudio/portaudio.git external/portaudio
add_subdirectory(external/portaudio EXCLUDE_FROM_ALL)
file(GLOB_RECURSE SRC_FILES src/*.cpp)
add_executable(sound-synth main.cpp ${SRC_FILES})
target_include_directories(sound-synth PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
And this is how it looks trying to include header files from the library
我正在使用 VSC 的 CMakeTools 和 MSVC 编译器。
【问题讨论】:
标签: c++ visual-studio-code cmake shared-libraries portaudio