cmake CHECK_INCLUDE_FILE_CXX macro

Hi,

quite some orocos cmake boilerplate code uses the
CHECK_INCLUDE_FILE_CXX macro (the counterpart of the AC_CHECK_HEADER
autoconf macro). Additionally to checking if it can find a header
file, it also tries to compile a file that includes the sought header
file.

However
1/ It seems like this macro does not take into account the environment
variable $CMAKE_INCLUDE_PATH (contrary to the FIND_PATH macro).
2/ Apart from the information found in the manpage, it seems to me
this macro is "virtually undocumented".

only gives me 411 hits, and it seems 95% of them are mailinglist
posts. The rest of them seem to be results from the orocos websvn
:-)
3/ does
not even mention this macro.

Can some cmake guru shed a light on this?

Thx,

Klaas

ps. I'm asking since the macro troubles me for the macosx port of
orocos, see e.g.

ps2. I *really* hate build systems :-)

cmake CHECK_INCLUDE_FILE_CXX macro

On Wednesday 18 June 2008 09:37:17 Klaas Gadeyne wrote:
> Hi,
>
> quite some orocos cmake boilerplate code uses the
> CHECK_INCLUDE_FILE_CXX macro (the counterpart of the AC_CHECK_HEADER

We have our 'own' implementation of this macro in
trunk/rtt/config/CheckIncludeFileCXX.cmake

If you need to honour $CMAKE_INCLUDE_PATH or any other variable, you need to
adapt that macro.

> autoconf macro). Additionally to checking if it can find a header
> file, it also tries to compile a file that includes the sought header
> file.
>
> However
> 1/ It seems like this macro does not take into account the environment
> variable $CMAKE_INCLUDE_PATH (contrary to the FIND_PATH macro).
> 2/ Apart from the information found in the manpage, it seems to me
> this macro is "virtually undocumented".
>
> only gives me 411 hits, and it seems 95% of them are mailinglist
> posts. The rest of them seem to be results from the orocos websvn
>
> :-)
>
> 3/ does
> not even mention this macro.
>
> Can some cmake guru shed a light on this?

This is our documentation:
# - Check if the include file exists.
# CHECK_INCLUDE_FILE_CXX(INCLUDE VARIABLE)
#
# INCLUDE - name of include file
# VARIABLE - variable to return result
#
# An optional third argument is the CFlags to add to the compile line
# or you can use CMAKE_REQUIRED_FLAGS.
#
# The following variables may be set before calling this macro to
# modify the way the check is run:
#
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
# CMAKE_REQUIRED_INCLUDES = list of include directories
#

You could for example change CMAKE_REQUIRED_INCLUDES to default to
CMAKE_INCLUDE_PATH or something similar ?

Peter

cmake CHECK_INCLUDE_FILE_CXX macro

On Mon, Jun 30, 2008 at 4:44 PM, Peter Soetens
<peter [dot] soetens [..] ...> wrote:
> On Wednesday 18 June 2008 09:37:17 Klaas Gadeyne wrote:
>> Hi,
>>
>> quite some orocos cmake boilerplate code uses the
>> CHECK_INCLUDE_FILE_CXX macro (the counterpart of the AC_CHECK_HEADER
>
> We have our 'own' implementation of this macro in
> trunk/rtt/config/CheckIncludeFileCXX.cmake
>
> If you need to honour $CMAKE_INCLUDE_PATH or any other variable, you need to
> adapt that macro.
>
>> autoconf macro). Additionally to checking if it can find a header
>> file, it also tries to compile a file that includes the sought header
>> file.
>>
>> However
>> 1/ It seems like this macro does not take into account the environment
>> variable $CMAKE_INCLUDE_PATH (contrary to the FIND_PATH macro).
>> 2/ Apart from the information found in the manpage, it seems to me
>> this macro is "virtually undocumented".
>>
>> only gives me 411 hits, and it seems 95% of them are mailinglist
>> posts. The rest of them seem to be results from the orocos websvn
>>
>> :-)
>>
>> 3/ does
>> not even mention this macro.
>>
>> Can some cmake guru shed a light on this?
>
> This is our documentation:
> # - Check if the include file exists.
> # CHECK_INCLUDE_FILE_CXX(INCLUDE VARIABLE)
> #
> # INCLUDE - name of include file
> # VARIABLE - variable to return result
> #
> # An optional third argument is the CFlags to add to the compile line
> # or you can use CMAKE_REQUIRED_FLAGS.
> #
> # The following variables may be set before calling this macro to
> # modify the way the check is run:
> #
> # CMAKE_REQUIRED_FLAGS = string of compile command line flags
> # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
> # CMAKE_REQUIRED_INCLUDES = list of include directories
> #
>
> You could for example change CMAKE_REQUIRED_INCLUDES to default to
> CMAKE_INCLUDE_PATH or something similar ?

AFAIS, the orocos implementation of the macro only slightly differs
from the cmake "native" one and my above problems would also occur
using the native macro. To rephrase the question: why does RTT uses
the (slighly modified) CMAKE_CHECK_INCLUDE_CXX macro instead of the
(on all cmake pages advocated, see above )FIND_PATH macro?

