[Ubuntu Daily PPA] Transitioning to OCCT7, VTK7...

Having trouble installing or compiling FreeCAD? Get help here.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
NormandC
Veteran
Posts: 18587
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: [Ubuntu Daily PPA] Transitioning to OCCT7, VTK7...

Post by NormandC »

sgrogan wrote:We are splitting the OCC package and the config file isn't specific to any of the sub-packages so we are not picking up the config file.
Actually we are. It's included in the opencascade-misc package.

Having a look at its content, what I find odd is that some of the Boolean values are in lowercase while some are uppercase (as I believe they all should?)
# Use of third-party libraries.
set (OpenCASCADE_WITH_TCL ON)
set (OpenCASCADE_WITH_FREETYPE ON)
set (OpenCASCADE_WITH_FREEIMAGE on)
set (OpenCASCADE_WITH_GL2PS OFF)
set (OpenCASCADE_WITH_TBB on)
set (OpenCASCADE_WITH_VTK off)
set (OpenCASCADE_WITH_GLES2 )
GLES2 doesn't even have a value...
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: [Ubuntu Daily PPA] Transitioning to OCCT7, VTK7...

Post by sgrogan »

NormandC wrote: Having a look at its content, what I find odd is that some of the Boolean values are in lowercase while some are uppercase (as I believe they all should?)
It looks like we are setting that way in the rules file: https://git.launchpad.net/~freecad-main ... bian/rules
NormandC wrote:Actually we are. It's included in the opencascade-misc package.
Thanks, I had missed that.
"fight the good fight"
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: [Ubuntu Daily PPA] Transitioning to OCCT7, VTK7...

Post by abdullah »

NormandC wrote:Actually we are. It's included in the opencascade-misc package.
I totally missed that one when installing!! :)
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: [Ubuntu Daily PPA] Transitioning to OCCT7, VTK7...

Post by sgrogan »

NormandC wrote: Having a look at its content, what I find odd is that some of the Boolean values are in lowercase while some are uppercase (as I believe they all should?)
From the Cmake docs: https://cmake.org/Wiki/CMake/Language_Syntax
CMake supports boolean variables.

CMake considers an empty string, "FALSE", "OFF", "NO", or any string ending in "-NOTFOUND" to be false. (This happens to be case-insensitive, so "False", "off", "no", and "something-NotFound" are all false.) Other values are true. Thus it matters not whether you use TRUE and FALSE, ON and OFF, or YES and NO for your booleans.

Many scripts expect a string to either be false or contain a useful value, often a path to a directory or a file. You have a potential but rare problem if one of the useful values coincides with falseness. Avoid giving nonsensical names like /tmp/ME-NOTFOUND to your files, executables or libraries.
If I understand correctly, anything not specifically interpreted as False, is interpreted as True. This is news to me. It seems to me we should use caps if only by convention. But anything that isn't FALSE (by Cmake's rules) is interpreted as if NOT_FALSE.
"fight the good fight"
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: [Ubuntu Daily PPA] Transitioning to OCCT7, VTK7...

Post by abdullah »

abdullah wrote: NormandC wrote:
Actually we are. It's included in the opencascade-misc package.



I totally missed that one when installing!! :)
I might have found a slight problem with OCC packaging or how we use it in FC.

While the configuration files are there, they do not seem to be used.

Now, the include files contain TBB in these files:

Code: Select all

