[CMake] How does cmake find libraries?

Doug douglas.linder at gmail.com
Wed Jun 15 21:14:05 EDT 2011


I've not had a problem with this before, but I'm having an odd issue where
cmake is finding libpng when it doesn't exist on an OSX machine.

I'm using Findlibpng.cmake:

  include(LibFindMacros)

  find_path(LIBPNG_INCLUDE_DIR NAMES png.h PATHS
${LIBPNG_PKGCONF_INCLUDE_DIRS})

  find_library(LIBPNG_LIBRARY NAMES png PATHS
${LIBPNG_PKGCONF_LIBRARY_DIRS})

  set(LIBPNG_PROCESS_INCLUDES LIBPNG_INCLUDE_DIR)
  set(LIBPNG_PROCESS_LIBS LIBPNG_LIBRARY LIBPNG_LIBRARIES)

  libfind_process(LIBPNG)

And in my cmake file:

  FIND_PACKAGE(libpng REQUIRED)

When I run cmake it says it found LIBPNG (cmake-gui doesn't request I search
for the path manually) and when compile it's erroring:

   [ 74%] Built target test_sethandler
   make[2]: *** No rule to make target `/usr/local/lib/libpng.dylib', needed
by `tests/na/common/test_common'.  Stop.
   make[1]: *** [tests/na/common/CMakeFiles/test_common.dir/all] Error 2

The obvious reason is that /usr/local/lib/libpng.dylib doesn't exist:

  arc:mbuild douglasl$ ls /usr/local/lib/ | grep png
  arc:mbuild douglasl$

But my cmake cache shows:

  LIBPNG_INCLUDE_DIR:PATH=/Library/Frameworks/Mono.framework/Headers
  LIBPNG_LIBRARY:FILEPATH=/usr/local/lib/libpng.dylib
  //ADVANCED property for variable: LIBPNG_INCLUDE_DIR
  LIBPNG_INCLUDE_DIR-ADVANCED:INTERNAL=1
  //ADVANCED property for variable: LIBPNG_LIBRARY
  LIBPNG_LIBRARY-ADVANCED:INTERNAL=1

Can someone shed some light on how cmake is finding that module?

Sounds like the machine config is broken, but I'm not sure exactly how to
fix it.

Cheers,
Doug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110616/44bb1042/attachment.htm>


More information about the CMake mailing list