cmake

基础用法

1
2
3
4
5
6
7
8
# 指定 cmake 的最低版本
cmake_minimum_required(VERSION 3.12)

# cmake 的项目名
project(hello)

# 定义可执行输出
add_executable(hello main.cpp)

添加依赖

1
2
3
4
5
6
7
8
9
10
11
cmake_minimum_required(VERSION 3.12)

project(hello)

# 增加依赖的子目录
add_subdirectory(poco)

add_executable(hello main.cpp)

# 给项目增加库链接
target_link_libraries(hello PUBLIC Poco::Foundation Poco::Zip Poco::Net Poco::Util) # replace `...` by all poco library you use

添加外部目录链接

因为外部项目并不在当前目录中,所以需要的一个参数,参考 cmake:用add_subdirectory()添加外部项目文件夹

자세히 보기

MongoDB Tips

关联查询

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
db.task.aggregate([
{ $lookup: {
let: { "modeId":{ "$toObjectId": "$modem" } },
from: "modem",
pipeline: [
{ "$match": { "$expr": { "$eq": [ "$_id", "$$modeId" ] } } }
],
as: "output"
}},
{
$set: {
modem_name: { $arrayElemAt: ["$output.name", 0] }
}
},{
$project: {
output: 0
}
}])