[CMake] Finding libraries under Windows

Mike Jackson imikejackson at gmail.com
Wed May 16 20:53:01 EDT 2007


For zlib you can use the FIND_PACKAGE(Zlib). For others you can make  
up your own scripts. I will include the contents of one I wrote to  
find the HDF libraries. Hope it helps out.


#----------------------------------------------------------------------- 
----
# This will find the HDF5 libraries and define the following variables:
#  HDF5_FOUND - Is the base HDF5 library and include file found
#  HDF5_INCLUDE_DIR - The Include directory containing all the HDF5  
include files
#  HDF5_LIBRARY - The Actual HDF5 library
#  HDF5_HL_FOUND - Is the High Level HDF5 API Found
#  HDF5_HL_INCLUDE_DIR - The High Level Include Directory
#  HDF5_HL_LIBRARY - The Actual High Level Library
#  HDF5_USE_HIGH_LEVEL - Set this to TRUE if you need to link against  
the HDF5 High level APIs.
#  HDF_INSTALL - This is an Environment variable that can be used to  
help find the HDF5 libraries and Include Directories
#  HDF5_LIBRARIES - The List of HDF5 libraries that were found. This  
variable can be used in a LINK_LIBRARIES(...) command

#-- Clear the Library List
SET (HDF5_LIBRARIES "")
#-- Clear the include Directories
SET (HDF5_INCLUDE_DIRS "")

# ------------------ START FIND HDF5 LIBS  
--------------------------------------

SET (HDF5_FOUND "NO")
SET (HDF5_HL_FOUND "NO")

FIND_PATH(HDF5_INCLUDE_DIR hdf5.h
     /usr/local/include
     /usr/include
     "$ENV{HDF_INSTALL}/include"
)

FIND_LIBRARY(HDF5_LIBRARY hdf5
   /usr/local/lib
   /usr/lib
   "$ENV{HDF_INSTALL}/lib"
)

IF (HDF5_INCLUDE_DIR)
   IF (HDF5_LIBRARY)
     SET (HDF5_FOUND "YES")
     SET (HDF5_LIBRARIES ${HDF5_LIBRARY} ${HDF5_LIBRARIES} )
     INCLUDE_DIRECTORIES( ${HDF5_INCLUDE_DIR} )
     MARK_AS_ADVANCED (HDF5_LIBRARY)
      MARK_AS_ADVANCED ( HDF5_INCLUDE_DIR )
   ELSE (HDF5_LIBRARY)
     SET (HDF5_FOUND "NO")
   ENDIF (HDF5_LIBRARY)
ENDIF (HDF5_INCLUDE_DIR)

# ------------------ START FIND HDF5 HL LIBS  
-----------------------------------
IF ( HDF5_USE_HIGH_LEVEL )
   FIND_PATH(HDF5_HL_INCLUDE_DIR H5LT.h
       /usr/local/include
       /usr/include
       "$ENV{HDF_INSTALL}/include"
   )

   FIND_LIBRARY(HDF5_HL_LIBRARY hdf5_hl
     /usr/local/lib
     /usr/lib
     "$ENV{HDF_INSTALL}/lib"
   )

   IF (HDF5_HL_INCLUDE_DIR )
     IF (HDF5_HL_LIBRARY)
       SET (HDF5_HL_FOUND "YES")
       SET (HDF5_LIBRARIES ${HDF5_HL_LIBRARY} ${HDF5_LIBRARIES} )
       INCLUDE_DIRECTORIES( ${HDF5_HL_INCLUDE_DIR} )
	MARK_AS_ADVANCED ( HDF5_HL_INCLUDE_DIR )
	MARK_AS_ADVANCED (HDF5_HL_LIBRARY)
     ELSE (HDF5_HL_LIBRARY)
       SET (HDF5_HL_FOUND "NO")
     ENDIF (HDF5_HL_LIBRARY)
   ENDIF (HDF5_HL_INCLUDE_DIR)
ENDIF ( HDF5_USE_HIGH_LEVEL )

-----------------------------------------
-- 
Mike Jackson   Senior Research Engineer
Innovative Management & Technology Services


On May 16, 2007, at 6:30 PM, Leon Moctezuma wrote:

> Hi all.
>
> I'm Leon Moctezuma, a cs student, who is participating in GSoC and  
> working on Freepv, we are trying to use cmake
> instead of autoconf for the projects building process we have been  
> able to create a basic CMakeLists.txt under both
> Linux and Windows, It works almost fine.
>
> At this point I'm very frustrated, after spending several days  
> trying to find common libraries such as zlib, glut or jpeg
> under Windows, I'm stuck in the same point, I have to indicate  
> where the libraries are using the cmake GUI.
> I've tried to do several things such as adding libraries' paths to  
> lib and include windows' environment variables, I also
> created CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH environment  
> variables and tried to make my own
> FindLibrary.cmake script, but nothing seems to work, could some one  
> guide me, for an example you could use
> zlib... which has zconf.h and zlib.h headers and zlib.dll...
>
> Best Regards.
>
> Leon Moctezuma.
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/cmake/attachments/20070516/47aff946/attachment.htm


More information about the CMake mailing list