Merge pull request #3059 from akien-mga/unbundle-glew2

CMake: Add option to use system GLEW 2.0+
This commit is contained in:
Deve 2018-01-13 00:20:11 +01:00 committed by GitHub
commit 84459c6086
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,6 +28,7 @@ option(SERVER_ONLY "Create a server only (i.e. no graphics or sound)" OFF)
option(USE_FRIBIDI "Support for right-to-left languages" ON)
option(CHECK_ASSETS "Check if assets are installed in ../stk-assets" ON)
option(USE_SYSTEM_ANGELSCRIPT "Use system angelscript instead of built-in angelscript. If you enable this option, make sure to use a compatible version." OFF)
option(USE_SYSTEM_GLEW "Use system GLEW instead of the built-in version, when available." ON)
CMAKE_DEPENDENT_OPTION(BUILD_RECORDER "Build opengl recorder" ON
"NOT SERVER_ONLY;NOT USE_GLES2;NOT APPLE" OFF)
@ -110,11 +111,24 @@ include_directories("${PROJECT_SOURCE_DIR}/lib/bullet/src")
add_subdirectory("${PROJECT_SOURCE_DIR}/lib/enet")
include_directories("${PROJECT_SOURCE_DIR}/lib/enet/include")
# Build glew library
# Find system GLEW library or build it if missing
if(NOT USE_GLES2 AND NOT SERVER_ONLY)
add_definitions(-DGLEW_NO_GLU)
add_subdirectory("${PROJECT_SOURCE_DIR}/lib/glew")
include_directories("${PROJECT_SOURCE_DIR}/lib/glew/include")
if(USE_SYSTEM_GLEW)
find_package(PkgConfig)
if(PKGCONFIG_FOUND)
pkg_check_modules(GLEW glew>=2.0)
endif()
endif()
if(GLEW_FOUND)
include_directories(${GLEW_INCLUDE_DIRS})
else()
# Fallback to built-in version silently
add_subdirectory("${PROJECT_SOURCE_DIR}/lib/glew")
include_directories("${PROJECT_SOURCE_DIR}/lib/glew/include")
set(GLEW_LIBRARIES "glew")
endif()
endif()
if(MSVC OR APPLE)
@ -421,7 +435,7 @@ target_link_libraries(supertuxkart
if(NOT SERVER_ONLY)
if(NOT USE_GLES2)
target_link_libraries(supertuxkart ${OPENGL_gl_LIBRARY} glew graphics_utils)
target_link_libraries(supertuxkart ${OPENGL_gl_LIBRARY} ${GLEW_LIBRARIES} graphics_utils)
else()
target_link_libraries(supertuxkart GLESv2)
endif()