cmake error detecting opencascade files on Fedora [FIXED]

Having trouble installing or compiling FreeCAD? Get help here.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
freman
Veteran
Posts: 2214
Joined: Tue Nov 27, 2018 10:30 pm

cmake error detecting opencascade files on Fedora [FIXED]

Post by freman »

Hi, I'm trying to build master on Fedora 35.

When I install the disto opencascade-7.5.0 it installs headers in /usr/include/opencascade as expected. However when I run cmake seems to have a bug which loses the "usr" but and ends up looking in "//include/opencascade" . Note the double slash. This fails and I can't finish cmake.

Code: Select all

-- PyCXX found:
--   Headers:  /svn/FreeCAD/src
--   Sources:  /svn/FreeCAD/src/CXX
--   Version:  6.2.8
CMake Error at cMake/FindOpenCasCade.cmake:101 (file):
  file STRINGS file "//include/opencascade/Standard_Version.hxx" cannot be                                                                                           
  read.                                                                                                                                                              
Call Stack (most recent call first):                                                                                                                                 
  cMake/FreeCAD_Helpers/SetupOpenCasCade.cmake:4 (find_package)                                                                                                      
  CMakeLists.txt:51 (SetupOpenCasCade)                                                                                                                              
   
It seems to think it has found it since it follows with :

Code: Select all

-- -- Found OCE/OpenCASCADE version: ..
-- -- OCE/OpenCASCADE include directory: //include/opencascade
-- -- OCE/OpenCASCADE shared libraries directory: //lib64
Note the library location has the same bug. It's /usr/lib64 not "//lib64"


If I build opencascade from source it works but I need kicad which seems to pull in the distro's OCC as well so I end up with both in parallel installations , one in /usr/lib64 and one in /usr/local/lib :(

Even though they are a nominally the same version that looks like asking for trouble.

I hit this last year with Fedora 34 and ended up building OCC locally. I don't know whether kicad was already using OCC and I did not notice. That seems likely.

Is no one else having this problem with FC's cmake failing to correct sniff the OCC headers ? Is there a work around like providing the location in an env var ?

TIA.
Last edited by freman on Thu May 12, 2022 12:19 am, edited 1 time in total.
wmayer
Founder
Posts: 20308
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: cmake error detecting opencascade files

Post by wmayer »

Since OCC libs are installed under /usr/lib you should have a directory /usr/lib/cmake/opencascade. Inside there you will find all OCC cmake files. Look through them and check if there the "usr" is missing in the path names.
User avatar
freman
Veteran
Posts: 2214
Joined: Tue Nov 27, 2018 10:30 pm

Re: cmake error detecting opencascade files

Post by freman »

Thanks, this looks like the point where the prefix is getting detected and presumably ending up as empty:
OpenCASCADEConfig.cmake

Code: Select all

