Making non-standard OS checks in cmake?

Raphael Kubo da Costa kubito at gmail.com
Fri Jan 1 19:22:15 CET 2010


On Friday 01 January 2010 16:01:14 Alexander Neundorf wrote:
> On Friday 01 January 2010, Raphael Kubo da Costa wrote:
> > Hey there,
> > 
> > As you can see on my.cdash.org, both kdeadmin and kdenetwork fail to
> > build
> > 
> > cleanly on FreeBSD:
> >  * kdeadmin/kuser's CMakeLists.txt's check for the need to link against -
> > 
> > lcrypt is broken on FreeBSD,  since the crypt() function is defined in
> > unistd.h, not crypt.h, even though -lcrypt still must be passed to the
> > compiler
> 
> Does crypt.h also exist ?
> You could also try check_symbol_exists() (
> http://www.cmake.org/cmake/help/cmake2.6docs.html#module:CheckSymbolExists
> ) to find out whether crypt() is in unistd.h or crypt.h
No, crypt.h doesn't exist. Would check_symbol_exists() not work then? How 
about using check_library_exists()?

> >  * kdenetwork/kppp has been broken since FreeBSD 8.0 - currently the
> >  ports
> > 
> > system just disable its build, and I'd like to do the same upstream.
> > In both cases (the former can actually be solved in a different way, but
> > I have felt the need for this in other cases as well), it would be
> > useful to know if the current OS is FreeBSD, just like APPLE, WIN32 or
> > UNIX are set. Is there an easy way to do that?
> 
> Yes, you can test
> if (${CMAKE_SYSTEM_NAME} STREQUAL FreeBSD)
> 
> (instead of STREQUAL you could also use MATCHES, depending on what you want
> to test, e.g. ... MATCHES BSD to check for multiple BSDs).
> 
> The names are the names of the platform files in
> share/cmake-2.6/Modules/Platform/.

I see. It would be nice if there was a way to check if FreeBSD's version is >= 
8.0, since apparently kppp works until version 7.x. The ports system checks if 
the __FreeBSD_version macro, defined in sys/param.h, is >= 800074, but that's 
not portable for us. In this case, do you recommend always disabling kppp and 
leaving it up to the ports maintainers to enable it if __FreeBSD_version < 
800074?


More information about the Kde-buildsystem mailing list