From 89964c884f43bb9136acb14e784b2452ae0214b7 Mon Sep 17 00:00:00 2001
From: Rashad Kanavath <rashad.kanavath@c-s.fr>
Date: Sat, 19 Nov 2016 13:54:00 +0100
Subject: [PATCH] COMP: cmake patch for openbsd

---
 CMake/OTBModuleMacros.cmake                     | 6 ++++--
 Modules/ThirdParty/GDAL/otb-module-init.cmake   | 9 +++++++--
 Modules/ThirdParty/SiftFast/src/CMakeLists.txt  | 4 ++--
 Modules/ThirdParty/SiftFast/src/libsiftfast.cpp | 2 ++
 4 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/CMake/OTBModuleMacros.cmake b/CMake/OTBModuleMacros.cmake
index 5a3e256db2..b45a9757a4 100644
--- a/CMake/OTBModuleMacros.cmake
+++ b/CMake/OTBModuleMacros.cmake
@@ -284,8 +284,10 @@ endmacro()
 macro(otb_module_target_name _name)
   get_property(_target_type TARGET ${_name} PROPERTY TYPE)
   if (NOT ${_target_type} STREQUAL "EXECUTABLE")
-    set_property(TARGET ${_name} PROPERTY VERSION 1)
-    set_property(TARGET ${_name} PROPERTY SOVERSION 1)
+    if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
+      set_property(TARGET ${_name} PROPERTY VERSION 1)
+      set_property(TARGET ${_name} PROPERTY SOVERSION 1)
+    endif()
     if("${_name}" MATCHES "^[Oo][Tt][Bb]")
       set(_otb "")
     else()
diff --git a/Modules/ThirdParty/GDAL/otb-module-init.cmake b/Modules/ThirdParty/GDAL/otb-module-init.cmake
index 1ed1ca6f83..ff2992ea9b 100644
--- a/Modules/ThirdParty/GDAL/otb-module-init.cmake
+++ b/Modules/ThirdParty/GDAL/otb-module-init.cmake
@@ -143,8 +143,13 @@ gdal_try_run(STATUS GDAL_HAS_HDF4 gdalFormatsTest.c HDF4)
 
 #------------------- TESTS (END)---------------------
 
+set(RUN_GDAL_SYMBOLS_TEST TRUE)
+if("${CMAKE_SYSTEM_NAME}" MATCHES "OpenBSD")
+  set(RUN_GDAL_SYMBOLS_TEST FALSE)
+endif()
+
 #FOR UNIX SYSTEMS ONLY
-if(UNIX)
+if(RUN_GDAL_SYMBOLS_TEST)
   # Prepare bash script
   configure_file(${CMAKE_SOURCE_DIR}/Modules/ThirdParty/GDAL/gdalTest.sh.in ${CMAKE_CURRENT_BINARY_DIR}/gdalTest.sh @ONLY)
   execute_process(COMMAND chmod u+x ${CMAKE_CURRENT_BINARY_DIR}/gdalTest.sh)
@@ -159,4 +164,4 @@ elseif("${JPEG2000_DRIVER_USED}" STREQUAL "JPEG2000")
   unset(JPEG2000_DRIVER_USED)
 else()
   message(STATUS "GDAL driver used for JPEG2000 dataset is '${JPEG2000_DRIVER_USED}'")
-endif()
\ No newline at end of file
+endif()
diff --git a/Modules/ThirdParty/SiftFast/src/CMakeLists.txt b/Modules/ThirdParty/SiftFast/src/CMakeLists.txt
index 56c63b1e54..ac8684974c 100644
--- a/Modules/ThirdParty/SiftFast/src/CMakeLists.txt
+++ b/Modules/ThirdParty/SiftFast/src/CMakeLists.txt
@@ -18,7 +18,7 @@ if( CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX )
     if(IS_SIFTFAST_COMPILE)
         message(STATUS "Try to compile libsiftfast.cpp -- yes.")
     else()
-        message(STATUS "Try to compile libsiftfast.cpp -- no.")
+        message(STATUS "Try to compile libsiftfast.cpp -- no. OUTPUT_VARIABLE has ${OUTPUT}")
         try_compile(IS_SIFTFAST_COMPILE2
               ${CMAKE_CURRENT_BINARY_DIR}
               ${CMAKE_CURRENT_SOURCE_DIR}/test_try_compile_libsiftfast.cpp
@@ -208,4 +208,4 @@ install(FILES otb_siftfast.h
   COMPONENT Development
   )
 
-otb_module_target( otbsiftfast NO_INSTALL )
\ No newline at end of file
+otb_module_target( otbsiftfast NO_INSTALL )
diff --git a/Modules/ThirdParty/SiftFast/src/libsiftfast.cpp b/Modules/ThirdParty/SiftFast/src/libsiftfast.cpp
index 631ab4e49a..3a31c09749 100644
--- a/Modules/ThirdParty/SiftFast/src/libsiftfast.cpp
+++ b/Modules/ThirdParty/SiftFast/src/libsiftfast.cpp
@@ -28,7 +28,9 @@
 #include <map>
 #include <list>
 
+#ifndef __OpenBSD__
 #include <sys/timeb.h>    // ftime(), struct timeb
+#endif
 
 #ifndef _MSC_VER
 #include <sys/time.h>
-- 
GitLab