cmake - 谷歌测试的 CMakeLists.txt 设置
问题描述
我创建了一个 Gtest 脚本,其中包含多个.h
文件并测试文件中的函数.c
。测试脚本在 VS2017 中运行良好,但是,我需要在 Ubuntu 中使用 CMake 构建它。我为我的文件创建了以下文件夹结构,它CMakeLists.txt
在顶层有一个,以及两个源文件夹和测试文件夹,如下所示:
CMakeLists.txt
├── source
│ ├── firstfile.c
│ ├── firstfile.h
│ ├── ...
│ ├── lastfile.c
│ ├── lastfile.h
│ └── CMakeLists.txt
├── test
│ ├── Test.cpp
│ └── CMakeLists.txt
该Test.cpp
文件调用源文件夹中的头文件,并使用 Gtest 测试.c
文件中定义的函数。不熟悉CMake
,请您指导我应该在三个CMakeLists.txt
文件中包含哪些内容?我很感激。
解决方案
推荐阅读
- c# - 尝试从 .NET 4.5 降级到 .NET 4.0 时引发异常
- php - 如果已检查数组的所有值,如何抛出错误?
- c# - PtrToStringUni 在 Windows 10 中不起作用
- android - 如何隐藏所有 ExoPlayer2?
- javascript - 反应状态意外改变
- oracle - 从 oracle 数据库中提取整个模式到另一个(java)(自动化)
- mongodb - 如何在mongodb中加入两个集合
- ios - 如何检查更新是否可用 - Swift 4.2 iOS 12
- javascript - 错误:属性 'require' 的值为 null 或未定义,不是 IE 浏览器 11 中的 Function 对象
- python - spaCy语言模块未下载