[CMake] Checking function or symbol in namespace

Mateusz Loskot mateusz at loskot.net
Thu Jan 21 10:44:43 EST 2010


Michael Wild wrote:
> On 21. Jan, 2010, at 24:55 , Mateusz Loskot wrote:
> 
>> Hi,
>> 
>> I'm trying to perform the following checks:
>> 
>> check_function_exists(std::pow HAVE_POW)
>> 
>> or
>> 
>> check_symbol_exists(std::pow cmath HAVE_POW)
>> 
>> but it looks that both macros have troubles with resolving std:: 
>> namespace.
>> 
>> The documentation is not very clear about that.
>> 
>> Or I should stick to try_compile based tests?
>> 
>> Best regards,
>> 
> 
> 
> AFAIK check_symbol_exists is used for preprocessor symbols. 
> check_function_exists looks for C functions, not C++.

OK, makes sense:
symbol -> preprocessor
function -> real function

Although, for clarity, perhaps check_symbol_exists should be
called check_macro_exists.

The fact check_function_exists checks C function but not C++ free
function is a bit confusing. AFAIU, CMake is dedicated to build C++
source code, so I suppose many users may expect it works
well for both C and C++ free functions.

Why it can not work, actually?

> Also notice,  that older C++ standard libraries and non-compliant C++
> compilers don't use the namespace std.  You might want to have a look
> at CMakeBackwardCompatibilityCXX.cmake or the various other modules
> it uses.

Yes, I know this problem quite well.
However, I rarely work with such old or incompatible libraries.
IMHO, CMake should be able to handle standard C++ definitions
and let users to deal with incompatibilities.

Best regards,
-- 
Mateusz Loskot, http://mateusz.loskot.net


More information about the CMake mailing list