Browse Source

Now tries to guess executable based on add_executable parameters

merge-requests/365/head
eidheim 10 years ago
parent
commit
b4e2b2fc80
  1. 25
      src/window.cc

25
src/window.cc

@ -1,4 +1,3 @@
#include "window.h" #include "window.h"
#include "logging.h" #include "logging.h"
#include "config.h" #include "config.h"
@ -8,6 +7,9 @@
#include "dialogs.h" #include "dialogs.h"
#include "filesystem.h" #include "filesystem.h"
#include <iostream> //TODO: remove
using namespace std; //TODO: remove
namespace sigc { namespace sigc {
#ifndef SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH_DECLTYPE #ifndef SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH_DECLTYPE
template <typename Functor> template <typename Functor>
@ -518,11 +520,26 @@ void Window::set_menu_actions() {
return; return;
CMake cmake(cmake_path); CMake cmake(cmake_path);
auto executables = cmake.get_functions_parameters("add_executable"); auto executables = cmake.get_functions_parameters("add_executable");
//Attempt to find executable based add_executable files and opened tab
boost::filesystem::path executable_path; boost::filesystem::path executable_path;
if(executables.size()>0 && executables[0].second.size()>0) { if(notebook.get_current_page()!=-1) {
executable_path=executables[0].first.parent_path(); for(auto &executable: executables) {
executable_path+="/"+executables[0].second[0]; if(executable.second.size()>1) {
for(size_t c=1;c<executable.second.size();c++) {
if(executable.second[c]==notebook.get_current_view()->file_path.filename()) {
executable_path=executable.first.parent_path()/executable.second[0];
break;
}
}
}
if(!executable_path.empty())
break;
}
} }
if(executable_path.empty() && executables.size()>0 && executables[0].second.size()>0)
executable_path=executables[0].first.parent_path()/executables[0].second[0];
if(cmake.project_path!="") { if(cmake.project_path!="") {
if(executable_path!="") { if(executable_path!="") {
compiling=true; compiling=true;

Loading…
Cancel
Save