[cmake-developers] CheckSymbolExists.cmake

Brad King brad.king at kitware.com
Tue Jun 4 16:17:51 EDT 2013


On 06/04/2013 02:50 PM, Christopher Sean Morrison wrote:
> See the below forwarded message for details on an issue with testing symbols
> that warrants discussion.  Eike patched CheckSymbolExists last year which
> changed it from primarily testing declaration to also enforcing linkage
> (and introducing a ISO C problem in the process).  Even if it fits the
> documented purpose, the method would still need changing due to the error.

The discussion that led to that change was here:

 http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/2523/focus=2530

CheckSymbolExists has always been intended to test decl+linkage except
in the case that the symbol is available as a preprocessor definition.
A success means "I can use this symbol".

CheckFunctionExists tests linkage only with no decl or preprocessor
definition possibility.  Those limitations led to CheckSymbolExists.

> p.s. CHECK_PROTOTYPE_EXISTS is practically useless as written.  I'd submit
> a patch to fix it, but the fix would look nearly identical to what
> CHECK_SYMBOL_EXISTS used to test. 

Perhaps that is the path forward for your need.

>>> We compile strict and the trick used results in a compile error when we
>>> test for the fileno symbol:
>>>
>>> error: ISO C forbids conversion of function pointer to object pointer type

This is a problem because we don't know the type of the symbol.
It could be data or it could be a function.  That's why the old
approach used a "..." argument for it.  Whatever flag you're using
for such strictness could perhaps be stripped for these checks.

>>> There needs to be a simple test that checks if a symbol is
>>> declared with current compilation flags and within specified headers.  Even
>>> the #ifndef wrapper in the test is unnecessary towards that end.

I think that's what CheckPrototypeExists should be.

-Brad



More information about the cmake-developers mailing list