[CMake] CHECK_FUNCTION_EXISTS for pthread_spin_init

Brantner Matthias brantner at m-brantner.de
Thu Feb 28 09:21:50 EST 2008


Hi,

I wanted to write a check whether pthread_mutex_init and  
pthread_spin_init exist in pthread.h. Therefore,
I used the following CMake commands:

INCLUDE(CheckFunctionExists)
CHECK_FUNCTION_EXISTS("pthread_spin_init"            
HAVE_PTHREAD_SPINLOCK)
CHECK_FUNCTION_EXISTS("pthread_mutex_init"        HAVE_PTHREAD_MUTEX)

The result of running CMake on a Linux system gives me

-- Looking for pthread_spin_init
-- Looking for pthread_spin_init - not found
-- Looking for pthread_mutex_init
-- Looking for pthread_mutex_init - found.

Although pthread_spin_init is declared in my pthread.h and my code  
compiles and uses it, CMake does not find it.
However, I saw that this function is guarded in an "#ifdef  
__USE_XOPEN2K". Could that be the reason why
CMake doesn't find it or am I doing something wrong here?

Thanks in advance.

Matthias



More information about the CMake mailing list