[英]Can a CMake project in Visual Studio reference source files in a parent folder?
I newbye with Visual Studio / CMake solution that I would like to use to compile on remote Linux OS from a Windows platform.我不熟悉 Visual Studio/CMake 解决方案,我想用它来从 Windows 平台在远程 Linux 操作系统上进行编译。
I have a complex source structure that use C++ file through different folders.我有一个复杂的源结构,它通过不同的文件夹使用 C++ 文件。
/trunk
/trunk/projects/cmake-project1/
/trunk/projects/cmake-project2/
/trunk/src1/
/trunk/src2/
/trunk/src.../
/trunk/external-libs/
My cmake projects are located at /trunk/projects/.我的 cmake 项目位于 /trunk/projects/。 The first project uses some files from src1 and src2 and external-libs, the second project uses different files from src1 and src2 and external-libs...第一个项目使用来自 src1 和 src2 以及外部库的一些文件,第二个项目使用来自 src1 和 src2 以及外部库的不同文件...
Actually it seems that the only way to operate is to copy the required source from src1, src2 to the cmake-project1 and cmake-project2, which is not particularly convenient for the structure lisibility.实际上好像只能把需要的source从src1、src2拷贝到cmake-project1和cmake-project2中,这样对于结构的可读性来说不是特别方便。
But I may be completely wrong about the right approach for this kind of problem!但是对于此类问题的正确方法,我可能完全错了!
Thanks for your suggestion!谢谢你的建议!
Overriding CMAKE_SRC_DIR
seems to work for me:覆盖CMAKE_SRC_DIR
似乎对我CMAKE_SRC_DIR
:
cmake -D CMAKE_SRC_DIR=/path/to/trunk /path/to/trunk/projects/project1
Source file references are by default relative to the CMakeLists.txt;默认情况下,源文件引用相对于 CMakeLists.txt; if this sits within the tree defined by CMAKE_SRC_DIR
it may just work with visual studio.如果它位于CMAKE_SRC_DIR
定义的树中,它可能只适用于 Visual Studio。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.