Setup to debug OCCT

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Setup to debug OCCT

Post by abdullah »

wmayer wrote: Thu Jun 04, 2020 8:15 am The point is that the RUNPATH section is added to the shared OCC libraries in the build directory but get removed after installing them.
I read that this is cmake standard and that can be changed (see first answer and the comment to the first answer):
https://stackoverflow.com/questions/324 ... installing

I have tried both the global CMAKE and the set properties (occt_toolkit.cmake), this is the property setting I tried:

Code: Select all

set_target_properties (${PROJECT_NAME} PROPERTIES BUILD_WITH_INSTALL_RPATH 1 INSTALL_NAME_DIR "${INSTALL_NAME_DIR}" INSTALL_RPATH_USE_LINK_PATH 1)
In ccmake, toggling to "advanced" (press t), these two appear:

Code: Select all

CMAKE_SKIP_INSTALL_RPATH         OFF                                                                                                                                                                             
 CMAKE_SKIP_RPATH                 OFF
I even changed these in CMakeCache.txt:

Code: Select all

CMakeCache.txt://ADVANCED property for variable: CMAKE_SKIP_INSTALL_RPATH
CMakeCache.txt:CMAKE_SKIP_INSTALL_RPATH-ADVANCED:INTERNAL=0
CMakeCache.txt://ADVANCED property for variable: CMAKE_SKIP_RPATH
CMakeCache.txt:CMAKE_SKIP_RPATH-ADVANCED:INTERNAL=0
to 0 (they were set to 1), without lack.

In none of these tests did I manage to have a RPATH in the installed directory.
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Setup to debug OCCT

Post by abdullah »

Reading this:
https://gitlab.kitware.com/cmake/commun ... H-handling

I came with the code for this patch (just adding some lines to the begining of occt_toolkit.cmake):

Code: Select all

--- a/adm/cmake/occt_toolkit.cmake
+++ b/adm/cmake/occt_toolkit.cmake
@@ -1,5 +1,26 @@
 # script for each OCCT toolkit
 
+# use, i.e. don't skip the full RPATH for the build tree
+set(CMAKE_SKIP_BUILD_RPATH FALSE)
+
+# when building, don't use the install RPATH already
+# (but later on when installing)
+set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
+
+set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
+
+# add the automatically determined parts of the RPATH
+# which point to directories outside the build tree to the install RPATH
+set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
+
+# the RPATH to be used when installing, but only if it's not a system directory
+list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
+if("${isSystemDir}" STREQUAL "-1")
+    set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
+endif("${isSystemDir}" STREQUAL "-1")
+
+
+
 # filling some variables by default values(src) or using custom(tools, samples)
 set (RELATIVE_SOURCES_DIR "${RELATIVE_DIR}")
with this patch, the libraries in the installation directory do have as RUNPATH the install directory path.

Then freecad can be build like this:

Code: Select all

cmake -DBUILD_QT5=ON -DPYTHON_EXECUTABLE=/usr/bin/python3 -DCMAKE_BUILD_TYPE=Debug -DOpenCASCADE_DIR=/mylocalfolder/occt-install/lib/cmake/opencascade/ ../free-cad-code
This one runs without any need of environment variable or need for the library being on path or other mangling:
OS: Ubuntu 18.04.4 LTS (MATE/mate)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.21423 (Git)
Build type: Debug
Branch: master
Hash: 21cbceba5ae0f5690e1863c89d94085ac99e28ad
Python version: 3.6.9
Qt version: 5.9.5
Coin version: 4.0.0a
OCC version: 7.4.1.dev
Post Reply