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 b2243e6..11831ef 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 24dc058..a4a6922 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 999e609..d74c668 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 6c86cf8..0d7a64d 100644 (file)
@@ -27,9 +27,9 @@
 set(INC
        .
        ../string
-       ../../extern/glew/include
        ../../source/blender/imbuf
        ../../source/blender/makesdna
+    ${GLEW_INCLUDE_PATH}
 )
 
 set(SRC
index 4f211bd..15fbfaa 100644 (file)
@@ -29,7 +29,7 @@ set(INC
        ../editors/include
        ../blenkernel
        ../../../intern/guardedalloc
-       ../../../extern/glew/include
+    ${GLEW_INCLUDE_PATH}
        ${FREETYPE_INCLUDE_DIRS}
 )
 
index c8969f8..aaa5968 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 85244a8..873b4e5 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 3e3d42e..16cfca8 100644 (file)
@@ -32,7 +32,7 @@ set(INC
        ../../render/extern/include
        ../../windowmanager
        ../../../../intern/guardedalloc
-       ../../../../extern/glew/include
+    ${GLEW_INCLUDE_PATH}
 )
 
 set(SRC
index c79206a..fc7e340 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 e89003a..86ba81a 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 70490e4..9f44c0a 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 5a20a22..c48b479 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 09a627b..efd5523 100644 (file)
@@ -34,7 +34,7 @@ set(INC
        ../makesrna
        ../render/extern/include
        ../../../intern/guardedalloc
-       ../../../extern/glew/include
+       ${GLEW_INCLUDE_PATH}
 )
 
 set(SRC
index 0ea478a..5e4eae4 100644 (file)
@@ -25,7 +25,7 @@ set(INC
        ../../blenkernel
        ../../blenloader
        ../../../../intern/guardedalloc
-       ../../../../extern/glew/include
+       ${GLEW_INCLUDE_PATH}
        ${PYTHON_INCLUDE_DIRS}
 )
 
index 2be62d5..db0815e 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 a4d3e1b..f40c240 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 1678edc..5be76de 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 81db7da..f510303 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 0bd8a0d..604dd92 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 dc13786..a88de69 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 67ac8a0..d5ea39f 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 c677685..cc469c3 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 d899fc3..7e2fda1 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 d47f19e..7c1dd8a 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 acab8de..aae57fc 100644 (file)
@@ -45,7 +45,7 @@ set(INC
        ../../../intern/string
        ../../../intern/moto/include
        ../../../intern/guardedalloc
-       ../../../extern/glew/include
+       ${GLEW_INCLUDE_PATH}
 )
 
 set(SRC