zoukankan      html  css  js  c++  java
  • macro example

    macro(getDirRelative result curdir)
        set(result )
        set(dirlist )
        file(GLOB children RELATIVE ${curdir} ${curdir}/*)
        foreach(child ${children})
            if(IS_DIRECTORY ${curdir}/${child})
                list(APPEND dirlist ${child})
            endif()
        endforeach()
        set(${result} ${dirlist})
    endmacro()
    
    macro(getDirRelativeR result curdir)
        set(result )
        set(_file_and_dir )
        set(_file_only )
    
        file(GLOB_RECURSE _file_and_dir LIST_DIRECTORIES true RELATIVE ${curdir} ${curdir}/*)
        file(GLOB_RECURSE _file_only LIST_DIRECTORIES false RELATIVE ${curdir} ${curdir}/*)
    
        foreach(_file ${_file_only})
            list(FIND _file_and_dir ${_file} pos)
            if(pos GREATER -1)
                list(REMOVE_ITEM _file_and_dir ${_file})
            endif()
        endforeach()
    
        set(${result} ${_file_and_dir})
    endmacro()
    
    macro(getDirRelativeRecurByPattern result curdir pattern)
        set(temp )
        set(all_dir )
    
        getDirRelativeR(all_dir ${curdir})
    
        foreach(dir ${all_dir})
            if (${dir} MATCHES ${pattern})
                list(APPEND temp ${dir})
            endif()
        endforeach()
    
        set(${result} ${temp})
    endmacro()
    
    set(dir )
    getDirRelative(dir ${CMAKE_SOURCE_DIR})
    
    set(dirR)
    getDirRelativeR(dirR ${CMAKE_SOURCE_DIR})
    
    set(dirP)
    set(pattern ".*2$")
    getDirRelativeRecurByPattern(dirP ${CMAKE_SOURCE_DIR} ${pattern})
    
    foreach(d ${dirP})
        message(STATUS ${d})
    endforeach()
    
  • 相关阅读:
    16款值得一用的iPhone线框图模板 (PSD & Sketch)
    设计神器
    {CF812}
    hiho1080(多标记线段树)
    {容斥原理}
    {dp入门}
    {AC自动机}
    CF807
    Trie树
    杂记
  • 原文地址:https://www.cnblogs.com/Searchor/p/14176758.html
Copyright © 2011-2022 走看看