diff --git a/src/dds/toolchain/toolchain.cpp b/src/dds/toolchain/toolchain.cpp index e7ac0228..25cbbd6d 100644 --- a/src/dds/toolchain/toolchain.cpp +++ b/src/dds/toolchain/toolchain.cpp @@ -102,6 +102,17 @@ vector toolchain::definition_args(std::string_view s) const noexcept { vector toolchain::create_compile_command(const compile_file_spec& spec) const noexcept { vector flags; + language lang = spec.lang; + if (lang == language::automatic) { + if (spec.source_path.extension() == ".c" || spec.source_path.extension() == ".C") { + lang = language::c; + } else { + lang = language::cxx; + } + } + + auto& cmd_template = lang == language::c ? _c_compile : _cxx_compile; + for (auto&& inc_dir : spec.include_dirs) { auto inc_args = include_args(inc_dir); extend(flags, inc_args); @@ -117,7 +128,7 @@ vector toolchain::create_compile_command(const compile_file_spec& spec) } vector command; - for (auto arg : _cxx_compile) { + for (auto arg : cmd_template) { if (arg == "") { extend(command, flags); } else {