我有以下CMakeLists.txt
:
cmake_minimum_required (VERSION 2.8.7)
project (Test)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
find_package(CURL REQUIRED)
find_package(PortAudio REQUIRED)
find_package(LibSndFile REQUIRED)
include_directories(src/audio src/web)
set(LIBS ${LIBS} ${LIBSNDFILE_LIBRARY} ${PORTAUDIO_LIBRARIES} ${CURL_LIBRARIES})
file(GLOB_RECURSE sources ${PROJECT_SOURCE_DIR}/src/*.c)
add_executable(Test ${sources})
target_link_libraries(Test ${LIBS})
以下是我的文件夹结构:
Test/
├── .gitignore
├── README
├── CMakeLists.txt
├── src/
│ ├── audio/
│ │ └── ...
│ ├── web/
│ │ └── ...
│ └── ...
├── build/
└── cmake/
├── FindLibSndFile.cmake
└── FindPortaudio.cmake
当我在Mac上编译我的程序时,我进入build/
目录并运行程序生成的cmake ..
:
-- The C compiler identification is Clang 5.1.0
-- The CXX compiler identification is Clang 5.1.0
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found CURL: /usr/lib/libcurl.dylib (found version "7.30.0")
-- Found PkgConfig: /usr/local/bin/pkg-config (found version "0.28")
-- checking for module 'portaudio-2.0'
-- found portaudio-2.0, version 19
-- Found LibSndFile: /usr/local/lib/libsndfile.dylib
-- Configuring done
-- Generating done
-- Build files have been written to: Development/Test/build
一切都运行良好,花花公子。但是,当我将源代码复制到我的Raspberry Pi并重复上述步骤时,它会向我吐出来:
-- The C compiler identification is GNU 4.6.3
-- The CXX compiler identification is GNU 4.6.3
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found CURL: /usr/lib/arm-linux-gnueabihf/libcurl.so (found version "7.26.0")
CMake Error at CMakeLists.txt:7 (find_package):
By not providing "FindPortAudio.cmake" in CMAKE_MODULE_PATH this project
has asked CMake to find a package configuration file provided by
"PortAudio", but CMake did not find one.
Could not find a package configuration file provided by "PortAudio" with
any of the following names:
PortAudioConfig.cmake
portaudio-config.cmake
Add the installation prefix of "PortAudio" to CMAKE_PREFIX_PATH or set
"PortAudio_DIR" to a directory containing one of the above files. If
"PortAudio" provides a separate development package or SDK, be sure it has
been installed.
-- Configuring incomplete, errors occurred!
我不太清楚为什么它不起作用。有什么建议吗?
答案 0 :(得分:3)
Mac不区分大小写,而其他操作系统通常区分大小写。要解决此问题,请更改FindPortaudio.cmake
的文件名 - > FindPortAudio.cmake
(注意音频中的首都A
)。或者在CMakeLists.txt
文件中,将音频中的A
更改为小写字符。即,改变
find_package(PortAudio REQUIRED)
到
find_package(Portaudio REQUIRED)