From e65ce4644c9610a6dbfaaba227f1d9255d4b2c7a Mon Sep 17 00:00:00 2001 From: gnieboer Date: Sun, 24 Apr 2016 19:53:45 +0300 Subject: [PATCH] Refactored changes per upstream request. Added custom FindGLEW cmake module as the one included with CMake 3.3/3.5 won't find it in Windows --- CMakeLists.txt | 2 +- cmake/Modules/FindGLEW.cmake | 50 ++++++++++++++++++++++++++++++++++++++++++++ lib/CMakeLists.txt | 10 +++++++++ lib/base_sink_c_impl.cc | 8 +++++++ lib/fosphor/gl.c | 8 ------- 5 files changed, 69 insertions(+), 9 deletions(-) create mode 100644 cmake/Modules/FindGLEW.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index be911cf..53ad8e4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -120,7 +120,7 @@ endif (QT_FOUND) ######################################################################## # Find gnuradio build dependencies ######################################################################## -set(GR_REQUIRED_COMPONENTS RUNTIME FFT) +set(GR_REQUIRED_COMPONENTS RUNTIME FFT PMT) find_package(Gnuradio 3.7.3 REQUIRED) find_package(CppUnit) diff --git a/cmake/Modules/FindGLEW.cmake b/cmake/Modules/FindGLEW.cmake new file mode 100644 index 0000000..8e7ea79 --- /dev/null +++ b/cmake/Modules/FindGLEW.cmake @@ -0,0 +1,50 @@ +#.rst: +# FindGLEW +# -------- +# +# Find the OpenGL Extension Wrangler Library (GLEW) +# +# IMPORTED Targets +# ^^^^^^^^^^^^^^^^ +# +# This module defines the :prop_tgt:`IMPORTED` target ``GLEW::GLEW``, +# if GLEW has been found. +# +# Result Variables +# ^^^^^^^^^^^^^^^^ +# +# This module defines the following variables: +# +# :: +# +# GLEW_INCLUDE_DIRS - include directories for GLEW +# GLEW_LIBRARIES - libraries to link against GLEW +# GLEW_FOUND - true if GLEW has been found and can be used + +#============================================================================= +# Copyright 2012 Benjamin Eikel +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +find_path(GLEW_INCLUDE_DIR GL/glew.h) +find_library(GLEW_LIBRARY NAMES GLEW glew64 glew32 glew glew32s PATH_SUFFIXES lib64 x86_64 x86 ) + +set(GLEW_INCLUDE_DIRS ${GLEW_INCLUDE_DIR}) +set(GLEW_LIBRARIES ${GLEW_LIBRARY}) + +if(GLEW_FOUND AND NOT TARGET GLEW::GLEW) + add_library(GLEW::GLEW UNKNOWN IMPORTED) + set_target_properties(GLEW::GLEW PROPERTIES + IMPORTED_LOCATION "${GLEW_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${GLEW_INCLUDE_DIRS}") +endif() + +mark_as_advanced(GLEW_INCLUDE_DIR GLEW_LIBRARY) \ No newline at end of file diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 08f7ff1..0a3321a 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -35,6 +35,16 @@ add_custom_command( COMMAND ${PYTHON_EXECUTABLE} -B mkresources.py fft.cl display.cl cmap_simple.glsl cmap_bicubic.glsl cmap_fallback.glsl DroidSansMonoDotted.ttf > ${CMAKE_CURRENT_BINARY_DIR}/fosphor/resource_data.c ) +if (WIN32) + find_package(GLEW REQUIRED) + include_directories( + ${GLEW_INCLUDE_DIRS} + ) + list(APPEND fosphor_libraries + ${GLEW_LIBRARIES} + ) +endif(WIN32) + include_directories( ${OPENGL_INCLUDE_DIRS} ${OpenCL_INCLUDE_DIRS} diff --git a/lib/base_sink_c_impl.cc b/lib/base_sink_c_impl.cc index bfb672c..e117020 100644 --- a/lib/base_sink_c_impl.cc +++ b/lib/base_sink_c_impl.cc @@ -85,6 +85,14 @@ void base_sink_c_impl::worker() /* Init GL context */ this->glctx_init(); +#ifdef _WIN32 + GLenum err = glewInit(); + if (GLEW_OK != err) + { + fprintf(stderr, "Glew initialization error: %s\n", glewGetErrorString(err)); + } +#endif + /* Init fosphor */ { /* (prevent // init of multiple instance to be gentle on the OpenCL diff --git a/lib/fosphor/gl.c b/lib/fosphor/gl.c index 297de53..8b8fe4b 100644 --- a/lib/fosphor/gl.c +++ b/lib/fosphor/gl.c @@ -252,14 +252,6 @@ fosphor_gl_init(struct fosphor *self) if (!gl) return -ENOMEM; -#ifdef USING_GLEW - GLenum err = glewInit(); - if (GLEW_OK != err) - { - fprintf(stderr, "Glew initialization error: %s\n", glewGetErrorString(err)); - } -#endif - self->gl = gl; memset(gl, 0, sizeof(struct fosphor_gl_state)); -- 2.7.1.windows.1