From b11494b15d1752c33b8fcd6ec1aa586ef1c5849e Mon Sep 17 00:00:00 2001 From: Ole Christian Eidheim Date: Fri, 18 Dec 2015 11:53:56 +0100 Subject: [PATCH] Cleanup of cmake project search, no longer tried to search for cmakelists if starting/reaching a directory without cmakelists --- src/cmake.cc | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/src/cmake.cc b/src/cmake.cc index 0ca58db..620575f 100644 --- a/src/cmake.cc +++ b/src/cmake.cc @@ -17,25 +17,21 @@ CMake::CMake(const boost::filesystem::path &path) { }; auto search_path=path; - auto search_cmake_path=search_path; - search_cmake_path+="/CMakeLists.txt"; - if(boost::filesystem::exists(search_cmake_path)) - paths.emplace(paths.begin(), search_cmake_path); - if(find_cmake_project(search_cmake_path)) - project_path=search_path; - else { - do { - search_path=search_path.parent_path(); - search_cmake_path=search_path; - search_cmake_path+="/CMakeLists.txt"; - if(boost::filesystem::exists(search_cmake_path)) - paths.emplace(paths.begin(), search_cmake_path); - if(find_cmake_project(search_cmake_path)) { - project_path=search_path; - break; - } - } while(search_path!=search_path.root_directory()); + while(true) { + auto search_cmake_path=search_path/"CMakeLists.txt"; + if(boost::filesystem::exists(search_cmake_path)) + paths.emplace(paths.begin(), search_cmake_path); + else + break; + if(find_cmake_project(search_cmake_path)) { + project_path=search_path; + break; + } + if(search_path==search_path.root_directory()) + break; + search_path=search_path.parent_path(); } + if(!project_path.empty()) { if(boost::filesystem::exists(project_path/"CMakeLists.txt") && !boost::filesystem::exists(project_path/"compile_commands.json")) create_compile_commands(project_path);