tweak the GLEW and glut modules to be more hifi specific

This commit is contained in:
Stephen Birarda 2014-03-06 17:53:07 -08:00
parent 594d43db84
commit b91a55d89d
3 changed files with 146 additions and 13 deletions

View file

@ -0,0 +1,36 @@
#
# Try to find GLEW library and include path.
# Once done this will define
#
# GLEW_FOUND
# GLEW_INCLUDE_DIRS
# GLEW_LIBRARY
#
# Created on 2/6/2014 by Stephen Birarda
#
# Adapted from FindGLEW.cmake available in the nvidia-texture-tools repository
# (https://code.google.com/p/nvidia-texture-tools/source/browse/trunk/cmake/FindGLEW.cmake?r=96)
IF (WIN32)
FIND_PATH(GLEW_INCLUDE_DIRS GL/glew.h
${GLEW_ROOT_DIR}/include
$ENV{GLEW_ROOT_DIR}/include
$ENV{HIFI_LIB_DIR}/glew/include
DOC "The directory where GL/glew.h resides")
FIND_LIBRARY(GLEW_LIBRARY
NAMES glew GLEW glew32 glew32s
PATHS
${GLEW_ROOT_DIR}/lib
$ENV{GLEW_ROOT_DIR}/include
$ENV{HIFI_LIB_DIR}/glew/lib
DOC "The GLEW library")
ENDIF()
IF (GLEW_INCLUDE_PATH)
SET( GLEW_FOUND 1 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise")
ELSE (GLEW_INCLUDE_PATH)
SET( GLEW_FOUND 0 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise")
ENDIF (GLEW_INCLUDE_PATH)
MARK_AS_ADVANCED(GLEW_FOUND)

View file

@ -0,0 +1,108 @@
# Try to find GLUT library and include path.
# Once done this will define
#
# GLUT_FOUND
# GLUT_INCLUDE_DIR
# GLUT_LIBRARIES
#
# Created on 2/6/2014 by Stephen Birarda
#
# Adapted from FindGLUT.cmake available in tlorach's OpenGLText Repository
# https://raw.github.com/tlorach/OpenGLText/master/cmake/FindGLUT.cmake
if (WIN32)
find_path( GLUT_INCLUDE_DIR GL/glut.h
${GLUT_ROOT_DIR}/include
$ENV{GLUT_ROOT_DIR}/include
$ENV{HIFI_LIB_DIR}/freeglut
${OPENGL_INCLUDE_DIR}
DOC "The directory where GL/glut.h resides")
if(ARCH STREQUAL "x86")
find_library( GLUT_glut_LIBRARY
NAMES freeglut
PATHS
${GLUT_ROOT_DIR}/lib
$ENV{GLUT_ROOT_DIR}/lib
$ENV{HIFI_LIB_DIR}/freeglut/lib
DOC "The GLUT library")
else()
find_library( GLUT_glut_LIBRARY
NAMES freeglut
PATHS
${GLUT_ROOT_DIR}/lib/x64
$ENV{GLUT_ROOT_DIR}/lib/x64
$ENV{HIFI_LIB_DIR}/freeglut/lib/x64
DOC "The GLUT library")
endif()
else ()
find_path( GLUT_INCLUDE_DIR GL/glut.h
${GLUT_LOCATION}/include
$ENV{GLUT_LOCATION}/include
/usr/include
/usr/include/GL
/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
)
find_library( GLUT_glut_LIBRARY glut
${GLUT_LOCATION}/lib
$ENV{GLUT_LOCATION}/lib
/usr/lib
/usr/local/lib
/usr/openwin/lib
/usr/X11R6/lib
)
find_library( GLUT_Xi_LIBRARY Xi
${GLUT_LOCATION}/lib
$ENV{GLUT_LOCATION}/lib
/usr/lib
/usr/local/lib
/usr/openwin/lib
/usr/X11R6/lib
)
find_library( GLUT_Xmu_LIBRARY Xmu
${GLUT_LOCATION}/lib
$ENV{GLUT_LOCATION}/lib
/usr/lib
/usr/local/lib
/usr/openwin/lib
/usr/X11R6/lib
)
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")
set (GLUT_LIBRARY ${GLUT_LIBRARIES})
set (GLUT_INCLUDE_PATH ${GLUT_INCLUDE_DIR})
endif(GLUT_glut_LIBRARY)
endif(GLUT_INCLUDE_DIR)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GLUT DEFAULT_MSG
GLUT_INCLUDE_DIR
GLUT_LIBRARIES
)
mark_as_advanced(
GLUT_INCLUDE_DIR
GLUT_glut_LIBRARY
GLUT_Xmu_LIBRARY
GLUT_Xi_LIBRARY
)

View file

@ -28,17 +28,6 @@ elseif (WIN32)
add_definitions( -D_USE_MATH_DEFINES ) # apparently needed to get M_PI and other defines from cmath/math.h
add_definitions( -DWINDOWS_LEAN_AND_MEAN ) # needed to make sure windows doesn't go to crazy with its defines
# windows build needs an external glut, we're using freeglut
set(GLUT_ROOT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/external/freeglut")
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "${GLUT_ROOT_PATH}")
# windows build needs glew (opengl extention wrangler) this will handle providing access to OpenGL methods after 1.1
# which are not accessible on windows without glew or some other dynamic linking mechanism
set(GLEW_ROOT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/external/glew")
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "${GLEW_ROOT_PATH}")
include_directories(SYSTEM "${GLEW_ROOT_PATH}/include" "${GLUT_ROOT_PATH}/include")
#set(GL_HEADERS "#define GLEW_STATIC\n#define FREEGLUT_STATIC\n#define FREEGLUT_LIB_PRAGMAS 0\n#include <GL/glew.h>\n#include <GL/wglew.h>\n#include <GL/freeglut_std.h>\n#include <GL/freeglut_ext.h>")
set(GL_HEADERS "#define GLEW_STATIC\n#include <windowshacks.h>\n#include <GL/glew.h>\n#include <GL/glut.h>")
endif ()
@ -227,12 +216,12 @@ else (APPLE)
find_package(GLUT REQUIRED)
include_directories("${GLUT_INCLUDE_DIR}" "${OPENGL_INCLUDE_DIR}")
target_link_libraries(${TARGET_NAME} "${OPENGL_LIBRARY}")
target_link_libraries(${TARGET_NAME} "${OPENGL_LIBRARY}" "${GLUT_LIBRARIES}")
# link target to external libraries
if (WIN32)
find_package(GLEW REQUIRED)
include_directories(${GLEW_INCLUDE_DIRS})
target_link_libraries(${TARGET_NAME} "${GLUT_LIBRARY}" "${GLEW_LIBRARY}" wsock32.lib opengl32.lib)
target_link_libraries(${TARGET_NAME} "${GLEW_LIBRARY}" wsock32.lib opengl32.lib)
endif()
endif (APPLE)