From 0b288b612119c551faa78644e7a1a7f395a78c98 Mon Sep 17 00:00:00 2001 From: Ian Scott Date: Tue, 3 Sep 2002 06:10:06 -0400 Subject: Fixed mistake in comments Transferred OPENGL finding logic in from VXL Added Some backwards compatibility with CMake1.4 --- Modules/FindAVIFile.cmake | 2 +- Modules/FindGLU.cmake | 50 ++------------ Modules/FindGLUT.cmake | 118 +++++++++++++++++++++++--------- Modules/FindJPEG.cmake | 2 +- Modules/FindOpenGL.cmake | 167 ++++++++++++++++++++++++++++++++++++---------- Modules/FindPNG.cmake | 2 +- Modules/FindTIFF.cmake | 2 +- Modules/FindX11.cmake | 1 + 8 files changed, 229 insertions(+), 115 deletions(-) diff --git a/Modules/FindAVIFile.cmake b/Modules/FindAVIFile.cmake index 157d08a..f1de1a2 100644 --- a/Modules/FindAVIFile.cmake +++ b/Modules/FindAVIFile.cmake @@ -8,7 +8,7 @@ # AVIFILE_INCLUDE_DIR, where to find avifile.h , etc. # AVIFILE_LIBRARIES, the libraries to link against to use AVIFILE # AVIFILE_DEFINITIONS, definitions to use when compiling code that uses AVIFILE. -# AVIFILE_FOUND, If false, do try to use AVIFILE. +# AVIFILE_FOUND, If false, don't try to use AVIFILE. IF (UNIX) diff --git a/Modules/FindGLU.cmake b/Modules/FindGLU.cmake index e752e1a..ffb3ba3 100644 --- a/Modules/FindGLU.cmake +++ b/Modules/FindGLU.cmake @@ -1,49 +1,13 @@ # -# Try to find GLU, once done this will define: +# Use of this file is deprecated, and is here for backwards compatibility with CMake 1.4 +# GLU library is now found by FindOpenGL.cmake # -# GLU_INCLUDE_PATH = where the GLU include directory can be found -# GLU_LIBRARY = the name of the GLU library to link with # -IF (WIN32) - IF(BORLAND) - SET (GLU_LIBRARY import32 CACHE STRING "GLU library for win32") - ELSE(BORLAND) - SET (GLU_LIBRARY glu32 CACHE STRING "GLU library for win32") - ENDIF(BORLAND) -ELSE (WIN32) - IF (APPLE) - # The GLU lib is included in the OpenGL framework. We can not - # set GLU_LIBRARY to an empty string since it is equal to FALSE if - # this variable is used in a IF test. So let's set it to the OpenGL - # framework. It does not harm to duplicate the OpenGL framework and it - # might even help in case OPENGL_LIBRARY is not set. - SET(GLU_LIBRARY "-framework AGL -framework OpenGL" CACHE STRING "GLU library for OSX") - ELSE (APPLE) - FIND_PATH(GLU_INCLUDE_PATH GL/glu.h - ${OPENGL_INCLUDE_PATH} - /usr/include - /usr/local/include - /usr/openwin/share/include - /opt/graphics/OpenGL/include - /usr/X11R6/include - ) - MARK_AS_ADVANCED( - GLU_INCLUDE_PATH - ) +INCLUDE(${CMAKE_ROOT}/Modules/FindOpenGL.cmake) - FIND_LIBRARY(GLU_LIBRARY GLU - ${OPENGL_LIBRARY_PATH} - /usr/lib - /usr/local/lib - /opt/graphics/OpenGL/lib - /usr/openwin/lib - /usr/X11R6/lib - ) +IF (OPENGL_GLU_FOUND) + SET (GLU_LIBRARY ${OPENGL_LIBRARIES}) + SET (GLU_INCLUDE_PATH ${OPENGL_INCLUDE_DIR}) +ENDIF (OPENGL_GLU_FOUND) - ENDIF (APPLE) -ENDIF (WIN32) - -MARK_AS_ADVANCED( - GLU_LIBRARY -) diff --git a/Modules/FindGLUT.cmake b/Modules/FindGLUT.cmake index d1c187e..2194347 100644 --- a/Modules/FindGLUT.cmake +++ b/Modules/FindGLUT.cmake @@ -1,55 +1,111 @@ # -# Try to find GLUT, once done this will define: -# -# GLUT_INCLUDE_PATH = where the GLUT include directory can be found -# GLUT_LIBRARY = the name of the GLUT library to link with +# try to find glut library and include files # +# GLUT_INCLUDE_DIR, where to find GL/glut.h, etc. +# GLUT_LIBRARIES, the libraries to link against to use GLUT. +# GLUT_FOUND, If false, do not try to use GLUT. + +# also defined, but not for general use are +# GLUT_glut_LIBRARY, where to find the glut library. +# GLUT_Xmu_LIBRARY, where to find the Xmu library if available. +# GLUT_Xi_LIBRARY, where to find the Xi Library if available. IF (WIN32) - IF (CYGWIN) - FIND_LIBRARY(GLUT_LIBRARY glut32 + + IF(CYGWIN) + + FIND_PATH( GLUT_INCLUDE_DIR GL/glut.h + /usr/include + ) + + FIND_LIBRARY( GLUT_glut_LIBRARY glut32 ${OPENGL_LIBRARY_PATH} + /usr/lib /usr/lib/w32api - /usr/lib - /usr/local/lib + /usr/local/lib /usr/X11R6/lib ) - ELSE (CYGWIN) - FIND_LIBRARY(GLUT_LIBRARY glut32 + + + ELSE(CYGWIN) + + FIND_PATH( GLUT_INCLUDE_DIR GL/glut.h + ${GLUT_ROOT_PATH}/include + ) + + FIND_LIBRARY( GLUT_glut_LIBRARY glut + ${GLUT_ROOT_PATH}/Release ${OPENGL_LIBRARY_PATH} ) - ENDIF (CYGWIN) + + ENDIF(CYGWIN) + ELSE (WIN32) + IF (APPLE) - SET(GLUT_LIBRARY "-framework Glut" CACHE STRING "GLUT library for OSX") +# These values for Apple could probably do with improvement. + FIND_PATH( GLUT_INCLUDE_DIR GL/glut.h + ${OPENGL_LIBRARY_PATH} + ) + SET(GLUT_glut_LIBRARY "-framework Glut" CACHE STRING "GLUT library for OSX") ELSE (APPLE) - FIND_PATH(GLUT_INCLUDE_PATH GL/glut.h - ${OPENGL_INCLUDE_PATH} - /usr/include + + FIND_PATH( GLUT_INCLUDE_DIR GL/glut.h + /usr/include /usr/include/GL - /usr/local/include - /usr/openwin/share/include - /opt/graphics/OpenGL/include + /usr/local/include + /usr/openwin/share/include + /usr/openwin/include + /usr/X11R6/include + /usr/include/X11 + /opt/graphics/OpenGL/include /opt/graphics/OpenGL/contrib/libglut - /usr/X11R6/include ) - MARK_AS_ADVANCED( - GLUT_INCLUDE_PATH + + FIND_LIBRARY( GLUT_glut_LIBRARY glut + /usr/lib + /usr/local/lib + /usr/openwin/lib + /usr/X11R6/lib ) - FIND_LIBRARY(GLUT_LIBRARY glut - ${OPENGL_LIBRARY_PATH} - /usr/lib - /usr/local/lib - /opt/graphics/OpenGL/lib - /opt/graphics/OpenGL/contrib/libglut - /usr/openwin/lib + FIND_LIBRARY( GLUT_Xi_LIBRARY Xi + /usr/lib + /usr/local/lib + /usr/openwin/lib + /usr/X11R6/lib + ) + + FIND_LIBRARY( GLUT_Xmu_LIBRARY Xmu + /usr/lib + /usr/local/lib + /usr/openwin/lib /usr/X11R6/lib ) - ENDIF (APPLE) + ENDIF (APPLE) + ENDIF (WIN32) +SET( GLUT_FOUND "NO" ) +IF(GLUT_INCLUDE_DIR) + IF(GLUT_glut_LIBRARY) + # Is -lXi and -lXmu required on all platforms that have it? + # If not, we need some way to figure out what platform we are on. + SET( GLUT_LIBRARIES + ${GLUT_glut_LIBRARY} + ${GLUT_Xmu_LIBRARY} + ${GLUT_Xi_LIBRARY} + ) + SET( GLUT_FOUND "YES" ) + +#The following deprecated settings are for backwards compatibility with CMake1.4 + SET (GLUT_LIBRARY ${GLUT_LIBRARIES}) + SET (GLUT_INCLUDE_PATH ${GLUT_INCLUDE_DIR}) + + ENDIF(GLUT_glut_LIBRARY) +ENDIF(GLUT_INCLUDE_DIR) + MARK_AS_ADVANCED( - GLUT_LIBRARY -) + GLUT_INCLUDE_PATH +) \ No newline at end of file diff --git a/Modules/FindJPEG.cmake b/Modules/FindJPEG.cmake index 0ca8055..e81e8bf 100644 --- a/Modules/FindJPEG.cmake +++ b/Modules/FindJPEG.cmake @@ -4,7 +4,7 @@ # This module defines # JPEG_INCLUDE_DIR, where to find jpeglib.h, etc. # JPEG_LIBRARIES, the libraries to link against to use JPEG. -# JPEG_FOUND, If false, do try to use JPEG. +# JPEG_FOUND, If false, do not try to use JPEG. # also defined, but not for general use are # JPEG_LIBRARY, where to find the JPEG library. diff --git a/Modules/FindOpenGL.cmake b/Modules/FindOpenGL.cmake index 119d1ee..2792b33 100644 --- a/Modules/FindOpenGL.cmake +++ b/Modules/FindOpenGL.cmake @@ -1,46 +1,139 @@ +# Try to find OpenGL +# Once done this will define # -# Try to find OpenGL, once done this will define: +# OPENGL_FOUND - system has OpenGL and it should be used +# OPENGL_XMESA_FOUND - system has XMESA, and it should be used. +# OPENGL_GLU_FOUND - system has GLU and it should be used. +# OPENGL_INCLUDE_DIR - where the GL include directory can be found +# OPENGL_LIBRARIES - Link these to use OpenGL # -# OPENGL_INCLUDE_PATH = where the GL include directory can be found -# OPENGL_LIBRARY = the name of the OpenGL library to link with -# OPENGL_LIBRARY_PATH = where the GL library can be found (might be empty) +# +# Also defined, but not for general use are +# OPENGL_gl_LIBRARY - Path to OpenGL Library +# OPENGL_glu_LIBRARY - Pat to GLU Librar # IF (WIN32) - IF(BORLAND) - SET (OPENGL_LIBRARY import32 CACHE STRING "OpenGL library for win32") - ELSE(BORLAND) - SET (OPENGL_LIBRARY opengl32 CACHE STRING "OpenGL library for win32") - ENDIF(BORLAND) + IF (CYGWIN) + + + FIND_PATH(OPENGL_INCLUDE_DIR GL/gl.h + /usr/include + /usr/X11R6/include + ) + + FIND_LIBRARY(OPENGL_gl_LIBRARY opengl32 + /usr/lib + /usr/lib/w32api + ) + + FIND_LIBRARY(OPENGL_glu_LIBRARY glu32 + /usr/lib + /usr/lib/w32api + ) + + ELSE (CYGWIN) + + IF(BORLAND) + SET (OPENGL_gl_LIBRARY import32 CACHE STRING "OpenGL library for win32") + SET (OPENGL_glu_LIBRARY import32 CACHE STRING "GLU library for win32") + ELSE(BORLAND) + SET (OPENGL_gl_LIBRARY opengl32 CACHE STRING "OpenGL library for win32") + SET (OPENGL_glu_LIBRARY glu32 CACHE STRING "GLU library for win32") + ENDIF(BORLAND) + + # No extra include path needed because OpenGL includes are with + # the system includes but, cmake will create makefiles with + # "-I${OPENGL_INCLUDE_DIR}" options if OPENGL_INCLUDE_DIR is + # not set. OPENGL_INCLUDE_DIR cannot be set to "" because the + # resulting -I option to "cl" will eat the following + # "-IC:\really\needed" option. This is a kludge to get around + # cmake not ignoring INCLUDE_DIRECTORIES commands with empty + # strings. + SET( OPENGL_INCLUDE_DIR "${PROJECT_SOURCE_DIR}" ) + + ENDIF (CYGWIN) + ELSE (WIN32) - IF (APPLE) - SET(OPENGL_LIBRARY "-framework AGL -framework OpenGL" CACHE STRING "OpenGL library for OSX") - ELSE (APPLE) - FIND_PATH(OPENGL_INCLUDE_PATH GL/gl.h - /usr/include - /usr/local/include - /usr/openwin/share/include - /opt/graphics/OpenGL/include - /usr/X11R6/include - ) - MARK_AS_ADVANCED( - OPENGL_INCLUDE_PATH - ) - - FIND_LIBRARY(OPENGL_LIBRARY GL - /usr/lib - /usr/local/lib - /opt/graphics/OpenGL/lib - /usr/openwin/lib - /usr/X11R6/lib - ) - - ENDIF (APPLE) + + + # The first line below is to make sure that the proper headers + # are used on a Linux machine with the NVidia drivers installed. + # They replace Mesa with NVidia's own library but normally do not + # install headers and that causes the linking to + # fail since the compiler finds the Mesa headers but NVidia's library. + # Make sure the NVIDIA directory comes BEFORE the others. + # - Atanas Georgiev + + FIND_PATH(OPENGL_INCLUDE_DIR GL/gl.h + /usr/share/doc/NVIDIA_GLX-1.0/include + /usr/include + /usr/local/include + /usr/openwin/share/include + /opt/graphics/OpenGL/include + /usr/X11R6/include + ) + + FIND_PATH(OPENGL_xmesa_INCLUDE_DIR GL/xmesa.h + /usr/share/doc/NVIDIA_GLX-1.0/include + /usr/include + /usr/local/include + /usr/openwin/share/include + /opt/graphics/OpenGL/include + /usr/X11R6/include + ) + + FIND_LIBRARY(OPENGL_gl_LIBRARY + NAMES MesaGL GL + PATHS /usr/lib + /usr/local/lib + /opt/graphics/OpenGL/lib + /usr/openwin/lib + /usr/X11R6/lib + ) + + FIND_LIBRARY(OPENGL_glu_LIBRARY + NAMES MesaGLU GLU + PATHS /usr/lib + /usr/local/lib + /opt/graphics/OpenGL/lib + /usr/openwin/lib + /usr/X11R6/lib + ) + + + + ENDIF(OPENGL_glu_LIBRARY) + ENDIF(OPENGL_gl_LIBRARY) + ENDIF(OPENGL_INCLUDE_DIR) + ENDIF (WIN32) -GET_FILENAME_COMPONENT (OPENGL_LIBRARY_PATH ${OPENGL_LIBRARY} PATH) -MARK_AS_ADVANCED( - OPENGL_LIBRARY - OPENGL_LIBRARY_PATH -) + + +SET( OPENGL_FOUND "NO" ) +IF(OPENGL_INCLUDE_DIR) + IF(OPENGL_gl_LIBRARY) + + IF(OPENGL_xmesa_INCLUDE_DIR) + SET( OPENGL_XMESA_FOUND "YES" ) + ELSE(OPENGL_xmesa_INCLUDE_DIR) + SET( OPENGL_XMESA_FOUND "NO" ) + ENDIF(OPENGL_xmesa_INCLUDE_DIR) + + IF(OPENGL_glu_LIBRARY) + SET( OPENGL_GLU_FOUND "YES" ) + ENDIF(OPENGL_glu_LIBRARY) + SET( OPENGL_GLU_FOUND "NO" ) + ENDIF(OPENGL_glu_LIBRARY) + + SET( OPENGL_FOUND "YES" ) + SET( OPENGL_LIBRARIES ${OPENGL_glu_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_LIBRARIES}) + +#The following deprecated settings are for backwards compatibility with CMake1.4 + SET (OPENGL_LIBRARY ${OPENGL_LIBRARIES}) + SET (OPENGL_INCLUDE_PATH ${OPENGL_INCLUDE_DIR}) + + ENDIF(OPENGL_gl_LIBRARY) +ENDIF(OPENGL_INCLUDE_DIR) diff --git a/Modules/FindPNG.cmake b/Modules/FindPNG.cmake index 897f2ee..8c0879b 100644 --- a/Modules/FindPNG.cmake +++ b/Modules/FindPNG.cmake @@ -5,8 +5,8 @@ # This module defines # PNG_INCLUDE_DIR, where to find png.h, etc. # PNG_LIBRARIES, the libraries to link against to use PNG. -# PNG_FOUND, If false, do try to use PNG. # PNG_DEFINITIONS - You should ADD_DEFINITONS(${PNG_DEFINITIONS}) before compiling code that includes png library files. +# PNG_FOUND, If false, do not try to use PNG. # also defined, but not for general use are # PNG_LIBRARY, where to find the PNG library. diff --git a/Modules/FindTIFF.cmake b/Modules/FindTIFF.cmake index d48dba4..46b55eb 100644 --- a/Modules/FindTIFF.cmake +++ b/Modules/FindTIFF.cmake @@ -4,7 +4,7 @@ # This module defines # TIFF_INCLUDE_DIR, where to find tiff.h, etc. # TIFF_LIBRARIES, the libraries to link against to use TIFF. -# TIFF_FOUND, If false, do try to use TIFF. +# TIFF_FOUND, If false, do not try to use TIFF. # also defined, but not for general use are # TIFF_LIBRARY, where to find the TIFF library. diff --git a/Modules/FindX11.cmake b/Modules/FindX11.cmake index 7e0695d..355a021 100644 --- a/Modules/FindX11.cmake +++ b/Modules/FindX11.cmake @@ -6,6 +6,7 @@ # X11_LIBRARIES - link against these to use X11 # X11_FOUND - True if X11 is available # X11_Xext_FOUND - True if the X11 extensions are available. + IF (UNIX) FIND_PATH(X11_INCLUDE_DIR X11/X.h -- cgit v0.12