From 44d0136cb4b532c957d6c037ea6a862a1e371cd9 Mon Sep 17 00:00:00 2001
From: Ennio Barbaro <enniobarbaro@gmail.com>
Date: Thu, 2 Jul 2015 23:24:52 +0200
Subject: Fixed bug crash if dlopen fails

---
 opentrack/plugin-support.hpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

(limited to 'opentrack/plugin-support.hpp')

diff --git a/opentrack/plugin-support.hpp b/opentrack/plugin-support.hpp
index bc07c106..95b4b0a1 100644
--- a/opentrack/plugin-support.hpp
+++ b/opentrack/plugin-support.hpp
@@ -115,7 +115,8 @@ struct dylib {
                 {
                     fprintf(stderr, "Error, ignoring: %s\n", err);
                     fflush(stderr);
-                    dlclose(handle);
+                    if (handle)
+                        dlclose(handle);
                     handle = nullptr;
                     return true;
                 }
@@ -138,6 +139,7 @@ struct dylib {
                 return;
         } else {
             (void) _foo::err(handle);
+            return;
         }
 #endif
     
-- 
cgit v1.2.3


From 340906d3571ba3c75e67d8457de4129381d5a6b3 Mon Sep 17 00:00:00 2001
From: Stanislaw Halik <sthalik@misaki.pl>
Date: Thu, 2 Jul 2015 11:58:04 +0200
Subject: try fix MSVC

---
 CMakeLists.txt                                      | 15 ++++++++++++---
 facetracknoir/main.cpp                              |  2 +-
 ftnoir_protocol_sc/ftnoir_protocol_sc.cpp           |  2 +-
 ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp       |  4 +++-
 ftnoir_tracker_aruco/include/exports.h              |  2 +-
 ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp       |  1 -
 ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp |  4 +++-
 opentrack/export.hpp                                |  8 +++++++-
 opentrack/plugin-support.hpp                        |  2 +-
 9 files changed, 29 insertions(+), 11 deletions(-)

(limited to 'opentrack/plugin-support.hpp')

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4fb6e8d2..4389432d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -30,6 +30,10 @@ find_package(Qt5 COMPONENTS SerialPort QUIET)
 include_directories(SYSTEM ${Qt5Core_INCLUDE_DIRS} ${Qt5Xml_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS})
 add_definitions(${Qt5Core_DEFINITIONS} ${Qt5Xml_DEFINITIONS} ${Qt5Gui_DEFINITIONS} ${Qt5Widgets_DEFINITIONS} ${Qt5Network_DEFINITIONS})
 
+if(MSVC)
+    add_definitions(-DNOMINMAX -D_CRT_SECURE_NO_WARNINGS)
+endif()
+
 set(my-qt-deps)
 if(WIN32) # hack to avoid breakage on buildbot
     set(my-qt-deps ws2_32)
@@ -71,6 +75,9 @@ set(EXTRA-MOCS opentrack/options.hpp)
 macro(opentrack_module n dir)
     file(GLOB ${n}-c ${dir}/*.cpp ${dir}/*.c ${dir}/*.h ${dir}/*.hpp ${EXTRA-MOCS})
     file(GLOB ${n}-res ${dir}/*.rc)
+    foreach(f ${n}-res)
+        set_source_files_properties(${f} PROPERTIES LANGUAGE RC)
+    endforeach()
     file(GLOB ${n}-ui ${dir}/*.ui)
     file(GLOB ${n}-rc ${dir}/*.qrc)
 endmacro()
@@ -78,7 +85,7 @@ endmacro()
 macro(opentrack_qt n)
     qt5_wrap_cpp(${n}-moc ${${n}-c} OPTIONS --no-notes)
     QT5_WRAP_UI(${n}-uih ${${n}-ui})
-    QT5_ADD_RESOURCES(${n}-rcc ${${n}-rc})
+    QT5_ADD_RESOURCES(${n}-rcc)
     set(${n}-all ${${n}-c} ${${n}-rc} ${${n}-rcc} ${${n}-uih} ${${n}-moc} ${${n}-res})
 endmacro()
 
@@ -97,7 +104,7 @@ macro(opentrack_library n dir)
             COMPILE_FLAGS "${foolib_COMPILE} ${foolib_GNU-COMPILE} -fvisibility=hidden -fvisibility-inlines-hidden"
         )
     else()
-        set_target_properties(${n} PROPERTIES LINK_FLAGS ${foolib_LINK} COMPILE_FLAGS ${foolib_COMPILE})
+        set_target_properties(${n} PROPERTIES LINK_FLAGS "${foolib_LINK}" COMPILE_FLAGS "${foolib_COMPILE}")
     endif()
     install(TARGETS ${n} RUNTIME DESTINATION . LIBRARY DESTINATION .)
 endmacro()
@@ -348,7 +355,9 @@ if(SDK_RIFT)
         set(link-flags "-framework CoreFoundation -framework CoreGraphics -framework IOKit -framework Quartz")
         set(c-flags "-fno-strict-aliasing")
     else()
-        set(c-flags "-fno-strict-aliasing")
+		if(NOT MSVC)
+			set(c-flags "-fno-strict-aliasing")
+		endif()
     endif()
     opentrack_library(opentrack-tracker-rift ftnoir_tracker_rift LINK ${link-flags} COMPILE ${c-flags})
     target_include_directories(opentrack-tracker-rift SYSTEM PUBLIC ${SDK_RIFT}/Include ${SDK_RIFT}/Src)
diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp
index c92f6980..2e08c8ba 100644
--- a/facetracknoir/main.cpp
+++ b/facetracknoir/main.cpp
@@ -20,7 +20,7 @@ static void add_program_library_path()
     {
         char* p = _pgmptr;
         {
-            char path[MAX_PATH];
+            char path[MAX_PATH+1];
             strcpy(path, p);
             char* ptr = strrchr(path, '\\');
             if (ptr)
diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp
index 36764edc..b1d84f9b 100644
--- a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp
+++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp
@@ -103,7 +103,7 @@ public:
         actx.lpResourceName = MAKEINTRESOURCEA(resid);
         actx.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID;
 #ifdef _MSC_VER
-#	error "MSVC support removed"
+#	define PREFIX ""
 #else
 #	define PREFIX "lib"
 #endif 
diff --git a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp
index b636ffd4..63f75685 100644
--- a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp
+++ b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp
@@ -13,7 +13,9 @@ FTNoIR_Protocol::~FTNoIR_Protocol()
 }
 
 void FTNoIR_Protocol::pose( const double *headpose ) {
-#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
+#ifdef __GNUC__
+#	pragma GCC diagnostic ignored "-Wmissing-field-initializers"
+#endif
     JOYSTICK_STATE state[2] = { 0 };
 
     state[0].POV = (4 << 12) | (4 << 8) | (4 << 4) | 4;
diff --git a/ftnoir_tracker_aruco/include/exports.h b/ftnoir_tracker_aruco/include/exports.h
index aaeb94e4..8f7dab8c 100644
--- a/ftnoir_tracker_aruco/include/exports.h
+++ b/ftnoir_tracker_aruco/include/exports.h
@@ -36,7 +36,7 @@ or implied, of Rafael Muñoz Salinas.
 #endif
 
 
-#if (defined WIN32 || defined _WIN32 || defined WINCE)   && defined DSO_EXPORTS
+#if ((defined WIN32 || defined _WIN32 || defined WINCE)   && defined DSO_EXPORTS) || defined(_MSC_VER)
      #define ARUCO_EXPORTS __declspec(dllexport)
 #else
     #define ARUCO_EXPORTS __attribute__ ((visibility ("default")))
diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp
index 34c27579..826cecaa 100644
--- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp
+++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp
@@ -10,7 +10,6 @@
 
 Hydra_Tracker::Hydra_Tracker() : should_quit(false) {}
 
-#pragma GCC diagnostic ignored "-Wreorder"
 #include <sixense_math.hpp>
 
 Hydra_Tracker::~Hydra_Tracker()
diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp
index 2dc0ad6b..264166fe 100644
--- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp
+++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp
@@ -41,7 +41,9 @@ FTNoIR_Tracker::~FTNoIR_Tracker()
     }
 }
 
-#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
+#ifdef __GNUC__
+#	pragma GCC diagnostic ignored "-Wmissing-field-initializers"
+#endif
 
 static BOOL CALLBACK EnumObjectsCallback( const DIDEVICEOBJECTINSTANCE* pdidoi,
                                    VOID* pContext )
diff --git a/opentrack/export.hpp b/opentrack/export.hpp
index 8c8bdc69..f0983b75 100644
--- a/opentrack/export.hpp
+++ b/opentrack/export.hpp
@@ -1,7 +1,13 @@
 #pragma once
+
 #ifdef _WIN32
 #   define OPENTRACK_LINKAGE __declspec(dllexport)
 #else
 #   define OPENTRACK_LINKAGE
 #endif
-#define OPENTRACK_EXPORT __attribute__ ((visibility ("default"))) OPENTRACK_LINKAGE
+
+#ifndef _MSC_VER
+#	define OPENTRACK_EXPORT __attribute__ ((visibility ("default"))) OPENTRACK_LINKAGE
+#else
+#	define OPENTRACK_EXPORT OPENTRACK_LINKAGE
+#endif
\ No newline at end of file
diff --git a/opentrack/plugin-support.hpp b/opentrack/plugin-support.hpp
index 95b4b0a1..627bce6a 100644
--- a/opentrack/plugin-support.hpp
+++ b/opentrack/plugin-support.hpp
@@ -42,7 +42,7 @@
 #include <iostream>
 
 #ifdef _MSC_VER
-#   error "No support for MSVC anymore"
+#   define OPENTRACK_LIB_PREFIX ""
 #else
 #   define OPENTRACK_LIB_PREFIX "lib"
 #endif
-- 
cgit v1.2.3