tpaviot / oce

OpenCASCADE Community Edition (OCE): a community driven fork of the Open CASCADE library.
http://groups.google.com/group/oce-dev
GNU Lesser General Public License v2.1
808 stars 284 forks source link

Bug fixes and patches to build on FreeBSD #699

Open teamblubee opened 6 years ago

teamblubee commented 6 years ago

This is an edit to CMakeLists.txt to find X11 on FreeBSD

--- CMakeLists.txt.orig 2018-07-04 11:12:46 UTC
+++ CMakeLists.txt
@@ -486,6 +486,24 @@ if(OCE_VISUALISATION)
        set(OPENGL_LIBRARIES /usr/X11R6/lib/libGL.dylib /usr/X11R6/lib/libGLU.dylib)
    endif (NOT APPLE OR OCE_OSX_USE_COCOA)

+        if (UNIX AND NOT APPLE)
+                message(WARNING "FreeBSD LOOKING FOR X11")
+                find_package(X11 REQUIRED)
+                if ( NOT ${X11_FOUND} )
+                        message(FATAL_ERROR "FreeBSD X11 NOT FOUND?")
+                else (${X11_FOUND} )
+                        include_directories(${X11_INCLUDE_DIR})
+                        link_directories(${X11_LIBRARIES})
+                endif( NOT ${X11_FOUND} )
+        endif(UNIX AND NOT APPLE)
+
+        get_cmake_property(_variableNames VARIABLES)
+        list (SORT _variableNames)
+        foreach (_variableName ${_variableNames})
+                message(STATUS "${_variableName}=${${_variableName}}")
+        endforeach()
+        # message(FATAL_ERROR "----------------====================--------------------")
+
    ## GL2PS
    if(OCE_WITH_GL2PS)
        find_path(GL2PS_INCLUDE_DIR gl2ps.h DOC "Location of header files for GL2PS (containing gl2ps.h)" ${CMAKE_SYSTEM_INCLUDE_PATH})

FreeBSD has malloc defined in stdlib.h

--- inc/config.h.orig   2018-07-04 12:22:31 UTC
+++ inc/config.h
@@ -1866,6 +1866,18 @@
 #endif   

+/*-----------------------------------------------------------*/
+/* Adaptation for FreeBSD */
+/*-----------------------------------------------------------*/
+
+#elif defined(__FreeBSD__)
+
+#define HAVE_MALLOC_H 1
+#define HAVE_STDLIB_H 1
+ 
+#endif   
+
+
 /*--------------------------------------------------------- */
 /*  */
 /*--------------------------------------------------------- */

Another file removing malloc for FreeBSD

--- src/OSD/OSD_MemInfo.cxx.orig    2018-02-13 18:38:59 UTC
+++ src/OSD/OSD_MemInfo.cxx
@@ -29,6 +29,8 @@
   #include <mach/task.h>
   #include <mach/mach.h>
   #include <malloc/malloc.h>
+#elif (defined(__FreeBSD__))
+  #include <unistd.h>
 #else
   #include <unistd.h>
   #include <malloc.h>
--- src/StepFile/recfile.pc.orig    2018-02-13 18:38:59 UTC
+++ src/StepFile/recfile.pc
@@ -16,7 +16,7 @@
 #include "stdio.h"
 #include "string.h"
 #include "stdlib.h"
-#if (!defined(_WIN32) && !defined(__APPLE__))
+#if (!defined(__FreeBSD__) && !defined(_WIN32) && !defined(__APPLE__))
 #include "malloc.h"
 #endif
 #include "recfile.ph" 

clang is more pedantic than gcc

--- src/STEPConstruct/STEPConstruct_AP203Context.cxx.orig   2018-07-04 12:43:42 UTC
+++ src/STEPConstruct/STEPConstruct_AP203Context.cxx
@@ -109,7 +109,7 @@ Handle(StepBasic_DateAndTime) STEPConstruct_AP203Conte
     long shift = 0;
     _get_timezone (&shift);
   #else
-    Standard_Integer shift = Standard_Integer(timezone);
+    Standard_Integer shift = Standard_Integer((size_t)timezone);
   #endif
     Standard_Integer shifth = abs ( shift ) / 3600;
     Standard_Integer shiftm = ( abs ( shift ) - shifth * 3600 ) / 60;