我具有以下文件夹结构:
Arrayhelper CMakeLists.txt
cmake_minimum_required (VERSION 3.8)
add_library(arrayhelper src/arrayhelper.cpp src/arrayhelper.h)
target_include_directories(arrayhelper PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src")
target_link_libraries(arrayhelper PUBLIC network neuralmath)
网络CMakeLists.txt
cmake_minimum_required (VERSION 3.8)
add_library(
network
src/layer.cpp
src/layer.h
src/network.cpp
src/network.h
)
target_include_directories(network PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src")
target_link_libraries(network PUBLIC arrayhelper neuralmath)
神经数学CMakeLists.txt
cmake_minimum_required (VERSION 3.8)
add_library(
neuralmath
src/functions.cpp
src/functions.h
src/matrix.cpp
src/matrix.h
)
target_include_directories(neuralmath PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src")
target_link_libraries(neuralmath PUBLIC arrayhelper)
主要CMakeLists.txt
cmake_minimum_required (VERSION 3.8)
add_subdirectory(arrayhelper)
add_subdirectory(neuralmath)
add_subdirectory(network)
add_executable(main main.cpp main.h)
set(INSTALL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/dist/")
target_link_libraries(main PUBLIC neuralmath arrayhelper network)
我在代码中没有看到任何错误,并且我再次检查了错误。我遵循了此指南:https://www.youtube.com/watch?v=SYgESCQeGJY
答案 0 :(得分:0)
我不知道这是否可以解决您的问题,但您要介绍的是circular dependency。
在arrayhelper
的CMakeLists.txt中,您链接到network
和neuralmath
。
在network
和neuralmath
的链接中。您针对arrayhelper
链接的CMakeLists.txt。
我很惊讶CMake甚至正确地解析了它。