[CMake] Confusion on how find_package works.
Michael Jackson
mike.jackson at bluequartz.net
Tue Jan 13 21:11:57 EST 2009
Just making sure it was read. Here is my take line by line from
FindZLIB.cmake
# - Find zlib
# Find the native ZLIB includes and library
#
# ZLIB_INCLUDE_DIR - where to find zlib.h, etc.
# ZLIB_LIBRARIES - List of libraries when using zlib.
# ZLIB_FOUND - True if zlib found.
# Next line checks to see if we have already found zlib.
IF (ZLIB_INCLUDE_DIR)
# Already in cache, be silent
# if zlib was already found then basically turn OFF debug statements
SET(ZLIB_FIND_QUIETLY TRUE)
ENDIF (ZLIB_INCLUDE_DIR)
# Find a path that has the file zlib.h in it and put that path into
# the variable 'ZLIB_INCLUDE_DIR' This will by default search
# all the paths generated by the the following variables:
#-- CMAKE_PREFIX_PATH:
#-- CMAKE_INCLUDE_PATH:
#-- CMAKE_FRAMEWORK_PATH:
#-- The standard system environment variables PATH and INCLUDE
#-- CMAKE_SYSTEM_PREFIX_PATH
#-- CMAKE_SYSTEM_INCLUDE_PATH
#-- CMAKE_SYSTEM_FRAMEWORK_PATH
FIND_PATH(ZLIB_INCLUDE_DIR zlib.h)
# Create a variable to hold the various names that zlib is called on
# the various systems
SET(ZLIB_NAMES z zlib zdll)
# This call works just like the FIND_PATH call except we are giving
# the FIND_LIBRARY command a list of possible names to find in each path
# listed above. If the library is found then the path to the library
# is put into the ZLIB_LIBRARY variable.
FIND_LIBRARY(ZLIB_LIBRARY NAMES ${ZLIB_NAMES} )
# handle the QUIETLY and REQUIRED arguments and set ZLIB_FOUND to TRUE
if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZLIB DEFAULT_MSG ZLIB_LIBRARY
ZLIB_INCLUDE_DIR)
# If we successfully found the zlib library then add the library to the
# ZLIB_LIBRARIES cmake variable otherwise set ZLIB_LIBRARIES to nothing.
IF(ZLIB_FOUND)
SET( ZLIB_LIBRARIES ${ZLIB_LIBRARY} )
ELSE(ZLIB_FOUND)
SET( ZLIB_LIBRARIES )
ENDIF(ZLIB_FOUND)
# Lastly make it so that the ZLIB_LIBRARY and ZLIB_INCLUDE_DIR variables
# only show up under the advanced options in the gui cmake applications.
MARK_AS_ADVANCED( ZLIB_LIBRARY ZLIB_INCLUDE_DIR )
########### END FindZLIB.cmake ###################################
Hope that helps. If you need to see what some variables are set to try
the following:
message (STATUS "CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}")
message (STATUS "CMAKE_INCLUDE_PATH: ${CMAKE_INCLUDE_PATH}")
message (STATUS "CMAKE_FRAMEWORK_PATH: ${CMAKE_FRAMEWORK_PATH}")
message (STATUS "CMAKE_SYSTEM_PREFIX_PATH: ${CMAKE_SYSTEM_PREFIX_PATH}")
message (STATUS "CMAKE_SYSTEM_INCLUDE_PATH: $
{CMAKE_SYSTEM_INCLUDE_PATH}")
message (STATUS "CMAKE_SYSTEM_FRAMEWORK_PATH: $
{CMAKE_SYSTEM_FRAMEWORK_PATH}")
That way you can see exactly where cmake is searching.
---
Mike Jackson www.bluequartz.net
On Jan 13, 2009, at 8:06 PM, Robert Dailey wrote:
> Trust me, I've read this already. It makes no sense to me. How am I
> supposed to know that any of the variables it is checking have been
> set? And if so, where were they set? Could someone give me a summary
> of what find_path is searching in in this specific case?
>
> On Tue, Jan 13, 2009 at 4:20 PM, Michael Jackson <mike.jackson at bluequartz.net
> > wrote:
> From the Help page:
>
> All CMake commands
>
BIG SNIP...
>
> On Jan 13, 2009, at 5:08 PM, Robert Dailey wrote:
>
> Hi,
>
> I'm currently looking at FindZLIB.cmake trying to understand how it
> works and I just can't seem to make sense of it. I have a few
> questions:
> • How does find_path() know where to look? Where is it
> looking? Where is it told where to look?
> • Question #1 with find_library() as well.
> It would be great to be able to set a root directory with all my
> libraries in it and have it recursively go through it and find the
> file it is looking for. This would be a convenient (but slow) way of
> getting find_path() and find_library() to work reliably in my case.
> Thanks in advance for any help.
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
>
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
>
More information about the CMake
mailing list