我有一个结构如下的项目:
─root
├──src
│ ├──main.cpp
│ └──CMakeLists.txt[2]
├──build
├──out
├──inc
├──dep
│ ├──log
│ │ ├──include
│ │ │ └──log.h
│ │ ├──src
│ │ │ └──log.cpp
│ │ └──CMakeLists.txt[4]
│ └──CMakeLists.txt[3]
└──CMakeLists.txt[1]
在dep
我下面有一个日志记录库,它是一个带有自己CMakeLists.txt
文件的外部git存储库。
主要CMakeLists.txt
(标记为[1])是:
cmake_minimum_required(VERSION 2.6)
set(APP_ROOT ${PROJECT_SOURCE_DIR})
add_subdirectory(dep)
add_subdirectory(src)
CMakeLists.txt
当前项目代码的(标记为[2])是:
add_executable(app main.cpp)
target_link_libraries(app log)
include_directories("${APP_ROOT}/inc")
CMakeLists.txt
依赖项的(标记为[3])是:
add_subdirectory(log)
我想做的是将该dep/log/include
文件夹的内容复制到一个名为的新文件夹中inc/log
,以便main.cpp
我可以编写类似的内容#include <log/log.h>
,但我不知道该如何做。我想避免编辑CMakeLists.txt
logger项目的。
我的解决方案:在/dep/CMakeLists.txt
我添加
file(MAKE_DIRECTORY "${APP_ROOT}/inc/log")
file(COPY "log/include/" DESTINATION "${APP_ROOT}/inc/log")
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句