[geos-devel] [#317] Build configuration for CMake build system

Mateusz Loskot mateusz at loskot.net
Mon Jan 25 17:17:34 EST 2010


Sandro Santilli wrote:
> On Sat, Jan 23, 2010 at 2:40 AM, Mateusz Loskot <mateusz at loskot.net> wrote:
> 
>> The CMakeLists.txt in root was performing incorrect checks.
>> It should be fine now, I hope.
> 
> Still no lack. platform.h dropped, cmake ../trunk re-run.
> The new platform still doesn't contain any valid FINITE function:
> 
> /* Set to 1 if C++/C99 std::isfinite is defined */
> /* #undef HAVE_STD_ISFINITE */
> 
> /* Set to 1 if C99 isfinite is defined */
> /* #undef HAVE_ISFINITE */
> 
> /* Set to 1 if Visual C++ finite is defined */
> /* #undef HAVE_FINITE */
> 
> This is r2888.

Sandro,

Thanks for testing!

The problem is not with CMake, but looks like GCC is a mess :-)

I'm a bit sick of the mess in how GCC handles C and C++ standards, it is
by one big pollution.

I've made a test by compiling this small program with two versions,
fairly close versions, of GCC:

#include <math.h>
#ifdef isfinite
#error isfinite defined
#else
#error isfinite NOT defined
#endif
int main() { return 0; }


1)

mloskot at dog:~/tmp$ gcc --version
gcc (Ubuntu 4.4.1-4ubuntu9) 4.4.1

mloskot at dog:~/tmp$ gcc isfinite.c
isfinite.c:3:2: error: #error isfinite defined
mloskot at dog:~/tmp$


2)

mloskot at vb-ubuntu904:~/tmp$ gcc --version
gcc (Ubuntu 4.3.3-5ubuntu4) 4.3.3

mloskot at vb-ubuntu904:~/tmp$ gcc isfinite.c
isfinite.c:5:2: error: #error isfinite NOT defined

To make it working with GCC 4.3, one has to specify -std=c99 option.

3) What should we expect from GCC 4.5 ?


Getting used to default behaviour of GCC from version to version
is like chasing my own tail :-)
I tried to force the isfinite with definitiosn of __USE_ISOC99 or
_GNU_SOURCE but it doesn't help. I'll have to figure out best platform
and GCC version independent option.

The simplest one would be to define something like this:

inline bool isfinite(double v)
{
   return v >= -(std::numeric_limits<double>::max)()
       && v <=  (std::numeric_limits<double>::max)();
}

but I'm concerned if it is robust enough on variety of platforms.

Best regards,
-- 
Mateusz Loskot, http://mateusz.loskot.net
Charter Member of OSGeo, http://osgeo.org


More information about the geos-devel mailing list