[CMake] CheckSymbolExists fails with multiple header files
Leif Walsh
leif.walsh at gmail.com
Sat May 12 09:09:55 EDT 2012
M_MMAP_THRESHOLD is #defined in malloc.h, there are no #ifdefs around it. You include that header, you get the symbol, no matter what.
Sent from my iPhone
On May 12, 2012, at 5:27, Andreas Mohr <andi at lisas.de> wrote:
> Hi,
>
> On Fri, May 11, 2012 at 03:41:59PM -0400, cmake-request at cmake.org wrote:
>> Date: Fri, 11 May 2012 13:32:55 -0400
>> From: Leif Walsh <leif.walsh at gmail.com>
>>
>> I want to check whether M_MMAP_THRESHOLD is defined in either malloc.h or sys/malloc.h, and whether CLOCK_REALTIME is defined in either time.h or sys/time.h. I thought this would work:
>>
>> check_symbol_exists(M_MMAP_THRESHOLD "malloc.h;sys/malloc.h" HAVE_M_MMAP_THRESHOLD)
>> check_symbol_exists(CLOCK_REALTIME "time.h;sys/time.h" HAVE_CLOCK_REALTIME)
>>
>> In this case, I found CLOCK_REALTIME but not M_MMAP_THRESHOLD (they both exist on this system, btw).
>
> I don't have much experience in this area, but are you sure
> that M_MMAP_THRESHOLD does indeed exist after including this header
> in an app?
> This may easily be one of the cases where it gets defined by the header
> *only* in case a specific "SDK variant/mode" define was provided by the user.
> (see e.g. the popular case of math.h, where certain defines have to be provided
> before including it, in order to gain access to certain features)
>
> If this is the case here, then CheckSymbolExists.cmake perhaps should be
> extended to document these potential include pre-conditions.
>
>
> The best way to verify define existence would obviously be a more _manual_ compile setup
> of a dummy source plus header include.
>
> Andreas Mohr
More information about the CMake
mailing list