CMake with include and source paths - basic setup(带有包含和源路径的 CMake - 基本设置)
问题描述
我正在尝试建立一个看起来像我自己的项目的测试项目,只是为了让事情先运行起来,它看起来像这样:
I'm trying to set up a test project looking like my own project just to get things working first and it looks like this:
我找到了一些教程,但是当我有 inc 和 src 文件夹时,我无法找到如何设置它?CMakeLists.txt 文件看起来如何?我会在/中有一个,每个项目文件夹中有一个吗?好像我不需要在 inc 和 src 文件夹中有一个?
I've found some tutorials, but I cant find out how to set up this when I have the inc and src folder? How would the CMakeLists.txt files look? Would I have one in /, one in each of the project folders? It seems like I dont need to have one in the inc and src folders?
推荐答案
对于每个源子目录,您都需要一个 CMakeLists.txt
.您的结构应如下所示:
You need a CMakeLists.txt
for each source subdirectory. Your structure should look something like this:
root/CMakeLists.txt
的内容:
LibProject/CMakeLists.txt
和 MainProject/CMakeLists.txt
的内容:
LibProject/src/CMakeLists.txt
的内容:
MainProject/src/CMakeLists.txt
的内容:
然后配置和构建:
这篇关于带有包含和源路径的 CMake - 基本设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!