[CMake] Checking function or symbol in namespace

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


On 21. Jan, 2010, at 17:17 , Jed Brown wrote:

> 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

Ahh, yes. Obviously didn't think it through... I have to agree, getting this kind of thing to work with C++ is probably not worth the trouble... Better use a check_cxx_source_compiles in the first place for everything C++.

Michael


More information about the CMake mailing list