From ca254dd37b5dd2c52a88d952569a20026fcae6cb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 5 Apr 2011 23:31:01 +0000 Subject: add option WITH_BUILTIN_GLEW, so linux packagers can disable to use their own glew library. --- CMakeLists.txt | 21 ++++++++ build_files/cmake/Modules/FindGLEW.cmake | 59 ++++++++++++++++++++++ build_files/cmake/macros.cmake | 4 ++ extern/CMakeLists.txt | 4 +- intern/ghost/CMakeLists.txt | 2 +- source/blender/blenfont/CMakeLists.txt | 2 +- source/blender/blenkernel/CMakeLists.txt | 2 +- source/blender/editors/include/BIF_gl.h | 2 +- source/blender/editors/render/CMakeLists.txt | 2 +- source/blender/gpu/CMakeLists.txt | 2 +- source/blender/makesrna/SConscript | 1 + source/blender/makesrna/intern/CMakeLists.txt | 2 +- source/blender/makesrna/intern/SConscript | 1 + source/blender/nodes/CMakeLists.txt | 2 +- source/blender/python/generic/CMakeLists.txt | 2 +- source/blender/windowmanager/CMakeLists.txt | 2 +- source/blenderplayer/CMakeLists.txt | 5 +- source/creator/CMakeLists.txt | 5 +- source/gameengine/BlenderRoutines/CMakeLists.txt | 2 +- source/gameengine/GamePlayer/common/CMakeLists.txt | 2 +- source/gameengine/GamePlayer/ghost/CMakeLists.txt | 2 +- source/gameengine/Ketsji/CMakeLists.txt | 2 +- source/gameengine/Physics/Bullet/CMakeLists.txt | 2 +- source/gameengine/Rasterizer/CMakeLists.txt | 2 +- .../Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt | 2 +- source/gameengine/VideoTexture/CMakeLists.txt | 2 +- 26 files changed, 115 insertions(+), 21 deletions(-) create mode 100644 build_files/cmake/Modules/FindGLEW.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index b2243e6bd74..11831ef0615 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 index 00000000000..0d319f67f01 --- /dev/null +++ b/build_files/cmake/Modules/FindGLEW.cmake @@ -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 diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index 24dc058c4b0..a4a6922bca3 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -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}) diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt index 999e60980db..d74c6683f2c 100644 --- a/extern/CMakeLists.txt +++ b/extern/CMakeLists.txt @@ -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) diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt index 6c86cf82f0e..0d7a64ddfa9 100644 --- a/intern/ghost/CMakeLists.txt +++ b/intern/ghost/CMakeLists.txt @@ -27,9 +27,9 @@ set(INC . ../string - ../../extern/glew/include ../../source/blender/imbuf ../../source/blender/makesdna + ${GLEW_INCLUDE_PATH} ) set(SRC diff --git a/source/blender/blenfont/CMakeLists.txt b/source/blender/blenfont/CMakeLists.txt index 4f211bdda17..15fbfaa2de2 100644 --- a/source/blender/blenfont/CMakeLists.txt +++ b/source/blender/blenfont/CMakeLists.txt @@ -29,7 +29,7 @@ set(INC ../editors/include ../blenkernel ../../../intern/guardedalloc - ../../../extern/glew/include + ${GLEW_INCLUDE_PATH} ${FREETYPE_INCLUDE_DIRS} ) diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index c8969f86778..aaa596862c5 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -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} ) diff --git a/source/blender/editors/include/BIF_gl.h b/source/blender/editors/include/BIF_gl.h index 85244a85613..873b4e52a20 100644 --- a/source/blender/editors/include/BIF_gl.h +++ b/source/blender/editors/include/BIF_gl.h @@ -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 diff --git a/source/blender/editors/render/CMakeLists.txt b/source/blender/editors/render/CMakeLists.txt index 3e3d42e9454..16cfca8dadb 100644 --- a/source/blender/editors/render/CMakeLists.txt +++ b/source/blender/editors/render/CMakeLists.txt @@ -32,7 +32,7 @@ set(INC ../../render/extern/include ../../windowmanager ../../../../intern/guardedalloc - ../../../../extern/glew/include + ${GLEW_INCLUDE_PATH} ) set(SRC diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index c79206a5641..fc7e3408683 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -32,9 +32,9 @@ set(INC ../imbuf ../makesdna ../makesrna - ../../../extern/glew/include ../../../intern/guardedalloc ../../../intern/smoke/extern + ${GLEW_INCLUDE_PATH} ) set(SRC diff --git a/source/blender/makesrna/SConscript b/source/blender/makesrna/SConscript index e89003a60c2..86ba81aae58 100644 --- a/source/blender/makesrna/SConscript +++ b/source/blender/makesrna/SConscript @@ -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 = [] diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index 70490e48add..9f44c0acad3 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -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}) diff --git a/source/blender/makesrna/intern/SConscript b/source/blender/makesrna/intern/SConscript index 5a20a2257a8..c48b479da16 100644 --- a/source/blender/makesrna/intern/SConscript +++ b/source/blender/makesrna/intern/SConscript @@ -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') diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index 09a627b51d4..efd5523f5b2 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -34,7 +34,7 @@ set(INC ../makesrna ../render/extern/include ../../../intern/guardedalloc - ../../../extern/glew/include + ${GLEW_INCLUDE_PATH} ) set(SRC diff --git a/source/blender/python/generic/CMakeLists.txt b/source/blender/python/generic/CMakeLists.txt index 0ea478adbf6..5e4eae4f809 100644 --- a/source/blender/python/generic/CMakeLists.txt +++ b/source/blender/python/generic/CMakeLists.txt @@ -25,7 +25,7 @@ set(INC ../../blenkernel ../../blenloader ../../../../intern/guardedalloc - ../../../../extern/glew/include + ${GLEW_INCLUDE_PATH} ${PYTHON_INCLUDE_DIRS} ) diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt index 2be62d5a8b2..db0815efa53 100644 --- a/source/blender/windowmanager/CMakeLists.txt +++ b/source/blender/windowmanager/CMakeLists.txt @@ -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 diff --git a/source/blenderplayer/CMakeLists.txt b/source/blenderplayer/CMakeLists.txt index a4d3e1b13fc..f40c240d7c5 100644 --- a/source/blenderplayer/CMakeLists.txt +++ b/source/blenderplayer/CMakeLists.txt @@ -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() diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 1678edcd6a3..5be76dea20a 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -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() diff --git a/source/gameengine/BlenderRoutines/CMakeLists.txt b/source/gameengine/BlenderRoutines/CMakeLists.txt index 81db7da5cee..f5103034316 100644 --- a/source/gameengine/BlenderRoutines/CMakeLists.txt +++ b/source/gameengine/BlenderRoutines/CMakeLists.txt @@ -29,7 +29,7 @@ set(INC ../../../source/blender/blenloader ../../../source/blender/gpu ../../../extern/bullet2/src - ../../../extern/glew/include + ${GLEW_INCLUDE_PATH} ) set(SRC diff --git a/source/gameengine/GamePlayer/common/CMakeLists.txt b/source/gameengine/GamePlayer/common/CMakeLists.txt index 0bd8a0dd9a3..604dd9296a1 100644 --- a/source/gameengine/GamePlayer/common/CMakeLists.txt +++ b/source/gameengine/GamePlayer/common/CMakeLists.txt @@ -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} diff --git a/source/gameengine/GamePlayer/ghost/CMakeLists.txt b/source/gameengine/GamePlayer/ghost/CMakeLists.txt index dc137861745..a88de69b272 100644 --- a/source/gameengine/GamePlayer/ghost/CMakeLists.txt +++ b/source/gameengine/GamePlayer/ghost/CMakeLists.txt @@ -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} ) diff --git a/source/gameengine/Ketsji/CMakeLists.txt b/source/gameengine/Ketsji/CMakeLists.txt index 67ac8a02255..d5ea39f5b35 100644 --- a/source/gameengine/Ketsji/CMakeLists.txt +++ b/source/gameengine/Ketsji/CMakeLists.txt @@ -52,7 +52,7 @@ set(INC ../../../intern/audaspace/intern ../../../source/blender/blenloader ../../../source/blender/gpu - ../../../extern/glew/include + ${GLEW_INCLUDE_PATH} ) set(SRC diff --git a/source/gameengine/Physics/Bullet/CMakeLists.txt b/source/gameengine/Physics/Bullet/CMakeLists.txt index c677685de49..cc469c3772a 100644 --- a/source/gameengine/Physics/Bullet/CMakeLists.txt +++ b/source/gameengine/Physics/Bullet/CMakeLists.txt @@ -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} ) diff --git a/source/gameengine/Rasterizer/CMakeLists.txt b/source/gameengine/Rasterizer/CMakeLists.txt index d899fc38162..7e2fda177d7 100644 --- a/source/gameengine/Rasterizer/CMakeLists.txt +++ b/source/gameengine/Rasterizer/CMakeLists.txt @@ -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} ) diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt index d47f19eda90..7c1dd8a2de8 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt @@ -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 diff --git a/source/gameengine/VideoTexture/CMakeLists.txt b/source/gameengine/VideoTexture/CMakeLists.txt index acab8de8d38..aae57fce679 100644 --- a/source/gameengine/VideoTexture/CMakeLists.txt +++ b/source/gameengine/VideoTexture/CMakeLists.txt @@ -45,7 +45,7 @@ set(INC ../../../intern/string ../../../intern/moto/include ../../../intern/guardedalloc - ../../../extern/glew/include + ${GLEW_INCLUDE_PATH} ) set(SRC -- cgit v1.2.3