【cmake】add_custom_target

centos7仓库配置

add_custom_target 是 CMake 中用于创建自定义目标的命令,它允许你定义不会生成文件的目标,主要用于执行特定的命令或脚本。

add_custom_target(Name [ALL] [command1 [args1...]]
                  [COMMAND command2 [args2...] ...]
                  [DEPENDS depend depend depend ... ]
                  [BYPRODUCTS [files...]]
                  [WORKING_DIRECTORY dir]
                  [COMMENT comment]
                  [JOB_POOL job_pool]
                  [VERBATIM] [USES_TERMINAL]
                  [COMMAND_EXPAND_LISTS]
                  [SOURCES src1 [src2...]])

主要参数说明

  • Name: 目标名称
  • ALL: 如果指定,该目标会被包含在默认构建中
  • COMMAND: 要执行的命令
  • DEPENDS: 依赖的文件或目标
  • WORKING_DIRECTORY: 命令执行的工作目录
  • COMMENT: 构建时显示的注释
  • VERBATIM: 确保参数正确传递给命令
  • SOURCES: 关联的源文件(用于 IDE 显示)

 

默认仓库:

-rw-r--r--. 1 root root 1664 Oct 23  2020 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 Oct 23  2020 CentOS-CR.repo
-rw-r--r--. 1 root root  649 Oct 23  2020 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  314 Oct 23  2020 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 Oct 23  2020 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 Oct 23  2020 CentOS-Sources.repo
-rw-r--r--. 1 root root 8515 Oct 23  2020 CentOS-Vault.repo
-rw-r--r--. 1 root root  616 Oct 23  2020 CentOS-x86_64-kernel.repo

1. 配置epel源

##  使用阿里提供的epel源
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

2. 配置CentOS-SCLo-rh源:

# vim CentOS-SCLo-rh.repo
[centos-sclo-rh]
name=CentOS-7 - SCLo rh
baseurl=https://mirrors.aliyun.com/centos/7/sclo/x86_64/rh/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo

安装gcc-11、g++-11:

yum install devtoolset-11-gcc.x86_64 devtoolset-11-gcc-c++.x86_64 
scl enable devtoolset-11 bash //或者 source /opt/rh/devtoolset-11/enable

3. 替换Base源为阿里源:

##  备份 /etc/yum.repos.d/CentOS-Base.repo
sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
##  更换为阿里源
sudo curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

4. 配置ceph源:

# cat storage.repo 
[storage]
name=CentOS-7 - storage
baseurl=https://mirrors.aliyun.com/centos/7/storage/x86_64/ceph-nautilus
gpgcheck=0
enabled=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official

参考资料

1. Centos7的yum使用国内源阿里源163源等提高下载速度

2. centos 7 更换为阿里云yum源

 

posted @ 2021-11-09 21:22  苏格拉底的落泪  阅读(81)  评论(0)    收藏  举报