cmake doesn't follow its own advice :)

Brad King brad.king at kitware.com
Thu Jul 17 02:06:44 CEST 2008


David Faure wrote:
> Running cmake in akonadi says:
> 
> =========
> -- Configuring done
> CMake Warning (dev) at libs/CMakeLists.txt:16 (add_library):
>   Policy CMP0003 should be set before this line.  Add code such as
>  
>     if(COMMAND cmake_policy)
>       cmake_policy(SET CMP0003 NEW)
>     endif(COMMAND cmake_policy)
>  
>   as early as possible but after the most recent call to
>   cmake_minimum_required or cmake_policy(VERSION).  This warning appears
>   because target "akonadiprotocolinternals" links to some libraries for which
>   the linker must search:
>  
>     -lpthread
>  
>   and other libraries with known full path:
>  
>     /usr/lib64/qt4/lib64/libQtCore.so
>  
>   CMake is adding directories in the second list to the linker search path in
>   case they are needed to find libraries from the first list (for backwards
>   compatibility with CMake 2.4).  Set policy CMP0003 to OLD or NEW to enable
>   or disable this behavior explicitly.  Run "cmake --help-policy CMP0003" for
>  more information.
> This warning is for project developers.  Use -Wno-dev to suppress it.
> =========
> 
> Obviously using a full path for libpthread would be the best solution,
> rather than hiding the warning with CMP0003.
> But this comes from cmake itself:
> FindThreads.cmake:        SET(CMAKE_THREAD_LIBS_INIT "-lpthread")
> Shouldn't this look for pthread.so and set the variable to e.g. /usr/lib/libpthread.so,
> to obey the above and avoid the whole issue with -L ordering?

Where in the warning does it say that one should use a full path for
-lpthread?  The fix it suggests has nothing to do with -lpthread.

CMake is warning that it is adding /usr/lib64/qt4/lib64 as a linker
search path in case it is needed to find -lpthread.  In the case of
pthreads, searching for the library and providing a full path is
inappropriate because it is a system library.

The warning check should probably have a special case for known system
libraries like -lpthread and -lm, but this is not a high priority.  In
the future everyone should write

  cmake_minimum_required(VERSION 2.6)

and then this warning will never show up again.

-Brad



More information about the Kde-buildsystem mailing list