从列表中的文件剥离绝对路径

时间:2017-11-30 17:22:54

标签: cmake

我想得到一个包含目录及其子目录中所有文件的列表,问题是,我只用它们的绝对路径获取它们。如何删除绝对路径?我试了这个没有成功:

file(GLOB_RECURSE parts chapters/*.tex)

message(STATUS "Remove absolute part of the paths")
foreach (_parts ${parts})
    file(RELATIVE_PATH ${_parts} "/home/user/latex_project/main" ${_parts})
endforeach()

2 个答案:

答案 0 :(得分:1)

正确使用命令:

file(GLOB_RECURSE)

或者只使用file(GLOB_RECURSE parts RELATIVE "/home/user/latex_project/main" chapters/*.tex) RELATIVE 选项:

var example = "0";

function getAsterank(){
//ARRAY OF NEO NAMES
    var xhr = new XMLHttpRequest();
    xhr.open("GET", 'http://asterank.com/api/asterank?query={"full_name": {"$eq" : "(2004 EU22)"}}&limit=5', false);
    xhr.send(null)
    responseData = JSON.parse(xhr.response);
    xhr.abort();

    example = responseData;
}

答案 1 :(得分:0)

尝试这样的事情:

file(GLOB_RECURSE parts chapters/*.tex)

message(STATUS "Remove absolute part of the paths")
set(_tmplist)
foreach (_parts ${parts})
    set(_tmpvar)
    get_filename_component(_tmpvar "${_parts}" NAME)
    list(APPEND _tmplist "${_tmpvar}")
endforeach()
set(parts "${_tmplist}")

get_filename_component()