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);