cmake_minimum_required(VERSION 3.10)
include(FetchContent)
project(qluto4)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
message(STATUS "Fetching libiio from github")
FetchContent_Declare(
libiio
GIT_REPOSITORY https://github.com/analogdevicesinc/libiio
GIT_TAG main
)
include_directories(build/_deps/libiio-build)
FetchContent_MakeAvailable(libiio)
当我想构建这个项目时,它失败并出现以下错误:
...
[ 30%] Built target iio
[ 31%] Building C object _deps/libiio-build/CMakeFiles/iio-compat.dir/compat.c.o
[ 32%] Building C object _deps/libiio-build/CMakeFiles/iio-compat.dir/dynamic-unix.c.o
[ 34%] Linking C shared library iio.framework/iio
Fixup Current symbolic link
/bin/sh: line 0: cd: /Users/myzinsky/Programming/qluto4/build/iio.framework/Versions: No such file or directory
make[2]: *** [_deps/libiio-build/iio.framework/Versions/0.99/iio] Error 1
make[2]: *** Deleting file `_deps/libiio-build/iio.framework/Versions/0.99/iio'
make[1]: *** [_deps/libiio-build/CMakeFiles/iio-compat.dir/all] Error 2
make: *** [all] Error 2
所以看起来 cmake 将生成的框架
iio.framework
放置在它实际期望的地方。我可以在以下位置找到该文件:
build/_deps/libiio-build/iio.framewok
这就是我找到的最终解决方案。
cmake_minimum_required(VERSION 3.30)
project(pluto17)
include(FetchContent)
include(ExternalProject)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
ExternalProject_Add(
libiio
GIT_REPOSITORY https://github.com/analogdevicesinc/libiio
GIT_TAG v0.26
INSTALL_COMMAND ""
)
ExternalProject_Add(
libad9361-iio
GIT_REPOSITORY https://github.com/analogdevicesinc/libad9361-iio
GIT_TAG v0.3
INSTALL_COMMAND ""
CMAKE_ARGS
-DLIBIIO_INCLUDEDIR=${CMAKE_BINARY_DIR}/libiio-prefix/src/libiio/
-DLIBIIO_LIBRARIES=${CMAKE_BINARY_DIR}/libiio-prefix/src/libiio-build/iio.framework/
)
add_executable(pluto17
src/main.cpp
)
add_dependencies(pluto17 libiio libad9361-iio)
target_include_directories(pluto17
PRIVATE ${CMAKE_BINARY_DIR}/libiio-prefix/src/libiio/
)
target_link_libraries(pluto17 PRIVATE ${CMAKE_DL_LIBS})