From 75ac11e77790ec74004e12c813448479f9ce1171 Mon Sep 17 00:00:00 2001 From: eidheim Date: Wed, 23 Sep 2015 10:31:09 +0200 Subject: [PATCH] Now creates compile_commands if missing when opening a file in a project. --- src/notebook.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/notebook.cc b/src/notebook.cc index facb803..d9e28b9 100644 --- a/src/notebook.cc +++ b/src/notebook.cc @@ -67,8 +67,11 @@ void Notebook::open(const boost::filesystem::path &file_path) { auto language=Source::guess_language(file_path); if(language && (language->get_id()=="chdr" || language->get_id()=="c" || language->get_id()=="cpp" || language->get_id()=="objc")) { boost::filesystem::path project_path; - if(directories.cmake && directories.cmake->project_path!="" && file_path.generic_string().substr(0, directories.cmake->project_path.generic_string().size()+1)==directories.cmake->project_path.generic_string()+'/') + if(directories.cmake && directories.cmake->project_path!="" && file_path.generic_string().substr(0, directories.cmake->project_path.generic_string().size()+1)==directories.cmake->project_path.generic_string()+'/') { project_path=directories.cmake->project_path; + if(boost::filesystem::exists(project_path.string()+"/CMakeLists.txt") && !boost::filesystem::exists(project_path.string()+"/compile_commands.json")) + CMake::create_compile_commands(project_path); + } else { project_path=file_path.parent_path(); CMake cmake(project_path);