From b2593723d0c5c1b2dcd9b577c94c3a089b7c638c Mon Sep 17 00:00:00 2001 From: eidheim Date: Thu, 16 May 2019 09:15:21 +0200 Subject: [PATCH] Cmake and meson: when no executable is found, look in src-folder if any --- src/project_build.cc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/project_build.cc b/src/project_build.cc index d9aa6a9..b2c7fb3 100644 --- a/src/project_build.cc +++ b/src/project_build.cc @@ -103,7 +103,14 @@ std::string Project::CMakeBuild::get_compile_command() { } boost::filesystem::path Project::CMakeBuild::get_executable(const boost::filesystem::path &path) { - return cmake.get_executable(get_default_path(), path).string(); + auto default_path = get_default_path(); + auto executable = cmake.get_executable(default_path, path); + if(executable.empty()) { + auto src_path = project_path / "src"; + if(boost::filesystem::is_directory(src_path)) + executable = cmake.get_executable(default_path, src_path); + } + return executable; } Project::MesonBuild::MesonBuild(const boost::filesystem::path &path) : Project::Build(), meson(path) { @@ -123,7 +130,14 @@ std::string Project::MesonBuild::get_compile_command() { } boost::filesystem::path Project::MesonBuild::get_executable(const boost::filesystem::path &path) { - return meson.get_executable(get_default_path(), path); + auto default_path = get_default_path(); + auto executable = meson.get_executable(default_path, path); + if(executable.empty()) { + auto src_path = project_path / "src"; + if(boost::filesystem::is_directory(src_path)) + executable = meson.get_executable(default_path, src_path); + } + return executable; } Project::CompileCommandsBuild::CompileCommandsBuild(const boost::filesystem::path &path) {