[CMake] Checking function or symbol in namespace

Jed Brown jed at 59A2.org
Thu Jan 21 11:17:55 EST 2010


On Thu, 21 Jan 2010 17:03:27 +0100, Michael Wild <themiwi at gmail.com> wrote:
> 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.

You're kidding, right?  Have you looked at CheckFunctionExists.c?  It
declares the symbol as

  char SYMBOL_NAME();

and then tries to link a program that calls this function.  No headers
are included, so there is no way for this symbol to match the mangled
symbol in the library.

Of course, you could write a completely different thing with an
interface more like check_cxx_source_compiles, and call this new thing
check_cxx_function_exists, but that would be terribly inconsistent so I
hope you don't.

Jed


More information about the CMake mailing list