cmake -E 命令行工具

前言

cmake這個編譯工具提供了執行指令的功能,只要在cmake之後加上-E及欲執行的命令即可。注意cmake支援的命令與linux不完全相通,在使用之前建議先前往cmake - Run a Command-Line Tool查詢用法。

幾個常用指令的demo如下。

常用指令

make_directory

cmake -E make_directory tmp1 tmp2

touch

cmake -E touch parent.txt tmp1/tmp1_file.txt tmp2/tmp1_file.txt tmp2/tmp2_file.txt

經過以上這兩個指令後,目錄結構變成:

.
├── parent.txt
├── tmp1
│   └── tmp1_file.txt
└── tmp2
    ├── tmp1_file.txt
    └── tmp2_file.txt

2 directories, 4 files

chdir

cmake -E chdir tmp1 ls

結果:

tmp1_file.txt

copy

原來的目錄結構為:

├── parent.txt
├── tmp1
│   └── tmp1_file.txt
└── tmp2
    ├── tmp1_file.txt
    └── tmp2_file.txt

2 directories, 4 files

使用copy指令做複製:

cmake -E copy parent.txt tmp1/

之後目錄結構變為:

├── parent.txt
├── tmp1
│   ├── parent.txt
│   └── tmp1_file.txt
└── tmp2
    ├── tmp1_file.txt
    └── tmp2_file.txt

2 directories, 5 files

copy_directory

Copy content of <dir>... directories to <destination> directory. If <destination> directory does not exist it will be created. copy_directory does follow symlinks.

<dir>目錄裡的內容複製到<destination>目錄裡。如果<destination>目錄不存在會自動創建。

原來的目錄結構:

├── parent.txt
├── tmp1
│   ├── parent.txt
│   └── tmp1_file.txt
└── tmp2
    ├── tmp1_file.txt
    └── tmp2_file.txt

2 directories, 5 files

使用copy_directory指令做複製:

cmake -E copy_directory tmp2/ tmp1/

之後目錄結構變為:

.
├── parent.txt
├── tmp1
│   ├── parent.txt
│   ├── tmp1_file.txt
│   └── tmp2_file.txt
└── tmp2
    ├── tmp1_file.txt
    └── tmp2_file.txt

2 directories, 6 files

remove

原來的目錄結構:

.
├── parent.txt
├── tmp1
│   ├── parent.txt
│   ├── tmp1_file.txt
│   └── tmp2_file.txt
└── tmp2
    ├── tmp1_file.txt
    └── tmp2_file.txt

2 directories, 6 files

使用remove指令移除檔案:

cmake -E remove tmp2/tmp1_file.txt tmp1/tmp2_file.txt tmp1/parent.txt

之後目錄結構變為:

.
├── parent.txt
├── tmp1
│   └── tmp1_file.txt
└── tmp2
    └── tmp2_file.txt

2 directories, 3 files

remove_directory

原來的目錄結構:

.
├── parent.txt
├── tmp1
│   └── tmp1_file.txt
└── tmp2
    └── tmp2_file.txt

2 directories, 3 files

使用remove_directory指令移除目錄:

cmake -E remove_directory tmp2

之後目錄結構變為:

.
├── parent.txt
└── tmp1
    └── tmp1_file.txt

1 directory, 2 files
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值