add option WITH_BUILTIN_GLEW, so linux packagers can disable to use their own glew...
authorCampbell Barton <ideasman42@gmail.com>
Tue, 5 Apr 2011 23:31:01 +0000 (23:31 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 5 Apr 2011 23:31:01 +0000 (23:31 +0000)
26 files changed:
CMakeLists.txt
build_files/cmake/Modules/FindGLEW.cmake [new file with mode: 0644]
build_files/cmake/macros.cmake
extern/CMakeLists.txt
intern/ghost/CMakeLists.txt
source/blender/blenfont/CMakeLists.txt
source/blender/blenkernel/CMakeLists.txt
source/blender/editors/include/BIF_gl.h
source/blender/editors/render/CMakeLists.txt
source/blender/gpu/CMakeLists.txt
source/blender/makesrna/SConscript
source/blender/makesrna/intern/CMakeLists.txt
source/blender/makesrna/intern/SConscript
source/blender/nodes/CMakeLists.txt
source/blender/python/generic/CMakeLists.txt
source/blender/windowmanager/CMakeLists.txt
source/blenderplayer/CMakeLists.txt
source/creator/CMakeLists.txt
source/gameengine/BlenderRoutines/CMakeLists.txt
source/gameengine/GamePlayer/common/CMakeLists.txt
source/gameengine/GamePlayer/ghost/CMakeLists.txt
source/gameengine/Ketsji/CMakeLists.txt
source/gameengine/Physics/Bullet/CMakeLists.txt
source/gameengine/Rasterizer/CMakeLists.txt
source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt
source/gameengine/VideoTexture/CMakeLists.txt

index b2243e6bd747a3493644d6a516292228a569417d..11831ef061561799bb483e9957765ce7d259cc4c 100644 (file)
@@ -44,6 +44,9 @@ endif()
 
 cmake_minimum_required(VERSION 2.8)
 
+# this starts out unset
+set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/build_files/cmake/Modules/")
+
 # quiet output for Makefiles, 'make -s' helps too
 # set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
 
@@ -86,6 +89,7 @@ endif()
 
 if(UNIX AND NOT APPLE)
        option(WITH_X11_XINPUT "Enable X11 Xinput (tablet support)"     ON)
+       option(WITH_BUILTIN_GLEW "Use GLEW OpenGL wrapper library bundled with blender" ON)
 endif()
 
 # Modifiers
@@ -1020,6 +1024,23 @@ if(WITH_OPENMP)
        mark_as_advanced(OpenMP_CXX_FLAGS)
 endif() 
 
+#-----------------------------------------------------------------------------
+# Configure GLEW
+
+if(WITH_BUILTIN_GLEW)
+       # set(GLEW_LIBRARY "")  # unused
+       set(GLEW_INCLUDE_PATH "${CMAKE_SOURCE_DIR}/extern/glew/include")
+else()
+       find_package(GLEW)
+
+       if(NOT GLEW_FOUND)
+               message(FATAL_ERROR "GLEW is required to build blender, install it or use WITH_BUILTIN_GLEW")
+       endif()
+
+       mark_as_advanced(GLEW_LIBRARY)
+       mark_as_advanced(GLEW_INCLUDE_PATH)
+endif()
+
 #-----------------------------------------------------------------------------
 # Configure Python.
 
diff --git a/build_files/cmake/Modules/FindGLEW.cmake b/build_files/cmake/Modules/FindGLEW.cmake
new file mode 100644 (file)
index 0000000..0d319f6
--- /dev/null
@@ -0,0 +1,59 @@
+#
+# Try to find GLEW library and include path.
+# Once done this will define
+#
+# GLEW_FOUND
+# GLEW_INCLUDE_PATH
+# GLEW_LIBRARY
+# 
+
+IF (WIN32)
+       FIND_PATH( GLEW_INCLUDE_PATH GL/glew.h
+               $ENV{PROGRAMFILES}/GLEW/include
+               ${PROJECT_SOURCE_DIR}/src/nvgl/glew/include
+               DOC "The directory where GL/glew.h resides")
+       IF (NV_SYSTEM_PROCESSOR STREQUAL "AMD64")
+               FIND_LIBRARY( GLEW_LIBRARY
+                       NAMES glew64 glew64s
+                       PATHS
+                       $ENV{PROGRAMFILES}/GLEW/lib
+                       ${PROJECT_SOURCE_DIR}/src/nvgl/glew/bin
+               ${PROJECT_SOURCE_DIR}/src/nvgl/glew/lib
+                       DOC "The GLEW library (64-bit)"
+               )
+       ELSE(NV_SYSTEM_PROCESSOR STREQUAL "AMD64")
+               FIND_LIBRARY( GLEW_LIBRARY
+                       NAMES glew GLEW glew32 glew32s
+                       PATHS
+                       $ENV{PROGRAMFILES}/GLEW/lib
+                       ${PROJECT_SOURCE_DIR}/src/nvgl/glew/bin
+               ${PROJECT_SOURCE_DIR}/src/nvgl/glew/lib
+                       DOC "The GLEW library"
+               )
+       ENDIF(NV_SYSTEM_PROCESSOR STREQUAL "AMD64")
+ELSE (WIN32)
+       FIND_PATH( GLEW_INCLUDE_PATH GL/glew.h
+               /usr/include
+               /usr/local/include
+               /sw/include
+               /opt/local/include
+               DOC "The directory where GL/glew.h resides")
+       FIND_LIBRARY( GLEW_LIBRARY
+               NAMES GLEW glew
+               PATHS
+               /usr/lib64
+               /usr/lib
+               /usr/local/lib64
+               /usr/local/lib
+               /sw/lib
+               /opt/local/lib
+               DOC "The GLEW library")
+ENDIF (WIN32)
+
+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 )
\ No newline at end of file
index 24dc058c4b0924d6c5c1007e704ff8aeb1092bf2..a4a6922bca3d9a210d4a2b72a13494d5b4ac87e5 100644 (file)
@@ -138,6 +138,10 @@ macro(setup_liblinks
                endif()
        endif()
 
+       if(NOT WITH_BUILTIN_GLEW)
+               target_link_libraries(${target} ${GLEW_LIBRARY})
+       endif()
+
        target_link_libraries(${target} ${OPENGL_glu_LIBRARY} ${JPEG_LIBRARIES} ${PNG_LIBRARIES} ${ZLIB_LIBRARIES})
        target_link_libraries(${target} ${FREETYPE_LIBRARY})
 
index 999e60980db5b08d5dfd4cf863620885bdb3d428..d74c6683f2c7dcdd4c95242a96b3efb8e4e10f6e 100644 (file)
@@ -35,7 +35,9 @@ if(WITH_BINRELOC)
        add_subdirectory(binreloc)
 endif()
 
-add_subdirectory(glew)
+if(WITH_BUILTIN_GLEW)
+       add_subdirectory(glew)
+endif()
 
 if(WITH_IMAGE_OPENJPEG AND (NOT UNIX OR APPLE))
        add_subdirectory(libopenjpeg)
index 6c86cf82f0e4588fb33375f3bf47d72273d6200d..0d7a64ddfa9d8224fad11ae30cca378915decd37 100644 (file)
@@ -27,9 +27,9 @@
 set(INC
        .
        ../string
-       ../../extern/glew/include
        ../../source/blender/imbuf
        ../../source/blender/makesdna
+    ${GLEW_INCLUDE_PATH}
 )
 
 set(SRC
index 4f211bdda17dbd722ce61a53cbffcedac9794e27..15fbfaa2de21c522275bc558e6c4938d3aa8d61f 100644 (file)
@@ -29,7 +29,7 @@ set(INC
        ../editors/include
        ../blenkernel
        ../../../intern/guardedalloc
-       ../../../extern/glew/include
+    ${GLEW_INCLUDE_PATH}
        ${FREETYPE_INCLUDE_DIRS}
 )
 
index c8969f8677866835f50533c69633dc799d41bc38..aaa596862c5040daac85dbeaed39335130e9d5a5 100644 (file)
@@ -38,7 +38,6 @@ set(INC
        ../nodes
        ../editors/include
        ../render/extern/include
-       ../../../extern/glew/include
        ../../../intern/audaspace/intern
        ../../../intern/bsp/extern ../blenfont
        ../../../intern/decimation/extern
@@ -50,6 +49,7 @@ set(INC
        ../../../intern/smoke/extern
        ../../../intern/mikktspace
     ../../../source/blender/windowmanager # XXX - BAD LEVEL CALL WM_api.h
+       ${GLEW_INCLUDE_PATH}
        ${ZLIB_INCLUDE_DIRS}
 )
 
index 85244a85613e3b19cc2e9759a30763cee1da9475..873b4e52a2021394876ceb57897ff0ea3901d4e0 100644 (file)
@@ -35,7 +35,7 @@
 #ifndef BIF_GL_H
 #define BIF_GL_H
 
-#include "../../../../extern/glew/include/GL/glew.h"
+#include "GL/glew.h"
 
        /*
         * these should be phased out. cpack should be replaced in
index 3e3d42e9454e520c9446ecb9cc181a226553d779..16cfca8dadb7b526734ac66adf744cf87dc9058f 100644 (file)
@@ -32,7 +32,7 @@ set(INC
        ../../render/extern/include
        ../../windowmanager
        ../../../../intern/guardedalloc
-       ../../../../extern/glew/include
+    ${GLEW_INCLUDE_PATH}
 )
 
 set(SRC
index c79206a5641bbb13fb083bdfe70f5cb58245d588..fc7e34086837d03aac6b220b6d8b0f928b8e11d8 100644 (file)
@@ -32,9 +32,9 @@ set(INC
        ../imbuf
        ../makesdna
        ../makesrna
-       ../../../extern/glew/include
        ../../../intern/guardedalloc
        ../../../intern/smoke/extern
+    ${GLEW_INCLUDE_PATH}
 )
 
 set(SRC
index e89003a60c2515447cc298d321566a446084e752..86ba81aae584eaf8807230a61a12640b03fe6849 100644 (file)
@@ -9,6 +9,7 @@ objs += o
 incs = '#/intern/guardedalloc #/intern/memutil #/intern/audaspace/intern ../blenkernel ../blenlib ../makesdna intern .'
 incs += ' ../windowmanager ../editors/include ../gpu ../imbuf ../ikplugin ../blenfont ../blenloader'
 incs += ' ../render/extern/include'
+incs += ' #/extern/glew/include'
 
 defs = []
 
index 70490e48addc992a6d931ab0b2c744835a0e81c1..9f44c0acad3865fb10a0984486a3daf9cfd242b4 100644 (file)
@@ -144,10 +144,10 @@ blender_include_dirs(
        ../../windowmanager
        ../../editors/include
        ../../render/extern/include
-       ../../../../extern/glew/include
        ../../../../intern/audaspace/intern
        ../../../../intern/guardedalloc
        ../../../../intern/memutil
+    ${GLEW_INCLUDE_PATH}
 )
 
 add_executable(makesrna ${SRC} ${SRC_RNA_INC} ${SRC_DNA_INC})
index 5a20a2257a8713b5f2d77c62c7d21c3d57aa76dc..c48b479da1652a15ee0a9b2f5fdfa2c6c4dbee55 100644 (file)
@@ -34,6 +34,7 @@ incs += ' ../../imbuf ../../makesdna ../../makesrna ../../ikplugin'
 incs += ' ../../windowmanager ../../editors/include ../../blenfont'
 incs += ' ../../render/extern/include'
 incs += ' #/intern/audaspace/intern '
+incs += ' #/extern/glew/include '
 
 if env['WITH_BF_OPENEXR']:
     defs.append('WITH_OPENEXR')
index 09a627b51d4dd2412a8e3874580d24b9ae42c6ed..efd5523f5b270b8d7985fe6236599d822bafc158 100644 (file)
@@ -34,7 +34,7 @@ set(INC
        ../makesrna
        ../render/extern/include
        ../../../intern/guardedalloc
-       ../../../extern/glew/include
+       ${GLEW_INCLUDE_PATH}
 )
 
 set(SRC
index 0ea478adbf6a8f1f9b51941d08a7a61329f6c68d..5e4eae4f809127319550c6b0f5efdc2211556ee2 100644 (file)
@@ -25,7 +25,7 @@ set(INC
        ../../blenkernel
        ../../blenloader
        ../../../../intern/guardedalloc
-       ../../../../extern/glew/include
+       ${GLEW_INCLUDE_PATH}
        ${PYTHON_INCLUDE_DIRS}
 )
 
index 2be62d5a8b2294f48f084b68b60127f8b682bac9..db0815efa5362c53949c139f5b3df2f35bb0ebae 100644 (file)
@@ -43,8 +43,8 @@ set(INC
        ../../../intern/elbeem/extern
        ../../../intern/ghost
        ../../../intern/opennl/extern
-       ../../../extern/glew/include
        ${OPENGL_INCLUDE_DIR}
+       ${GLEW_INCLUDE_PATH}
 )
 
 set(SRC
index a4d3e1b13fccbb7c9f51018bea830f354a5854c1..f40c240d7c54a7b92688729fa9a2946199f1a0c6 100644 (file)
@@ -112,13 +112,16 @@ if(UNIX)
                bf_intern_audaspace
                blenkernel_blc
                extern_binreloc
-               extern_glew
                extern_minilzo
                bf_intern_ghost # duplicate for linking
                bf_blenkernel # duplicate for linking
                bf_intern_mikktspace
        )
 
+    if(WITH_BUILTIN_GLEW)
+               list(APPEND BLENDER_SORTED_LIBS extern_glew)
+    endif()
+
        if(WITH_LZMA)
                list(APPEND BLENDER_SORTED_LIBS extern_lzma)
        endif()
index 1678edcd6a34d3ded69090046b8218cbbe0fc2aa..5be76dea20a26ed24d0bc59d74f5966b28ec9727 100644 (file)
@@ -777,7 +777,6 @@ endif()
                extern_bullet
                ge_logic_loopbacknetwork
                bf_intern_moto
-               extern_glew
                extern_openjpeg
                extern_redcode
                ge_videotex
@@ -788,6 +787,10 @@ endif()
                bf_intern_mikktspace
        )
 
+    if(WITH_BUILTIN_GLEW)
+               list(APPEND BLENDER_SORTED_LIBS extern_glew)
+    endif()
+
        if(WITH_BINRELOC)
                list(APPEND BLENDER_SORTED_LIBS extern_binreloc)
        endif()
index 81db7da5ceea00b3beeb172bdbaa8ccd24b97a2a..f510303431694847ae4828e2c524f4f4056f1087 100644 (file)
@@ -29,7 +29,7 @@ set(INC
        ../../../source/blender/blenloader
        ../../../source/blender/gpu
        ../../../extern/bullet2/src
-       ../../../extern/glew/include
+       ${GLEW_INCLUDE_PATH}
 )
 
 set(SRC
index 0bd8a0dd9a3562a1093d7e7b34566eb7deb774e2..604dd9296a142a2cf1141c941337e8f3fad13631 100644 (file)
@@ -51,7 +51,7 @@ set(INC
        ../../../../source/gameengine/GamePlayer/ghost
        ../../../../source/blender/blenloader
        ../../../../source/blender/gpu
-       ../../../../extern/glew/include
+       ${GLEW_INCLUDE_PATH}
        ${PYTHON_INCLUDE_DIRS}
        ${PNG_INCLUDE_DIR}
        ${ZLIB_INCLUDE_DIRS}
index dc137861745c4d19530b9e53b0008f797fb46d25..a88de69b272913b81a320f62c17e54de951e4151 100644 (file)
@@ -53,7 +53,7 @@ set(INC
        ../../../../source/gameengine/GamePlayer/common
        ../../../../source/blender/blenloader
        ../../../../source/blender/gpu
-       ../../../../extern/glew/include
+       ${GLEW_INCLUDE_PATH}
        ${PYTHON_INCLUDE_DIRS}
 )
 
index 67ac8a02255c47ac1c7973efa6a76c8db5302caa..d5ea39f5b35f414c5dd1a62612de5f8a043b2cc5 100644 (file)
@@ -52,7 +52,7 @@ set(INC
        ../../../intern/audaspace/intern
        ../../../source/blender/blenloader
        ../../../source/blender/gpu
-       ../../../extern/glew/include
+       ${GLEW_INCLUDE_PATH}
 )
 
 set(SRC
index c677685de4953c7276686b7b13a91f9cf80497b9..cc469c3772a51aa8a20b0a1a48ec1390b626783f 100644 (file)
@@ -31,7 +31,6 @@ set(INC
        .
        ../common
        ../../../../extern/bullet2/src
-       ../../../../extern/glew/include
        ../../../../intern/moto/include
        ../../../../intern/guardedalloc
        ../../../kernel/gen_system
@@ -44,6 +43,7 @@ set(INC
        ../../../../source/blender/makesdna
        ../../../../source/blender/blenlib
        ../../../../source/blender/blenkernel
+       ${GLEW_INCLUDE_PATH}
        ${PYTHON_INCLUDE_DIRS}
 )
 
index d899fc38162ad84dd88437650a9ba7cf49d826d5..7e2fda177d759c2cba70f81763e5ac8350a7f22f 100644 (file)
@@ -32,9 +32,9 @@ set(INC
        ../../../source/gameengine/Ketsji
        ../../../intern/string
        ../../../intern/moto/include
-       ../../../extern/glew/include
        ../../../intern/guardedalloc
        ../Expressions
+       ${GLEW_INCLUDE_PATH}
        ${PYTHON_INCLUDE_DIRS}
 )
 
index d47f19eda90a7dd44ebb1fd0225ad133fc1574b2..7c1dd8a2de8566cce35b2996b994563c3cf0db4f 100644 (file)
@@ -31,12 +31,12 @@ set(INC
        ../../../../source/gameengine/Rasterizer
        ../../../../source/gameengine/Ketsji
        ../../../../source/gameengine/SceneGraph
-       ../../../../extern/glew/include
        ../../../../source/blender/gpu
        ../../../../source/blender/makesdna
        ../../../../source/blender/blenkernel
        ../../../../source/blender/blenlib
        ../../../../source/blender/blenloader
+       ${GLEW_INCLUDE_PATH}
 )
 
 set(SRC
index acab8de8d3869b6e2f9c81b56e7c48a078a2d498..aae57fce679019a91463280023769c0037badb41 100644 (file)
@@ -45,7 +45,7 @@ set(INC
        ../../../intern/string
        ../../../intern/moto/include
        ../../../intern/guardedalloc
-       ../../../extern/glew/include
+       ${GLEW_INCLUDE_PATH}
 )
 
 set(SRC