[CMake] Checking function or symbol in namespace

Michael Wild themiwi at gmail.com
Thu Jan 21 11:03:27 EST 2010


On 21. Jan, 2010, at 16:57 , Jed Brown wrote:

> On Thu, 21 Jan 2010 15:44:43 +0000, Mateusz Loskot <mateusz at loskot.net> wrote:
>> Why it can not work, actually?
> 
> C++ does name mangling so it's difficult to determine what the symbol
> actually is (you have to know about various classes and templates that
> may be in scope), therefore the interface would look a bit different.
> In particular, it would require locating and including headers because
> "private" details of a template library can change how the symbol is
> mangled.
> 
> It's almost certainly the case that it works for C because it's easy to
> make work for C, and not for C++ because that would be hard, and you
> probably need to use check_cxx_source_compiles/check_cxx_source_runs in
> order to find a C++ symbol anyway.
> 
> Jed

But both of them just do a try_compile. I don't see where the name-mangling comes in there... If the user wants to check for a template, he has to instantiate the template, e.g. check_cxx_function_exists("std::copy<std::string::const_iterator, std::string::iterator>" "algorithm;string" HAVE_STD_COPY). Tedious, but should work. To check for classes, you'd need a different macro, however.


Michael


More information about the CMake mailing list