From a3d86ceead3e8e0762880e68a4c175cbe19b3c0e Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Sat, 7 Sep 2013 12:24:32 -0500 Subject: [PATCH 1/2] When checking for glew via cmake check to see that the system version of glew is at least 1.8 and has the methods of glew 1.9. This is an annoying hack to deal with Ubuntu's glew setup, which is glew 1.8 with 1.9 methods patched in. --- CMakeLists.txt | 2 +- CMakeTests/FindGLEW.cmake | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 CMakeTests/FindGLEW.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b2ba4f44f..f2571e824b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -646,7 +646,7 @@ if(WIN32) else() if(NOT ANDROID) if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - check_lib(GLEW GLEW GL/glew.h) + include(FindGLEW) endif() if(NOT GLEW_FOUND) message("Using static GLEW from Externals") diff --git a/CMakeTests/FindGLEW.cmake b/CMakeTests/FindGLEW.cmake new file mode 100644 index 0000000000..33c60d0439 --- /dev/null +++ b/CMakeTests/FindGLEW.cmake @@ -0,0 +1,35 @@ +include(FindPkgConfig OPTIONAL) + +# This is a hack to deal with Ubuntu's mess. +# Ubuntu's version of glew is 1.8, but they have patched in most of glew 1.9. +# So Ubuntu's version works for dolphin. +macro(test_glew) + set(CMAKE_REQUIRED_INCLUDES ${GLEW_INCLUDE_DIRS}) + set(CMAKE_REQUIRED_LIBRARIES GLEW) + check_cxx_source_runs(" + #include + int main() + { + #ifdef GLEW_ARB_shader_image_load_store + return 0; + #else + return 1; + #endif + }" + GLEW_HAS_1_9_METHODS) +endmacro() + +if(PKG_CONFIG_FOUND AND NOT ${var}_FOUND) + pkg_search_module(GLEW REQUIRED glew>=1.8) +endif() + +if(GLEW_FOUND) + test_glew() + if (GLEW_HAS_1_9_METHODS) + include_directories(${GLEW_INCLUDE_DIRS}) + message("GLEW found") + else() + set($GLEW_FOUND 0 CACHE INTERNAL "") + message(FATAL_ERROR "A version of GLEW with the required methods was not found") + endif() +endif() From d617efc5ef1af2c6fa563c7b1aeeed911d7886a4 Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Sat, 7 Sep 2013 12:40:40 -0500 Subject: [PATCH 2/2] When checking for glew, don't fail if a working system version is not found so we can fall back to the Externals version. --- CMakeLists.txt | 4 ++-- CMakeTests/FindGLEW.cmake | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f2571e824b..48504d66af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -648,11 +648,11 @@ else() if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") include(FindGLEW) endif() - if(NOT GLEW_FOUND) + if(NOT GLEW_FOUND OR NOT GLEW_HAS_1_9_METHODS) message("Using static GLEW from Externals") add_subdirectory(Externals/GLew) include_directories(Externals/GLew/include) - endif(NOT GLEW_FOUND) + endif() endif() endif() diff --git a/CMakeTests/FindGLEW.cmake b/CMakeTests/FindGLEW.cmake index 33c60d0439..cb1e09021a 100644 --- a/CMakeTests/FindGLEW.cmake +++ b/CMakeTests/FindGLEW.cmake @@ -28,8 +28,5 @@ if(GLEW_FOUND) if (GLEW_HAS_1_9_METHODS) include_directories(${GLEW_INCLUDE_DIRS}) message("GLEW found") - else() - set($GLEW_FOUND 0 CACHE INTERNAL "") - message(FATAL_ERROR "A version of GLEW with the required methods was not found") endif() endif()