[CMake] Re: Finding libraries under Windows

Bill Hoffman bill.hoffman at kitware.com
Thu May 17 08:01:13 EDT 2007


Leon Moctezuma wrote:
> Thanks Brandon and Mike
>
> I did something similar to Mike's code adn this wiki page[1 
> <http://www.cmake.org/Wiki/CMake_HowToFindInstalledSoftware>].
> I could see different things in Chiken, that helped me to understand 
> cmake better.
>
> Here is the script:
>
> IIF(WIN32)
>     FIND_PATH(FREEGLUT_INCLUDE_DIR GL/freeglut.h ${CMAKE_INCLUDE_PATH} 
> $ENV{include} ${OPENGL_INCLUDE_DIR})
>     FIND_LIBRARY(FREEGLUT_LIBRARY NAMES freeglut_static PATH 
> ${CMAKE_LIBRARY_PATH} $ENV{lib})
> ELSE(WIN32)
>     FIND_PATH(FREEGLUT_INCLUDE_DIR GL/freeglut.h /usr/include 
> /usr/local/include)
>     FIND_LIBRARY( FREEGLUT_LIBRARY NAMES freeglut glut
>               /usr/lib
>               /usr/local/lib
>         )
> ENDIF(WIN32)
>
> IF (FREEGLUT_INCLUDE_DIR AND FREEGLUT_LIBRARY)
>    SET(FREEGLUT_FOUND TRUE)
> ENDIF (FREEGLUT_INCLUDE_DIR AND FREEGLUT_LIBRARY)
>
> IF(NOT FREEGLUT_FOUND)
>    IF (FREEGLUT_FIND_REQUIRED)
>       MESSAGE(FATAL_ERROR "Could not find FREEGLUT")
>    ENDIF (FREEGLUT_FIND_REQUIRED)
> ENDIF(NOT FREEGLUT_FOUND)
>
> If you have a better solution, please don't hesitate to post it.
>
> Best Regards.
>
> Leon Moctezuma
You should not need the IF.
This should work:

 FIND_PATH(FREEGLUT_INCLUDE_DIR NAMES GL/freeglut.h PATHS ENV include 
${OPENGL_INCLUDE_DIR})
 FIND_LIBRARY(FREEGLUT_LIBRARY NAMES freeglut_static freeglut glut PATHS 
ENV lib)

See the documentation for FIND_PATH and FIND_LIBRARY:

http://www.cmake.org/HTML/Documentation.html

(I have been told it is too long...  :-)  )
Most of the other paths you had cmake searches automatically.   Also, 
where is freeglut_static.lib on your machine?
Also, is GL/freeglut.h on your machine, and if so where is it?

-Bill




More information about the CMake mailing list