File 0001-detect-mingw.patch of Package mingw64-gl2ps

From 243d4f2c98fac6c6923d45213db02a7c47b1aade Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Thu, 13 Sep 2018 16:33:15 +0200
Subject: [PATCH] detect mingw + create DLL (fix #22)

---
 CMakeLists.txt | 59 +++++++++++++++++++++++++++++++-------------------
 1 file changed, 37 insertions(+), 22 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3a1aecd..2ca4419 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,37 +1,40 @@
 #  GL2PS, an OpenGL to PostScript Printing Library
 #  Copyright (C) 1999-2017 C. Geuzaine
-# 
+#
 #  This program is free software; you can redistribute it and/or
 #  modify it under the terms of either:
-# 
+#
 #  a) the GNU Library General Public License as published by the Free
 #  Software Foundation, either version 2 of the License, or (at your
 #  option) any later version; or
-# 
+#
 #  b) the GL2PS License as published by Christophe Geuzaine, either
 #  version 2 of the License, or (at your option) any later version.
-# 
+#
 #  This program is distributed in the hope that it will be useful, but
 #  WITHOUT ANY WARRANTY; without even the implied warranty of
 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See either
 #  the GNU Library General Public License or the GL2PS License for
 #  more details.
-# 
+#
 #  You should have received a copy of the GNU Library General Public
 #  License along with this library in the file named "COPYING.LGPL";
 #  if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
 #  Cambridge, MA 02139, USA.
-# 
+#
 #  You should have received a copy of the GL2PS License with this
 #  library in the file named "COPYING.GL2PS"; if not, I will be glad
 #  to provide one.
-# 
+#
 #  For the latest info about gl2ps and a full list of contributors,
 #  see http://www.geuz.org/gl2ps/.
-# 
+#
 #  Please report all bugs and problems to <gl2ps@geuz.org>.
 
-cmake_minimum_required(VERSION 2.4 FATAL_ERROR)
+cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
+
+# do not warn about non-definition of WIN32 on Cygwin
+set(CMAKE_LEGACY_CYGWIN_WIN32 0)
 
 # if CMAKE_BUILD_TYPE is specified use it; otherwise set the default
 # build type to "RelWithDebInfo" ("-O2 -g" with gcc) prior to calling
@@ -55,7 +58,7 @@ set(GL2PS_EXTRA_VERSION "" CACHE STRING "GL2PS extra version string")
 set(GL2PS_VERSION "${GL2PS_MAJOR_VERSION}.${GL2PS_MINOR_VERSION}")
 set(GL2PS_VERSION "${GL2PS_VERSION}.${GL2PS_PATCH_VERSION}${GL2PS_EXTRA_VERSION}")
 
-execute_process(COMMAND date "+%Y%m%d" OUTPUT_VARIABLE DATE 
+execute_process(COMMAND date "+%Y%m%d" OUTPUT_VARIABLE DATE
                 OUTPUT_STRIP_TRAILING_WHITESPACE)
 if(NOT DATE)
   set(DATE "unknown")
@@ -65,7 +68,20 @@ set(GL2PS_DATE "${DATE}")
 if(APPLE)
   set(GL2PS_OS "MacOSX")
 elseif(CYGWIN)
-  set(GL2PS_OS "Windows")
+  # detect if we use the MinGW compilers on Cygwin - if we do, handle the build
+  # as a pure Windows build
+  if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR
+     CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+    execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpmachine
+                    OUTPUT_VARIABLE CXX_COMPILER_MACHINE
+                    OUTPUT_STRIP_TRAILING_WHITESPACE)
+    if(CXX_COMPILER_MACHINE MATCHES "mingw")
+      set(GMSH_OS "Windows")
+      set(WIN32 1)
+      add_definitions(-DWIN32)
+    endif(CXX_COMPILER_MACHINE MATCHES "mingw")
+  endif(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR
+        CMAKE_CXX_COMPILER_ID MATCHES "Clang")
 else(APPLE)
   set(GL2PS_OS "${CMAKE_SYSTEM_NAME}")
 endif(APPLE)
@@ -119,14 +135,13 @@ if(OPENGL_FOUND)
 
   add_library(shared SHARED gl2ps.c gl2ps.h)
   target_link_libraries(shared ${EXTERNAL_LIBRARIES})
-  set_target_properties(shared PROPERTIES OUTPUT_NAME gl2ps)
-  set_target_properties(shared PROPERTIES
+  set_target_properties(shared PROPERTIES OUTPUT_NAME gl2ps
     VERSION ${GL2PS_MAJOR_VERSION}.${GL2PS_MINOR_VERSION}.${GL2PS_PATCH_VERSION}
-    SOVERSION ${GL2PS_MAJOR_VERSION})
-  if(MSVC)
-    set_target_properties(shared PROPERTIES COMPILE_FLAGS "-DGL2PSDLL -DGL2PSDLL_EXPORTS")
-  endif(MSVC)
-
+    SOVERSION ${GL2PS_MAJOR_VERSION}.${GL2PS_MINOR_VERSION})
+  if(WIN32 OR CYGWIN)
+    set_target_properties(shared PROPERTIES PREFIX "" IMPORT_PREFIX ""
+      IMPORT_SUFFIX ".lib" COMPILE_FLAGS "-DGL2PSDLL -DGL2PSDLL_EXPORTS")
+  endif(WIN32 OR CYGWIN)
   install(TARGETS lib shared DESTINATION lib${LIB_SUFFIX})
 endif(OPENGL_FOUND)
 
 -- 
2.18.1

openSUSE Build Service is sponsored by