我有以下结构Main (dir)
+-- CMakeLists.txt
+-- File.cpp
+-- File.hpp
+-- Dir (dir)
+-- CMakeLists.txt
+-- File1.cpp
+-- File1.hpp
+-- File2.cpp
+-- File2.hpp
main/cmakelists.txtCMAKE_MINIMUM_REQUIRED (VERSION 2.8.11)
PROJECT(Main)
FILE(GLOB SOURCE
"*.hpp"
"*.cpp"
)
ADD_SUBDIRECTORY(Dir)
ADD_EXECUTABLE(Main ${SOURCE})
main/dir/cmakelists.txtFILE(GLOB LOCAL_SOURCE
"*.hpp"
"*.cpp"
)
SET(SOURCE
${SOURCE}
${LOCAL_SOURCE}
PARENT_SCOPE
)
它在visual studio中生成了以下结构
我想要的:
我尝试过的:
main/cmakelists.txtCMAKE_MINIMUM_REQUIRED (VERSION 2.8.11)
PROJECT(Main)
FILE(GLOB LOCAL_SOURCE
"*.hpp"
"*.cpp"
)
SET(SOURCE
${LOCAL_SOURCE}
)
ADD_SUBDIRECTORY(Dir)
SOURCE_GROUP(Main FILES ${LOCAL_SOURCE})
ADD_EXECUTABLE(Main ${SOURCE})
main/dir/cmakelists.txtFILE(GLOB LOCAL_SOURCE
"*.hpp"
"*.cpp"
)
SET(SOURCE
${SOURCE}
${LOCAL_SOURCE}
PARENT_SCOPE
)
SOURCE_GROUP(Dir FILES ${LOCAL_SOURCE})
我得到的信息:
请帮助我。我不想在具有筛选器的主目录中使用单个cmakefile.txt实际结构为多层深嵌套结构。因此,请建议适用于任何级别子目录的解决方案