首页 > 其他分享 >自动添加子目录

自动添加子目录

时间:2022-11-26 21:55:06浏览次数:67  
标签:set target 子目录 list 添加 自动 subdir child output

转载自:https://www.codeleading.com/article/36054217046/

# 获取目录下的子目录名
# output 子目录名称列表, 填充时不能加${}
# target 目标路径, 全路径
macro(list_subdir output target)
    file(GLOB children ${target}/*)
    set(dir_list "")
    foreach(child ${children})
        file(RELATIVE_PATH child_name ${target} ${child})
        if(IS_DIRECTORY ${target}/${child_name})
            list(APPEND dir_list ${child_name})
        endif()
    endforeach()
    list(APPEND ${output} ${dir_list})
endmacro()

# 判断目录下是否有 CMakeLists
# output 是否含有 CMakeLists.txt, 填充时不能加 ${}
# target 目标路径, 全路径
macro(check_cmakelists output target)
    set(${output} FALSE)
    if(IS_DIRECTORY ${target})
        if(EXISTS ${target}/CMakeLists.txt)
            set(${output} TRUE)
        endif()
    else()
        message(FATAL_ERROR "Invalid dir para: ${target}")
    endif()
endmacro()
 
# 为含有 CMakeList 的子目录添加 add_subdirectory 调用
macro(add_all_subdirs)
    set(subdir_list "")
    list_subdir(subdir_list ${CMAKE_CURRENT_SOURCE_DIR})
    foreach(subdir ${subdir_list})
        set(has_cmakelist FALSE)
        check_cmakelists(has_cmakelist ${CMAKE_CURRENT_SOURCE_DIR}/${subdir})
        if(${has_cmakelist})
            add_subdirectory(${subdir})
        endif()
    endforeach()
endmacro()

标签:set,target,子目录,list,添加,自动,subdir,child,output
From: https://www.cnblogs.com/lonelyraft/p/add_all_subdirs.html

相关文章

  • 重点--自测可以----Java实现微信公众号自动回复
    背景最近准备搭建自己的博客系统,有些软件或资料的下载链接放在网盘中,为了方便下载,同时可以将用户导流到公众号上,因此准备用Java实现微信公众号自动回复的功能准备工作微信......
  • Ubuntu子系统shell脚本自动连接xfce4界面
    脚本功能命令行参数指定ip连接/获取ifconfig中的本地ip连接修改.bashrc#!/bin/bashnet_dev="wifi0"#默认的设备名FALSE="0"TRUE="1"#若无参数则选择本地ipv4......
  • html canvas添加文字(自动换行)
    htmlcanvas添加文字遇到\r换行超过宽度自动换行<html><body><imgwidth="1070"height="1070"id="img"/><scripttype="text/javascript">constcanva......
  • web系统添加盲水印
    前言为增加系统安全性,避免重要敏感信息通过截图方式泄露,对web页面增加盲水印标识,标注系统名称,登陆人,当前时间等信息,这里的盲水印指肉眼不可见的html水印增加水印引入wate......
  • web系统添加盲水印
    前言为增加系统安全性,避免重要敏感信息通过截图方式泄露,对web页面增加盲水印标识,标注系统名称,登陆人,当前时间等信息,这里的盲水印指肉眼不可见的html水印增加水印引入wat......
  • 自动代码生成器类
    packagecode.auto;importcom.baomidou.mybatisplus.core.toolkit.StringPool;importcom.baomidou.mybatisplus.generator.AutoGenerator;importcom.baomidou.myba......
  • win10 家庭版 cmd运行gpedit.msc找不到文件?| 设置开机自动运行批处理脚本
    问题近期win10家庭版笔记本想设置开机自启,运行gpedit.msc直接提示没有gpedit.msc(组策略)场景win10家庭版设置开机自动运行批处理脚本原因win10家庭版本不提供组策略编......
  • ArcMap10.6以上版本添加天地图底图
    文章目录​​申请天地图服务Key​​​​在ArcMap10.7中添加天地图服务​​​​注意点​​申请天地图服务Key天地图​​API​​:​​http://lbs.tianditu.gov.cn/server/MapSe......
  • centos8上使用kubeasz3.0.0项目ansible自动的二进制部署k8s高可用集群
    一、ansible的kubeasz3.0.0部署多master高可用kubernetes集群环境#二进制部署,ansible的kubeasz3.0.0部署多master高可用kubernetes集群环境1.#主机名设置类型服务器I......
  • MFC-给控件添加变量
           ......