Using pkgconfig to find library
Posted: 2013-03-18T09:03:37-07:00
Couple issues:
- The new library naming scheme presents some difficulties for cmake in finding the library to link to as it does not just use pkgconfig (since it supports platforms without it). Perhaps the pkgconfig file could provide a libname variable that would contain the name? Not sure if there is a standard pkgconfig variable for this.
- Unless the IM headers reference functions in libm, it should not specify it on the link line unless linking privately. Also, wouldn't have to come *after* the ImageMagick library?
This handles these issues:
Finally, any suggestions for determining the library name on Windows?
- The new library naming scheme presents some difficulties for cmake in finding the library to link to as it does not just use pkgconfig (since it supports platforms without it). Perhaps the pkgconfig file could provide a libname variable that would contain the name? Not sure if there is a standard pkgconfig variable for this.
- Unless the IM headers reference functions in libm, it should not specify it on the link line unless linking privately. Also, wouldn't have to come *after* the ImageMagick library?
This handles these issues:
Code: Select all
--- ImageMagick-6.8.3-9/magick/MagickCore.pc.in.libnam 2013-03-04 10:43:46.000000000 -0700
+++ ImageMagick-6.8.3-9/magick/MagickCore.pc.in 2013-03-18 09:58:48.154429878 -0600
@@ -2,9 +2,11 @@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@/ImageMagick-@MAGICK_MAJOR_VERSION@
+libname=MagickCore-@MAGICK_MAJOR_VERSION@.@MAGICK_ABI_SUFFIX@
Name: MagickCore
Description: MagickCore - C API for ImageMagick (ABI @MAGICK_ABI_SUFFIX@)
Version: @PACKAGE_VERSION@
-Libs: -L${libdir} @MATH_LIBS@ -lMagickCore-@MAGICK_MAJOR_VERSION@.@MAGICK_ABI_SUFFIX@
+Libs: -L${libdir} -l${libname}
+Libs.private: -L${libdir} -l${libname} @MATH_LIBS@
Cflags: -I${includedir} @MAGICK_PCFLAGS@
Code: Select all
# pkg-config MagickCore --libs
-lMagickCore-6.Q16
# pkg-config MagickCore --libs --static
-lMagickCore-6.Q16 -lm
# pkg-config MagickCore --variable=libname
MagickCore-6.Q16