Klaas

cmake CHECK_INCLUDE_FILE_CXX macro

On Monday 30 June 2008 17:54:29 Klaas Gadeyne wrote:
>  To rephrase the question: why does RTT uses
> the (slighly modified) CMAKE_CHECK_INCLUDE_CXX macro instead of the
> (on all cmake pages advocated, see above )FIND_PATH macro?

Because of ignorance. Go FIND_PATH. I hate the 'failed once, never check
again' approach of the CMAKE_CHECK_* macros, so a FIND_PATH/FIND_LIBRARY is
perfect for me.

Is a conversion like
CHECK_INCLUDE_FILE_CXX( boost/numeric/ublas/matrix.hpp BOOST )
to
FIND_PATH( BOOST boost/numeric/ublas/matrix.hpp )
sufficient ?

Peter

cmake CHECK_INCLUDE_FILE_CXX macro

On Tue, Jul 1, 2008 at 9:55 AM, Peter Soetens
<peter [dot] soetens [..] ...> wrote:
> On Monday 30 June 2008 17:54:29 Klaas Gadeyne wrote:
>> To rephrase the question: why does RTT uses
>> the (slighly modified) CMAKE_CHECK_INCLUDE_CXX macro instead of the
>> (on all cmake pages advocated, see above )FIND_PATH macro?
>
> Because of ignorance. Go FIND_PATH. I hate the 'failed once, never check
> again' approach of the CMAKE_CHECK_* macros, so a FIND_PATH/FIND_LIBRARY is
> perfect for me.
>
> Is a conversion like
> CHECK_INCLUDE_FILE_CXX( boost/numeric/ublas/matrix.hpp BOOST )
> to
> FIND_PATH( BOOST boost/numeric/ublas/matrix.hpp )
> sufficient ?

This is at least what I used for the initial attempt in porting ocl to
mac os x, see e.g.

As you can see, I added some "find_library" statements too.

So if you want, I can work this out completely on the mac os x
branches and we can merge then later with trunk. Since Mac OS X has a
lot of software installed in non-standard locations, this seems like
the perfect testbed anyway.
Any thoughts?

Klaas

cmake CHECK_INCLUDE_FILE_CXX macro

On Tuesday 01 July 2008 10:20:22 Klaas Gadeyne wrote:
> So if you want, I can work this out completely on the mac os x
> branches and we can merge then later with trunk. Since Mac OS X has a
> lot of software installed in non-standard locations, this seems like
> the perfect testbed anyway.
> Any thoughts?

OK. We can merge these cmake files early on.

Peter

cmake CHECK_INCLUDE_FILE_CXX macro

A Dimecres 18 Juny 2008, Klaas Gadeyne va escriure:
> Hi,
>
> quite some orocos cmake boilerplate code uses the
> CHECK_INCLUDE_FILE_CXX macro (the counterpart of the AC_CHECK_HEADER
> autoconf macro). Additionally to checking if it can find a header
> file, it also tries to compile a file that includes the sought header
> file.
>
> However
> 1/ It seems like this macro does not take into account the environment
> variable $CMAKE_INCLUDE_PATH (contrary to the FIND_PATH macro).
> 2/ Apart from the information found in the manpage, it seems to me
> this macro is "virtually undocumented".
>
> only gives me 411 hits, and it seems 95% of them are mailinglist
> posts. The rest of them seem to be results from the orocos websvn
>
> :-)
>
> 3/ does
> not even mention this macro.
>
> Can some cmake guru shed a light on this?
>
> Thx,
>
> Klaas
>
> ps. I'm asking since the macro troubles me for the macosx port of
> orocos, see e.g.
> >_depend.cmake?op=diff&rev=0&sc=1>
>
> ps2. I *really* hate build systems :-)

Hi Klass,

first of all I'm not a cmake guru so probably there will be another would
answer better.

I have been a bit crazy looking on the CHECK_INCLUDE_FILE_CXX.

I though that it was a problem of looking for a C headers using a C++ macro.
But no, I was wrong. So, looking it deeply I have found that a nice
workaround is use the FIND_PATH macro. In my case, it works ok use:

FIND_PATH(RTAI_INCLUDE_DIR rtai_lxrt.h
PATHS
/usr/realtime/include
/opt/realtime/include
/usr/include/rtai
/opt/rtai)
if(RTAI_INCLUDE_DIR STREQUAL "")
MESSAGE(FATAL_ERROR "-- Looking for LXRT - not found ")
SET(OROPKG_SUPPORT_RTAI FALSE CACHE INTERNAL "" FORCE)
else(RTAI_INCLUDE_DIR STREQUAL "")
MESSAGE("-- Looking for LXRT - found in RTAI_INCLUDE_DIR is
${RTAI_INCLUDE_DIR}")

so, if I would to prepare macros to find soft, I would use FIND_PATH. Also,
searching for that, and reading that you have had problems with the OSX port,
the FindSDL macro have some hits to the OSX platform, that "maybe" could help
you.

Regards,

Leo

--
Linux User 152692
PGP: 0xF944807E
Catalonia