[cmake-developers] Adding CheckCXXSymbolsExists.cmake ?

Eric Noulard eric.noulard at gmail.com
Wed Jul 6 18:25:18 EDT 2011


2011/7/6 Alexander Neundorf <neundorf at kde.org>:
> On Wednesday 06 July 2011, Eric Noulard wrote:
>> >
>> > So, just go ahead with adding it as CHECK_CXX_SYMBOL_EXISTS() or
>> > CHECK_SYMBOL_EXISTS_CXX() and if the macro name has no language in it, it
>> > is implicitely C ?
>>
>> I would rather go with a backward compatible option i.e.:
>> No language means C.
>>
>> Note that you'll need name mangling for
>>
>> CMAKE_REQUIRED_xxxx vars too.
>> i.e.
>> CMAKE_CXX_REQUIRED_xxxxx
>
> Hmm, actually I don't think this is necessary.
> Personally I would make sure that CMAKE_REQUIRED_xxx is set appropriately
> before any cmake_check_foo() call.
> (see my other mail about push/pop_required_variables())

Yes right.
The only drawback of the push/pop approach vs language based var is the fact
that you may have to push/pop several time the same var values in
different places. For example, if ever you do

1) test some C feature
2) test some CXX feature
3) test some other C feature
4) test some other CXX feature

In this case you may push the very same value at step 2) and 3),
whereas you did inherit your initial 1) setting for 4) if did not
popped the 1) context.

That said it's not a big deal and for most of the case your approach should be
the more economic one.

May be PUSH/POP could be enhance in order to accept an optional
CONTEXT argument.

MACRO_PUSH_REQUIRED_VARS()
SET(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -DSOME_MORE_DEF)
CHECK_FUNCTION_EXISTS(...)
MACRO_POP_REQUIRED_VARS(CONTEXT MY_C_CHECK)
CHECK_FUNCTION_EXISTS(...)
....other MACRO_POP/PUSH_REQUIRED ...

MACRO_PUSH_REQUIRED_VARS(CONTEXT MY_C_CHECK)
# no set needed because we use the previously defined context
# MY_C_CHECK
CHECK_FUNCTION_EXISTS(...)
MACRO_POP_REQUIRED_VARS()

....

-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org



More information about the cmake-developers mailing list