From 2f26df69c5c601ccd2c3871aabbc6e9ce581ab74 Mon Sep 17 00:00:00 2001 From: eidheim Date: Wed, 16 Nov 2016 00:23:06 +0100 Subject: [PATCH] Corrected order of found executables in CMakeLists.txt files --- src/cmake.cc | 14 ++++++-------- tests/cmake_build_test.cc | 4 ++-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/cmake.cc b/src/cmake.cc index cd6e752..c89759a 100644 --- a/src/cmake.cc +++ b/src/cmake.cc @@ -359,28 +359,26 @@ std::vector > > CMak if(!parsed) parse(); std::vector > > functions; - size_t file_c=0; - for(auto &file: files) { + for(size_t c=files.size()-1;c!=static_cast(-1);--c) { size_t pos=0; - while(posstart_line) { - auto line=file.substr(start_line, end_line-start_line); + auto line=files[c].substr(start_line, end_line-start_line); std::smatch sm; if(std::regex_match(line, sm, function_regex)) { auto data=sm[1].str(); while(data.size()>0 && data.back()==' ') data.pop_back(); auto parameters=get_function_parameters(data); - functions.emplace(functions.begin(), paths[file_c], parameters); + functions.emplace_back(paths[c], parameters); } } pos=end_line+1; } - file_c++; } return functions; } diff --git a/tests/cmake_build_test.cc b/tests/cmake_build_test.cc index 0708f49..eec0908 100644 --- a/tests/cmake_build_test.cc +++ b/tests/cmake_build_test.cc @@ -32,9 +32,9 @@ int main() { auto functions_parameters=cmake.get_functions_parameters("project"); g_assert(functions_parameters.at(0).second.at(0)=="juci"); - g_assert(cmake.get_executable(project_path/"build", tests_path)==project_path/"build"/"tests"/"git_test"); + g_assert(cmake.get_executable(project_path/"build", tests_path)==project_path/"build"/"tests"/"process_test"); g_assert(cmake.get_executable(project_path/"build", tests_path/"cmake_build_test.cc")==project_path/"build"/"tests"/"cmake_build_test"); - g_assert(cmake.get_executable(project_path/"build", tests_path/"non_existing_file.cc")==project_path/"build"/"tests"/"git_test"); + g_assert(cmake.get_executable(project_path/"build", tests_path/"non_existing_file.cc")==project_path/"build"/"tests"/"process_test"); } auto build=Project::Build::create(tests_path);