[CMake] How does cmake find libraries?

Alexander Neundorf a.neundorf-work at gmx.net
Thu Jun 16 12:50:13 EDT 2011


On Thursday 16 June 2011, Doug wrote:
> 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?

That's weird, since cmake checks for existing files.
Maybe that file existed before and has been removed, but it is still in the 
cmake cache ?

What does libfind_process() do, what is LibFindMacros.cmake for a file ?

Alex


More information about the CMake mailing list