# Compute the installation prefix from this OpenCASCADEConfig.cmake file 
# location, by going up one level + one level if "cmake" + one level if "lib".
# This is made to support different locations of CMake files:
# - in UNIX style: $INSTALL_DIR/lib/cmake/opencascade-<version>
# - in Windows style: $INSTALL_DIR/cmake
# - in Android style: $INSTALL_DIR/libs/$CMAKE_ANDROID_ARCH_ABI/cmake/opencascade-<version>
get_filename_component (OpenCASCADE_INSTALL_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component (OpenCASCADE_INSTALL_PREFIX "${OpenCASCADE_INSTALL_PREFIX}" PATH)
if (OpenCASCADE_INSTALL_PREFIX MATCHES "/cmake$")
  get_filename_component (OpenCASCADE_INSTALL_PREFIX "${OpenCASCADE_INSTALL_PREFIX}" PATH)
endif()
if (OpenCASCADE_INSTALL_PREFIX MATCHES "/lib$" OR OpenCASCADE_INSTALL_PREFIX MATCHES "/lib64$")
  get_filename_component (OpenCASCADE_INSTALL_PREFIX "${OpenCASCADE_INSTALL_PREFIX}" PATH)
endif()
if (OpenCASCADE_INSTALL_PREFIX MATCHES "/libs/${CMAKE_ANDROID_ARCH_ABI}$")
  get_filename_component (OpenCASCADE_INSTALL_PREFIX "${OpenCASCADE_INSTALL_PREFIX}" PATH)
  get_filename_component (OpenCASCADE_INSTALL_PREFIX "${OpenCASCADE_INSTALL_PREFIX}" PATH)
endif()

# Set OpenCASCADE paths to headers, binaries, libraries, resources, tests, samples, data
set (OpenCASCADE_BINARY_DIR   "${OpenCASCADE_INSTALL_PREFIX}/bin")
set (OpenCASCADE_LIBRARY_DIR  "${OpenCASCADE_INSTALL_PREFIX}/lib64")
set (OpenCASCADE_SCRIPT_DIR   "${OpenCASCADE_INSTALL_PREFIX}/bin")
set (OpenCASCADE_INCLUDE_DIR  "${OpenCASCADE_INSTALL_PREFIX}/include/opencascade")
set (OpenCASCADE_RESOURCE_DIR "${OpenCASCADE_INSTALL_PREFIX}/share/opencascade/resources")

Presumably this is the distro's cmake files. Maybe I can hack the correct value here to get it to run.

Code: Select all

set (OpenCASCADE_INSTALL_PREFIX "/usr" )
Yes, that worked ! Thanks for so efficiently pointing me to the problem lies.
-

Code: Select all

- PyCXX found:
--   Headers:  /svn/FreeCAD/src
--   Sources:  /svn/FreeCAD/src/CXX
--   Version:  6.2.8
-- Found OCC: /usr/include/opencascade (found version "7.5.0") 
-- -- Found OCE/OpenCASCADE version: 7.5.0
-- -- OCE/OpenCASCADE include directory: /usr/include/opencascade
-- -- OCE/OpenCASCADE shared libraries directory: /usr/lib64
I've put some message outputs in that code to see how it stips the path.

Code: Select all

ERROR: sniff: CMAKE_CURRENT_LIST_FILE = /lib64/cmake/opencascade/OpenCASCADEConfig.cmake
ERROR: sniff: OpenCASCADE_INSTALL_PREFIX = /lib64/cmake/opencascade
ERROR: sniff up cmake: OpenCASCADE_INSTALL_PREFIX = /lib64
ERROR: sniff up lib: OpenCASCADE_INSTALL_PREFIX = /
ERROR: sniff end: OpenCASCADE_INSTALL_PREFIX = /
So the problem is that this initial path of cmake file itself stored in CMAKE_CURRENT_LIST_FILE is not correct and is missing its absolute path from /usr.

https://cmake.org/cmake/help/latest/var ... _FILE.html

Code: Select all

Full path to the listfile currently being processed.
There's bug in cmake ?
Is that a bug I need to open with Fedora ?
Last edited by freman on Tue May 10, 2022 10:42 am, edited 1 time in total.
User avatar
freman
Veteran
Posts: 2214
Joined: Tue Nov 27, 2018 10:30 pm

Re: cmake error detecting opencascade files

Post by freman »

Very odd. If I do the same with the local occt build installed , it does return the full path to the makefile:

Code: Select all

--   Version:  6.2.8
ERROR: occt sniff CMAKE_CURRENT_LIST_FILE =   /usr/local/lib/cmake/opencascade/OpenCASCADEConfig.cmake
-- Found OCC: /usr/local/include/opencascade (found version "7.5.0") 
Ah! I get it.

Fedora has a symlink /lib64 -> /usr/lib64

cmake is presumably using that path so sees the CMAKE_CURRENT_LIST_FILE seen above. Fedora need to fix their version of the sniff testing to take account of it.

Many thanks for your help on where to look. I got stuck on this last year and no one could help. I had no other need to use a local build instead of letting the distro handle it. The clash with kicad was making it a problem.

At least a simple hack of the cmake file provides are workaround until ( if and when ) Fedora get round to fixing their version.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: cmake error detecting opencascade files

Post by Kunda1 »

Sorry for the intrusion, just wondering, why not install the latest OCC v7.6.2 ?
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
User avatar
adrianinsaval
Veteran
Posts: 5551
Joined: Thu Apr 05, 2018 5:15 pm

Re: cmake error detecting opencascade files

Post by adrianinsaval »

I think he's trying to use the distro provided package so it won't be the latest out there, although 7.5.0 was a pretty buggy release at least regarding step import/export IIRC so I'm not sure if using that version is a good idea.
btw it seems you've got into quite some issues by upgrading to Fedora 35, why not just skip it and wait a little more for 36, not saying it wouldn't give you trouble but at least you wouldn't have to suffer twice since I assume you'll eventually need/want to move from 35 to 36.
User avatar
freman
Veteran
Posts: 2214
Joined: Tue Nov 27, 2018 10:30 pm

Re: cmake error detecting opencascade files

Post by freman »

btw it seems you've got into quite some issues by upgrading to Fedora 35, why not just skip it and wait a little more for 36,
LOL. You answered your own question. I have enough trouble only updating when my previous is going EOL, in theory the most stable state it's ever going to achieve. What I really don't need is to be the level 1 lab rat for rawhide. ;)

