[CMake] check_function_exists frailty

Eric Noulard eric.noulard at gmail.com
Wed Jan 19 04:27:00 EST 2011


2011/1/19 Jack Poulson <jack.poulson at gmail.com>:
> I have no idea why this would occur, but with CMake 2.8.2 on x86_64 I'm
> getting strange behavior with check_function_exists. Namely, if I perform
> the sequence
> set(CMAKE_REQUIRED_LIBRARIES ${MATH_LIBS})
> check_function_exists(daxpy HAVE_DAXPY)
> whether or not /usr/lib/libpthread.a or /usr/lib/libpthread.so is in the
> list changes the answer, even though daxpy is defined in a completely
> different library!
> Output with libpthread.so:
> --
> MATH_LIBS=/opt/intel/Compiler/11.1/072/mkl/lib/em64t/libmkl_scalapack_lp64.a;/opt/intel/Compiler/11.1/072/mkl/lib/em64t/libmkl_blacs_lp64.a;/opt/intel/Compiler/11.1/072/mkl/lib/em64t/libmkl_intel_lp64.a;/opt/intel/Compiler/11.1/072/mkl/lib/em64t/libmkl_intel_thread.a;/opt/intel/Compiler/11.1/072/mkl/lib/em64t/libmkl_core.a;/opt/intel/Compiler/11.1/072/lib/intel64/libguide.a;/opt/intel/Compiler/11.1/072/lib/intel64/libiomp5.a;/usr/lib/libpthread.so
> -- Looking for daxpy
> -- Looking for daxpy - found
> Output with libpthread.a:
> --
> MATH_LIBS=/opt/intel/Compiler/11.1/072/mkl/lib/em64t/libmkl_scalapack_lp64.a;/opt/intel/Compiler/11.1/072/mkl/lib/em64t/libmkl_blacs_lp64.a;/opt/intel/Compiler/11.1/072/mkl/lib/em64t/libmkl_intel_lp64.a;/opt/intel/Compiler/11.1/072/mkl/lib/em64t/libmkl_intel_thread.a;/opt/intel/Compiler/11.1/072/mkl/lib/em64t/libmkl_core.a;/opt/intel/Compiler/11.1/072/lib/intel64/libguide.a;/opt/intel/Compiler/11.1/072/lib/intel64/libiomp5.a;/usr/lib/libpthread.a
> -- Looking for daxpy
> -- Looking for daxpy - not found
>
> Any ideas what would be causing this strange behavior? And while I'm on the
> subject, should check_function_exist work with dynamic libraries? I had to
> give up some portability and force find_library to search for the static MKL
> libraries just to get the libpthread.so case to work.
> I apologize in advance if I've missed something obvious...

May be you have an implicit dependency on dynamic pthread somewhere.
Are you using icc or gcc ?

As far as I remember check_function_exists is using try_compile.
May be you can try to run CMake with

--debug-trycompile and look into files

I don't remember where they are... but I'm sure someone will tell you that.

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


More information about the CMake mailing list