2017-02-14 56 views
0

我试图从使用CMakeFiles的现有项目导入外部项目。为此,我试图添加一个静态库“.a”和我需要导入的文件。CMake shell查找

我CMakeFiles.txt:

cmake_minimum_required(VERSION 2.8.9)                                    
project(TEST)                                           
set(CMAKE_BUILD_TYPE Release)                                      

#Bring the headers, such as Student.h into the project                                
include_directories(include)                                       

#However,文件(GLOB ...)允许通配符补充:

file(GLOB SOURCES "src/examples/equality_prob/*.cpp" "src/examples/equality_prob/common/*.cpp") 
#Generate the static library from the sources                                  
add_library(testEquality STATIC ${SOURCES})  

直到那里我认为我在r ight方式。但在文件中(GLOB SOURCES,我想添加所有文件* .cpp,* .h等等,其中包含其他文件夹的文件夹

我可以在Makefiles中这样做, :?

$(shell find ${SRC}/examples -type f -name '*.o') 

,但我怎样才能使这个在CMakeFiles

+0

'file(GLOB_RECURSE ...)'? – Florian

回答

1

使用GLOB_RECURSE,而不是可以给你你想要的结果

这不是一个推荐的方法收集的源文件,从GLOBdocumentation(也适用于GLOB_RECURSE):

我们不建议使用GLOB收集源文件的列表,从你的源代码树。如果在添加或删除源时未更改CMakeLists.txt文件,则生成的生成系统无法知道何时要求CMake重新生成。

所以,虽然有点不方便,但最好明确列出构成库的文件。

+0

感谢您的明确回答! – PRVS