[CMake] Math lib with CMAKE_REQUIRED_LIBRARIES

Moreland, Kenneth kmorel at sandia.gov
Wed May 4 10:00:19 EDT 2005


If this comes up a lot, perhaps there should be some CMake convention to
handle it.  Could CMake automatically add the math library where
appropriate whenever it links any C or C++ program?

-Ken

> -----Original Message-----
> From: Brad King [mailto:brad.king at kitware.com] 
> Sent: Tuesday, May 03, 2005 1:29 PM
> To: Moreland, Kenneth
> Cc: cmake at www.cmake.org
> Subject: Re: [CMake] Math lib with CMAKE_REQUIRED_LIBRARIES
> 
> Moreland, Kenneth wrote:
> > I'm setting CMAKE_REQUIRED_LIBRARIES and using 
> CHECK_FUNCTION_EXISTS 
> > to test the existence of a function in a library.  However, 
> sometimes 
> > the library in question relies on the math library, which is not 
> > automatically added to the link that CHECK_FUNCTION_EXISTS is using.
> > How do you ensure that the math library is added to the link in a 
> > platform independent way?
> 
> We've seen this problem many times.  Windows runtime 
> libraries always seem to have all the math functions, so we just do
> 
> IF(UNIX)
>    SET(MY_MATH_LIB -lm)
> ELSE(UNIX)
>    SET(MY_MATH_LIB)
> ENDIF(UNIX)
> 
> and then reference ${MY_MATH_LIB}.
> 
> -Brad
> 
> 



More information about the CMake mailing list