From ecd26f9f5b9caa12950cea017defe57d1d2357f1 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 29 Apr 2014 12:18:51 +0000 Subject: [PATCH] From Paul Martz, "There is no standard place for gl/glcorearb.h on Windows. Previously, the only way to get OSG to build for core profile was to append an additional include directory ("/I") onto the CFLAGS variables This submission adds a FindGLCORE.cmake script so that the path to gl/glcorearb.h can be specified with a variable, GLCORE_ROOT, either in CMake or the environment. Currently this submission is Windows-only. I don't think OSX or Linux require any help in locating gl/glcorearb.h. But if they do, this submission can be easily modified. Files: - "CMakeLists.txt" is the top-level file. - FindGLCORE.cmake" and "OsgMacroUtils.cmake" go in CMakeModules. " --- CMakeLists.txt | 3 +++ CMakeModules/FindGLCORE.cmake | 36 ++++++++++++++++++++++++++++++++ CMakeModules/OsgMacroUtils.cmake | 12 +++++++++++ 3 files changed, 51 insertions(+) create mode 100644 CMakeModules/FindGLCORE.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d9f4ac78..e7ac68ee2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -528,6 +528,9 @@ IF (OSG_GL3_AVAILABLE) ELSE() IF (OPENGL_PROFILE STREQUAL "GLCORE") + IF(WIN32) + FIND_PACKAGE(GLCORE REQUIRED) + ENDIF() SET(OPENGL_HEADER1 "#include " CACHE STRING "#include<> line for OpenGL Header") SET(OPENGL_HEADER2 "" CACHE STRING "#include<> line for additional OpenGL Headers if required") ELSE() diff --git a/CMakeModules/FindGLCORE.cmake b/CMakeModules/FindGLCORE.cmake new file mode 100644 index 000000000..18c0347c8 --- /dev/null +++ b/CMakeModules/FindGLCORE.cmake @@ -0,0 +1,36 @@ +# Finds the OpenGL Core Profile (cp) header file. +# Looks for glcorearb.h +# +# This script defines the following: +# GLCORE_FOUND // Set to TRUE if glcorearb.h is found +# GLCORE_INCLUDE_DIR // Parent directory of directory (gl, GL3, or OpenGL) containing the CP header. +# GLCORE_GLCOREARB_HEADER // advanced +# +# GLCORE_ROOT can be set as an environment variable or a CMake variable, +# to the parent directory of the gl, GL3, or OpenGL directory containing the CP header. +# + + +FIND_PATH( GLCORE_GLCOREARB_HEADER + NAMES GL/glcorearb.h GL3/glcorearb.h OpenGL/glcorearb.h gl/glcorearb.h + HINTS ${GLCORE_ROOT} + PATHS ENV GLCORE_ROOT +) + +set( GLCORE_INCLUDE_DIR ) +if( GLCORE_GLCOREARB_HEADER ) + set( GLCORE_INCLUDE_DIR ${GLCORE_GLCOREARB_HEADER} ) +endif() + + +# handle the QUIETLY and REQUIRED arguments and set +# GLCORE_FOUND to TRUE as appropriate +INCLUDE( FindPackageHandleStandardArgs ) +FIND_PACKAGE_HANDLE_STANDARD_ARGS( GLCORE + "Set GLCORE_ROOT as the parent of the directory containing the OpenGL core profile header." + GLCORE_INCLUDE_DIR ) + +MARK_AS_ADVANCED( + GLCORE_INCLUDE_DIR + GLCORE_GLCOREARB_HEADER +) diff --git a/CMakeModules/OsgMacroUtils.cmake b/CMakeModules/OsgMacroUtils.cmake index 33b4750fd..3ae19864d 100644 --- a/CMakeModules/OsgMacroUtils.cmake +++ b/CMakeModules/OsgMacroUtils.cmake @@ -212,6 +212,10 @@ ENDMACRO(SET_OUTPUT_DIR_PROPERTY_260 TARGET_TARGETNAME RELATIVE_OUTDIR) ########################################################################################################## MACRO(SETUP_LIBRARY LIB_NAME) + IF(GLCORE_FOUND) + INCLUDE_DIRECTORIES( ${GLCORE_INCLUDE_DIR} ) + ENDIF() + IF(ANDROID) SETUP_ANDROID_LIBRARY(${LIB_NAME}) ELSE() @@ -247,6 +251,10 @@ MACRO(SETUP_LIBRARY LIB_NAME) ENDMACRO(SETUP_LIBRARY LIB_NAME) MACRO(SETUP_PLUGIN PLUGIN_NAME) + IF(GLCORE_FOUND) + INCLUDE_DIRECTORIES( ${GLCORE_INCLUDE_DIR} ) + ENDIF() + IF(ANDROID) SETUP_ANDROID_LIBRARY(${TARGET_DEFAULT_PREFIX}${PLUGIN_NAME}) ELSE() @@ -342,6 +350,10 @@ ENDMACRO(SETUP_PLUGIN) MACRO(SETUP_EXE IS_COMMANDLINE_APP) #MESSAGE("in -->SETUP_EXE<-- ${TARGET_NAME}-->${TARGET_SRC} <--> ${TARGET_H}<--") + IF(GL3_FOUND) + INCLUDE_DIRECTORIES( ${GLCORE_INCLUDE_DIR} ) + ENDIF() + IF(NOT TARGET_TARGETNAME) SET(TARGET_TARGETNAME "${TARGET_DEFAULT_PREFIX}${TARGET_NAME}") ENDIF(NOT TARGET_TARGETNAME)