MSVC Patch

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/osmocom-sdr@lists.osmocom.org/.

Geof Nieboer gnieboer at corpcomm.net
Sun Apr 24 18:19:41 UTC 2016


New patch attached.

GLEW detection will be somewhat spotty I suspect, the basic FindGLEW module
built into CMake doesn't really cover it so I added some coverage to a
custom one and added it to the cmake/modules subdir.  It was good enough
for mine, and users can manually specify if they need to.

I haven't seen that any of the other changes ariovistus made were necessary
to get gr-fosphor going, so I didn't include them.  Some are needed for
earlier compiler versions, but not MSVC 2015.


On Sun, Apr 24, 2016 at 1:52 AM, Sylvain Munaut <246tnt at gmail.com> wrote:

> Hi,
>
> > Do you mean in xxx_sink_c_impl, or are you thinking that GR would do it
> in
> > it's initial GUI setup?
>
> In the xxx_sink_c_impl. Although since this is common this should
> probably be in the base_sink, most likely just after the glctx_init()
> call
>
>
> >>  Also using a magic 'USING_GLEW' that must somehow be setup manually is
> >> not acceptable. Need some CMake logic to detect when this is required
> and
> >> automatically set it up.
> >
> >
> > Sure.  I don't disagree, but I'm not sure what other configurations would
> > require Glew, so since I couldn't vouch for anything but Win10-64/MSVC, I
> > left it as a manual option that can then be specified on the CMake
> command
> > line (which is what my build scripts are doing now).  If you can point
> in to
> > what configurations overall would need this, then happy to submit a new
> > change.
>
> I don't think this is compiler specific so probably anything on
> windows would require it.
>
> I found out someone else tried to build gr-fosphor with MSVC a while
> back but he never to upstream :
>
> https://github.com/ariovistus/gr-fosphor/search?utf8=%E2%9C%93&q=glew
>
> You can see there the GLEW things he had to do ... not sure if they're
> required.
>
> Cheers,
>
>    Sylvain
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/osmocom-sdr/attachments/20160424/c65fa5c4/attachment.htm>
-------------- next part --------------
From e65ce4644c9610a6dbfaaba227f1d9255d4b2c7a Mon Sep 17 00:00:00 2001
From: gnieboer <gnieboer at corpcomm.net>
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



More information about the osmocom-sdr mailing list