Browse Source

CMake build paths cleanup

merge-requests/365/head
eidheim 10 years ago
parent
commit
18748aed24
  1. 12
      src/cmake.cc
  2. 6
      src/source_clang.cc

12
src/cmake.cc

@ -36,6 +36,9 @@ CMake::CMake(const boost::filesystem::path &path) {
} }
boost::filesystem::path CMake::get_default_build_path(const boost::filesystem::path &project_path) { boost::filesystem::path CMake::get_default_build_path(const boost::filesystem::path &project_path) {
if(!boost::filesystem::exists(project_path/"CMakeLists.txt"))
return boost::filesystem::path();
boost::filesystem::path default_build_path=Config::get().terminal.default_build_path; boost::filesystem::path default_build_path=Config::get().terminal.default_build_path;
const std::string path_variable_project_directory_name="<project_directory_name>"; const std::string path_variable_project_directory_name="<project_directory_name>";
@ -65,6 +68,9 @@ boost::filesystem::path CMake::get_default_build_path(const boost::filesystem::p
} }
boost::filesystem::path CMake::get_debug_build_path(const boost::filesystem::path &project_path) { boost::filesystem::path CMake::get_debug_build_path(const boost::filesystem::path &project_path) {
if(!boost::filesystem::exists(project_path/"CMakeLists.txt"))
return boost::filesystem::path();
boost::filesystem::path debug_build_path=Config::get().terminal.debug_build_path; boost::filesystem::path debug_build_path=Config::get().terminal.debug_build_path;
const std::string path_variable_project_directory_name="<project_directory_name>"; const std::string path_variable_project_directory_name="<project_directory_name>";
@ -109,9 +115,6 @@ bool CMake::create_default_build(const boost::filesystem::path &project_path, bo
if(project_path.empty()) if(project_path.empty())
return false; return false;
if(!boost::filesystem::exists(project_path/"CMakeLists.txt"))
return false;
auto default_build_path=get_default_build_path(project_path); auto default_build_path=get_default_build_path(project_path);
if(default_build_path.empty()) if(default_build_path.empty())
return false; return false;
@ -150,9 +153,6 @@ bool CMake::create_debug_build(const boost::filesystem::path &project_path) {
if(project_path.empty()) if(project_path.empty())
return false; return false;
if(!boost::filesystem::exists(project_path/"CMakeLists.txt"))
return false;
auto debug_build_path=get_debug_build_path(project_path); auto debug_build_path=get_debug_build_path(project_path);
if(debug_build_path.empty()) if(debug_build_path.empty())
return false; return false;

6
src/source_clang.cc

@ -182,11 +182,7 @@ void Source::ClangViewParse::soft_reparse() {
} }
std::vector<std::string> Source::ClangViewParse::get_compilation_commands() { std::vector<std::string> Source::ClangViewParse::get_compilation_commands() {
boost::filesystem::path default_build_path; clang::CompilationDatabase db(CMake::get_default_build_path(project_path).string());
if(boost::filesystem::exists(project_path/"CMakeLists.txt"))
default_build_path=CMake::get_default_build_path(project_path);
clang::CompilationDatabase db(default_build_path.string());
clang::CompileCommands commands(file_path.string(), db); clang::CompileCommands commands(file_path.string(), db);
std::vector<clang::CompileCommand> cmds = commands.get_commands(); std::vector<clang::CompileCommand> cmds = commands.get_commands();
std::vector<std::string> arguments; std::vector<std::string> arguments;

Loading…
Cancel
Save