grep TBB /usr/include/opencascade/*
/usr/include/opencascade/BVH_DistanceField.lxx:#ifdef HAVE_TBB
/usr/include/opencascade/BVH_DistanceField.lxx:#ifdef HAVE_TBB
/usr/include/opencascade/BVH_DistanceField.lxx://! Tool object for parallel construction of distance field (uses Intel TBB).
/usr/include/opencascade/BVH_DistanceField.lxx:#ifdef HAVE_TBB
/usr/include/opencascade/BVH_LinearBuilder.lxx:#ifdef HAVE_TBB
/usr/include/opencascade/BVH_LinearBuilder.lxx:  //! TBB task for parallel bounds updating.
/usr/include/opencascade/BVH_LinearBuilder.lxx:    //! Creates new TBB parallel bound update task.
/usr/include/opencascade/BVH_LinearBuilder.lxx:#ifdef HAVE_TBB
/usr/include/opencascade/BVH_LinearBuilder.lxx:  // Note: Although TBB tasks are allocated using placement
/usr/include/opencascade/BVH_RadixSorter.lxx:#ifdef HAVE_TBB
/usr/include/opencascade/BVH_RadixSorter.lxx:  //! TBB functor class to run sorting.
/usr/include/opencascade/BVH_RadixSorter.lxx:#ifdef HAVE_TBB
/usr/include/opencascade/OSD_Parallel.hxx:#ifdef HAVE_TBB
/usr/include/opencascade/OSD_Parallel.hxx://! Moreover the primitives may be a wrapper for some primitives from 3rd-party library - TBB.
/usr/include/opencascade/OSD_Parallel.hxx://! To use it is necessary to implement TBB like interface which is based on functors.
/usr/include/opencascade/OSD_Parallel.hxx:  #ifdef HAVE_TBB
/usr/include/opencascade/OSD_Parallel.hxx:  #ifdef HAVE_TBB
/usr/include/opencascade/Standard_MMgrTBBalloc.hxx:#ifndef _Standard_MMgrTBBalloc_HeaderFile
/usr/include/opencascade/Standard_MMgrTBBalloc.hxx:#define _Standard_MMgrTBBalloc_HeaderFile
/usr/include/opencascade/Standard_MMgrTBBalloc.hxx://! Implementation of OCC memory manager which uses Intel TBB
/usr/include/opencascade/Standard_MMgrTBBalloc.hxx://! On configurations where TBB is not available standard RTL functions 
/usr/include/opencascade/Standard_MMgrTBBalloc.hxx:class Standard_MMgrTBBalloc : public Standard_MMgrRoot
/usr/include/opencascade/Standard_MMgrTBBalloc.hxx:  Standard_EXPORT Standard_MMgrTBBalloc(const Standard_Boolean aClear=Standard_False);
As you can see there is lots of HAVE_TBB conditional compilation. However none defines HAVE_TBB.

Now, in /usr/lib/cmake/opencascade, there are these definitions:

Code: Select all

OpenCASCADECompileDefinitionsAndFlags-release.cmake:set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Release>:HAVE_TBB>)
OpenCASCADEConfig.cmake:set (OpenCASCADE_WITH_TBB       on)
Now, HAVE_TBB is not defined when I compile (I tried). This should mean that when those opencascade headers are included in FC, the HAVE_TBB blocks are not being used (but the code WITHOUT the HAVE_TBB). This apparently means that we are linking to a library produced with the HAVE_TBB "ON" (defined), but using the HAVE_TBB "OFF" (undefined) headers. Potentially I would say there may be unresolved symbols (in the future).

I am not expert at all in this cmake topic. I have invested a couple of days into trying to show the TBB support in the about FC window without success. I have just not come with a right combination of cmake statements that would "import" the Opencascade configuration/compile definitions and let me access to the HAVE_TBB (or other macro) in FC's code.

I just wanted to let you know. Maybe I am just wrong. Better safe than sorry ;)
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: [Ubuntu Daily PPA] Transitioning to OCCT7, VTK7...

Post by sgrogan »

abdullah wrote:I might have found a slight problem with OCC packaging or how we use it in FC.
I think you are right. We don't even run cmake's find_package for opencascade. https://github.com/FreeCAD/FreeCAD/blob ... ke#L36-L79
You could try adding "HAVE_TBB=ON" to FreeCAD's Cmake flags?
"fight the good fight"
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: [Ubuntu Daily PPA] Transitioning to OCCT7, VTK7...

Post by abdullah »

sgrogan wrote:
abdullah wrote:I might have found a slight problem with OCC packaging or how we use it in FC.
I think you are right. We don't even run cmake's find_package for opencascade. https://github.com/FreeCAD/FreeCAD/blob ... ke#L36-L79
You could try adding "HAVE_TBB=ON" to FreeCAD's Cmake flags?
Sure I can make add a HAVE_TBB preprocessor definition in CMake. However, I was hopping to do it "right" and detect how opencascade was actually build. This goes beyond my current cmake/package finding capabilities. So I was actually hopping somebody would know the answer ;)

If I just add blindly such a definition, then if somebody builds its own OCC without TBB the wrong headers will be used for him.

However, I can use such a trick to debug an extension of version information ;)
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: [Ubuntu Daily PPA] Transitioning to OCCT7, VTK7...

Post by sgrogan »

abdullah wrote:However, I can use such a trick to debug an extension of version information ;)
I meant only as an experiment. Pass it to CMake as a command line switch. If this fixes the conditional compilation problem with FreeCAD I can work on integrating it into FreeCAD's FindOpenCasCade.cmake script.
"fight the good fight"
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: [Ubuntu Daily PPA] Transitioning to OCCT7, VTK7...

Post by abdullah »

sgrogan wrote:
abdullah wrote:However, I can use such a trick to debug an extension of version information ;)
I meant only as an experiment. Pass it to CMake as a command line switch. If this fixes the conditional compilation problem with FreeCAD I can work on integrating it into FreeCAD's FindOpenCasCade.cmake script.
OK. This diff effectively activates the HAVE_TBB preprocesor macro in FC:

Code: Select all

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 448eb9a..e5acf82 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -980,6 +980,7 @@ endif(WIN32)
 #
 if(OCC_INCLUDE_DIR AND EXISTS ${OCC_INCLUDE_DIR}/Standard_Version.hxx)
     set(HAVE_OCC_VERSION 1)
+    add_definitions(-DHAVE_TBB)
 endif(OCC_INCLUDE_DIR AND EXISTS ${OCC_INCLUDE_DIR}/Standard_Version.hxx)
 
 configure_file(LibraryVersions.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/LibraryVersions.h)
@@ -999,8 +1000,6 @@ ELSE(CMAKE_SIZEOF_VOID_P EQUAL 8)
        MESSAGE(STATUS "Platform is 32-bit")
 ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 8)
 
This is a workaround, as it sets the preprocessor macro if OCC is used (it does not if OCE is used). Appropriate code should see if it was compiled with TBB support, either via the CMAKE option or the compile definitions and flags. The latter I think it is the way.

Some information that might be useful (I did not know about CMake generators):
https://stackoverflow.com/questions/344 ... n-in-cmake

See link to cMake generator information.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: [Ubuntu Daily PPA] Transitioning to OCCT7, VTK7...

Post by Kunda1 »

Does it also merit to mention OCC TBB support in Help > About FreeCAD ?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Post Reply