MantisBT - CMake
View Issue Details
0008758CMakeCMakepublic2009-03-18 10:192016-06-10 14:30
Denis Scherbakov 
Bill Hoffman 
normalminoralways
closedmoved 
CMake-2-6 
 
0008758: CheckSymbolExists does not find a symbol although it exists
There is a symbol (#define) in math.h called fpclassify(x) which returns type of a floating point variable. CheckSymbolExists does not find it.

INCLUDE(CheckSymbolExists)
CHECK_SYMBOL_EXISTS(fpclassify math.h HAVE_FPCLASSIFY)

Below is a code which compiles

/* */
#include <math.h>

void cmakeRequireSymbol(int dummy,...){(void)dummy;}
int main()
{
#ifndef fpclassify
// cmakeRequireSymbol(0,&fpclassify);
#endif

#ifndef fpclassify
  fpclassify_function_does_not_exist();
#else
  puts("Exists.");
#endif

  return 0;
}
CMake 2.6.3
Gentoo Linux
Linux Kernel 2.6.28.x
No tags attached.
txt CMakeLists.txt (330) 2009-03-18 10:19
https://public.kitware.com/Bug/file/2130/CMakeLists.txt
? math.h (15,728) 2009-03-23 05:10
https://public.kitware.com/Bug/file/2136/math.h
Issue History
2009-03-18 10:19Denis ScherbakovNew Issue
2009-03-18 10:19Denis ScherbakovFile Added: CMakeLists.txt
2009-03-18 10:47Denis ScherbakovNote Added: 0015722
2009-03-18 10:55Denis ScherbakovNote Added: 0015723
2009-03-22 22:04Bill HoffmanNote Added: 0015753
2009-03-22 22:04Bill HoffmanStatusnew => assigned
2009-03-22 22:04Bill HoffmanAssigned To => Bill Hoffman
2009-03-23 05:10Denis ScherbakovFile Added: math.h
2009-03-23 05:11Denis ScherbakovNote Added: 0015756
2009-04-27 13:02Denis ScherbakovNote Added: 0016195
2010-01-22 18:48Mateusz LoskotNote Added: 0019280
2016-06-10 14:27Kitware RobotNote Added: 0041517
2016-06-10 14:27Kitware RobotStatusassigned => resolved
2016-06-10 14:27Kitware RobotResolutionopen => moved
2016-06-10 14:30Kitware RobotStatusresolved => closed

Notes
(0015722)
Denis Scherbakov   
2009-03-18 10:47   
Here is unmodified code from /usr/share/cmake/Modules/CheckSymbolExists.cmake which CMake saves as a "CheckSymbolExists.c" file and tries to compile.

/* */
#include <math.h>

void cmakeRequireSymbol(int dummy,...){(void)dummy;}
int main()
{
#ifndef fpclassify
  cmakeRequireSymbol(0,&fpclassify);
#endif
  return 0;
}
(0015723)
Denis Scherbakov   
2009-03-18 10:55   
Originally I found the error on GCC 4.1, but 3.3 and 4.3 also fail.

Quick fix: everywhere in CheckSymbolExists.cmake replace CheckSymbolExists.c with CheckSymbolExists.cpp. I don't know what is the difference, GCC manual says that C and CPP are both preprocessed, but this fix worked for me.

Denis
(0015753)
Bill Hoffman   
2009-03-22 22:04   
.c is a C program and .cpp is a c++ program. So, I am guessing the symbol is not available in C?
(0015756)
Denis Scherbakov   
2009-03-23 05:11   
I uploaded math.h from my linux box, where I see this problem.So far I understand it there is no dependency on C++ anywhere in this file except in one structure.
(0016195)
Denis Scherbakov   
2009-04-27 13:02   
I also wanted to note that some symbols are defined in C, but not defined in C++. On HP-UX on IA64 I've seen:

#if defined(_PA_RISC) || !defined(__cplusplus)
#define fpclassify(x) _FPCLASSIFY(x)
#endif

So it is reasonable to add additional parameter to CHECK_SYMBOL_EXISTS, which defines a language to use (C or C++).
(0019280)
Mateusz Loskot   
2010-01-22 18:48   
Recently, I started thread on the list directly related to this issue:

[CMake] Checking function or symbol in namespace

http://www.cmake.org/pipermail/cmake/2010-January/034718.html [^]

Responses are very informative. Hopefully it will clarify the problem a bit.
(0041517)
Kitware Robot   
2016-06-10 14:27   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.