If I wait another year for F36 I can at least hope that they've fix some of the thousands of bug which will get reported in that time. I won't need to deal with those too.
just wondering, why not install the latest OCC v7.6.2 ?
Mainly because I did know there was a new release, but also as adrian said I'm trying to use distro version because of co-deps with Kicad. I don't even want to imagine what happens when you have two different version on the same system !
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: cmake error detecting opencascade files

Post by Kunda1 »

freman wrote: Tue May 10, 2022 2:53 pm co-deps with Kicad.
I see. Makes some sense. OCC 7.5.x had some annoying issues. For reference here are some of them: https://forum.freecadweb.org/viewtopic.php?t=20264
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
User avatar
freman
Veteran
Posts: 2214
Joined: Tue Nov 27, 2018 10:30 pm

Re: cmake error detecting opencascade files

Post by freman »

Thanks for keeping track of all this.

One thing I noticed is the link to the OCC forum, under " Upstream tickets that need to be bumped", is no longer valid:
https://www.salome-platform.org/forum/f ... /409168870

I started looking at OCCT project at one time and concluded the FOSS version was not getting much attention. It seems they released the old version publicly and let it live its own life. That is why I did not check for updates.

It's not quite as dead as I thought but the age of some of these bugs confirms my general impression.

It would be nice to get more recent than 7.5.0 but that mean I need to take Kicad out of the distro as well, which is more hassle than it's worth without some killer issues being resolved in OCCT.

Thanks for your input, I have a better idea of the state of play on these issues now.
User avatar
freman
Veteran
Posts: 2214
Joined: Tue Nov 27, 2018 10:30 pm

Re: cmake error detecting opencascade files

Post by freman »

Here is a proper fix for the cmake bug should anyone need it on Fedora.
Use REAL_PATH to expand the symlink before calulating the library paths.

Code: Select all

# - in UNIX style: $INSTALL_DIR/lib/cmake/opencascade-<version>
# - in Windows style: $INSTALL_DIR/cmake
# - in Android style: $INSTALL_DIR/libs/$CMAKE_ANDROID_ARCH_ABI/cmake/opencascade-<version>
get_filename_component (OpenCASCADE_INSTALL_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
file (REAL_PATH ${OpenCASCADE_INSTALL_PREFIX} OpenCASCADE_INSTALL_PREFIX)
Post Reply