From daa35c9e4b592f055b42e482fe1398527cfdf90b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 6 Jun 2019 18:00:10 +0200 Subject: Fix cc link rule matching ambiguity wrt to C/C++ sources Considering a C header as C++ source was definitely a bad idea. --- build2/cc/module.cxx | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'build2/cc/module.cxx') diff --git a/build2/cc/module.cxx b/build2/cc/module.cxx index 7527da2..14d3ceb 100644 --- a/build2/cc/module.cxx +++ b/build2/cc/module.cxx @@ -578,24 +578,32 @@ namespace build2 { using namespace install; - auto& t (rs.target_types); + auto& tts (rs.target_types); - t.insert (x_src); + tts.insert (x_src); - // Note: module (x_mod) is in x_hdr. - - for (const target_type* const* ht (x_hdr); *ht != nullptr; ++ht) + auto insert_hdr = [&rs, &tts, install_loaded] (const target_type& tt) { - t.insert (**ht); + tts.insert (tt); // Install headers into install.include. // if (install_loaded) - install_path (rs, **ht, dir_path ("include")); - } + install_path (rs, tt, dir_path ("include")); + }; + + // Note: module (x_mod) is in x_hdr. + // + for (const target_type* const* ht (x_hdr); *ht != nullptr; ++ht) + insert_hdr (**ht); + + // Also register the C header for C-derived languages. + // + if (*x_hdr != &h::static_type) + insert_hdr (h::static_type); - t.insert (); - t.insert (); + tts.insert (); + tts.insert (); if (install_loaded) install_path (rs, dir_path ("pkgconfig")); -- cgit v1.1