pkg_config quick non intrusive solution
Alexander Neundorf
neundorf at kde.org
Wed Nov 12 22:48:54 CET 2008
On Wednesday 12 November 2008, Helio Chissini de Castro wrote:
> Hi alez
>
> Since you talked about the find_libraries that can make things right, i was
> thinking how to solve the pkg_check_modules issue.
>
> So, testing QCA2 module, i got this:
>
> foreach(ENTRY ${QCA2_LIBRARIES})
> find_library(TMP_LIB NAMES ${ENTRY} PATHS ${QCA2_LIBRARY_DIRS})
> if(QCA2_TMP_LIB AND TMP_LIB)
> set( QCA2_TMP_LIB "${QCA2_TMP_LIB};${TMP_LIB}" )
> else(QCA2_TMP_LIBi AND TMP_LIB)
> set( QCA2_TMP_LIB "${TMP_LIB};" )
> endif(QCA2_TMP_LIB AND TMP_LIB)
> endforeach(ENTRY ${QCA2_LIBRARIES})
> set(QCA2_LIBRARIES ${QCA2_TMP_LIB})
>
> So, i just use find_library to find real libraries iteraction over the
> pkg_config provided ones and at end substitute QCA2_LIBRARIES, providing
> proper /path/to/lib.so
>
> This could be a smal function on our kde modules or even a extra patch for
> next cmake FindPkgconfig .cmake and will get rid of our headaches.
Looks quite ok.
I guess the FIND_LIBRARY() should have the NO_DEFAULT_PATH argument, so it
only looks in the given directories. Or, probably better, use HINTS instead
of PATHS, then the given dirs will be checked before the default dirs.
You can also do
list(APPEND QCA2_TMP_LIB ${TMP_LIB})
then you don't have to check whether QCA2_TMP_LIB is empty or not.
Alex
More information about the Kde-buildsystem
mailing list