CMake shell find
CMake shell find
我正在尝试从使用 CMakeFiles 的现有项目导入外部项目。为此,我正在尝试添加一个静态库".a",其中包含导入所需的文件。
我的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})
直到在那里,我认为我的方式是正确的。但是在文件(GLOB SOURCES,我想添加一个包含其他文件夹的文件夹的所有文件*.cpp,*.h等。
我可以用这样的东西在 Makefiles 中做到这一点:
$(shell find ${SRC}/examples -type f -name '*.o')
但是我如何在 CMakeFiles 中做到这一点?
改用GLOB_RECURSE
可能会给你你想要的结果。
但
这不是从GLOB
文档中收集源文件的推荐方法(也适用于GLOB_RECURSE
(:
我们不建议使用 GLOB 从源树中收集源文件列表。如果没有 CMakeLists.txt则在添加或删除源时文件会更改,则生成的生成系统无法知道何时要求 CMake 重新生成。
因此,尽管有点不方便,但最好明确列出构成库的文件。
相关文章:
- std::map<struct,struct>::find 找不到匹配项,但是如果我循环通过 begin() 到 end(),我在那里看到匹配项
- 如何通过cpp程序运行shell脚本
- 如何将c++程序的一些输出传递给shell,以便在shell中使用
- OpenMP卸载说'fatal error: could not find accel/nvptx-none/mkoffload'
- shell排序中的交换和比较
- 使用.find函数在c++中查找字符和另一个字符之间的大小
- 在 QVector<std::unique_ptr 上使用 std::find<Type>>
- 错误"Could not find Boost"(缺少:上下文标头)
- /usr/bin/ld: cannot find -lc++
- std::find,返回所有找到的值的替代方法,而不仅仅是存在重复的向量的第一个值
- 我适合在我的构建系统中使用 shell 脚本而不是AX_CHECK_COMPILE_FLAG吗?
- 使用 find 解析文件会给出不同文件的奇怪结果
- 在 ifcondition al中 find() C++ STL 中的 == a.end() 有什么用?
- Cannot find -lglad
- "Cannot find -l<directory>"错误 - CMake
- 为什么在向量上使用 std::find() 时会出现错误?
- 为什么映射插入和 map.find() 的单次迭代比插入和 map.find() 的两次单独迭代慢得多
- C++ find() 在存储为变量时返回不同的值
- set::find 查找不存在的元素
- CMake shell find