[BUG?] FreeCAD/head build fails @OpenCASCADEConfig.cmake for local installed opencascade 7.4

Having trouble installing or compiling FreeCAD? Get help here.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
pgnd
Posts: 13
Joined: Sun Nov 17, 2019 6:33 am

[BUG?] FreeCAD/head build fails @OpenCASCADEConfig.cmake for local installed opencascade 7.4

Post by pgnd »

I've installed opencascade 7.4.0 locally,

Code: Select all

	ls -ald /usr/local/opencascade/
		drwxr-xr-x 7 root root 4.0K Jan 12 10:54 /usr/local/opencascade

	cat /usr/local/opencascade/lib/cmake/opencascade/OpenCASCADEConfig.cmake 
		#-----------------------------------------------------------------------------
		#
		# OpenCASCADEConfig.cmake - OpenCASCADE CMake configuration file for external projects.
		#
		# This file is configured by OpenCASCADE.
		#

		if(OpenCASCADE_ALREADY_INCLUDED)
		  return()
		endif()
		set(OpenCASCADE_ALREADY_INCLUDED 1)

		# The OpenCASCADE version number
		set (OpenCASCADE_MAJOR_VERSION       "7")
		set (OpenCASCADE_MINOR_VERSION       "4")
		set (OpenCASCADE_MAINTENANCE_VERSION "0")
		set (OpenCASCADE_DEVELOPMENT_VERSION "beta")

		# 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
		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 "/lib64$")
		  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")
		...
sourcing FreeCAD master,

Code: Select all

	git log | head
		commit acd3cd901e5caef9cca94df00b0462b1a832c6dd
		Author: wmayer <wmayer@users.sourceforge.net>
		Date:   Sun Jan 12 21:12:09 2020 +0100

		    Gui: [skip ci] add missing export macro

		commit 74847380445a1cc59caf47fa3f7834f157fb80d6
		Author: Zheng, Lei <realthunder.dev@gmail.com>
		Date:   Sat Jan 11 15:20:24 2020 +0800
building

Code: Select all

mkdir -p FreeCAD-build
cd FreeCAD-build
cmake \
	...
../FreeCAD
fails with errors

Code: Select all

	...
	-- Found ZLIB: /usr/lib64/libz.so (found version "1.2.11") 
	-- PyCXX found:
	--   Headers:  /usr/local/src/FreeCAD/src
	--   Sources:  /usr/local/src/FreeCAD/src/CXX
	--   Version:  6.2.8
	CMake Error at cMake/FindOpenCasCade.cmake:95 (file):
	  file STRINGS file
	  "/usr/local/opencascade/lib/include/opencascade/Standard_Version.hxx"
	  cannot be read.
	Call Stack (most recent call first):
	  cMake/FreeCAD_Helpers/SetupOpenCasCade.cmake:4 (find_package)
	  CMakeLists.txt:57 (SetupOpenCasCade)


	CMake Error at cMake/FindOpenCasCade.cmake:98 (string):
	  string sub-command REGEX, mode MATCH needs at least 5 arguments total to
	  command.
	Call Stack (most recent call first):
	  cMake/FreeCAD_Helpers/SetupOpenCasCade.cmake:4 (find_package)
	  CMakeLists.txt:57 (SetupOpenCasCade)


	CMake Error at cMake/FindOpenCasCade.cmake:99 (file):
	  file STRINGS file
	  "/usr/local/opencascade/lib/include/opencascade/Standard_Version.hxx"
	  cannot be read.
	Call Stack (most recent call first):
	  cMake/FreeCAD_Helpers/SetupOpenCasCade.cmake:4 (find_package)
	  CMakeLists.txt:57 (SetupOpenCasCade)


	CMake Error at cMake/FindOpenCasCade.cmake:102 (string):
	  string sub-command REGEX, mode MATCH needs at least 5 arguments total to
	  command.
	Call Stack (most recent call first):
	  cMake/FreeCAD_Helpers/SetupOpenCasCade.cmake:4 (find_package)
	  CMakeLists.txt:57 (SetupOpenCasCade)


	CMake Error at cMake/FindOpenCasCade.cmake:103 (file):
	  file STRINGS file
	  "/usr/local/opencascade/lib/include/opencascade/Standard_Version.hxx"
	  cannot be read.
	Call Stack (most recent call first):
	  cMake/FreeCAD_Helpers/SetupOpenCasCade.cmake:4 (find_package)
	  CMakeLists.txt:57 (SetupOpenCasCade)


	CMake Error at cMake/FindOpenCasCade.cmake:106 (string):
	  string sub-command REGEX, mode MATCH needs at least 5 arguments total to
	  command.
	Call Stack (most recent call first):
	  cMake/FreeCAD_Helpers/SetupOpenCasCade.cmake:4 (find_package)
	  CMakeLists.txt:57 (SetupOpenCasCade)


	-- Found OCC: /usr/local/opencascade/lib/include/opencascade (found version "..") 
	-- -- Found OCE/OpenCASCADE version: ..
	-- -- OCE/OpenCASCADE include directory: /usr/local/opencascade/lib/include/opencascade
	-- -- OCE/OpenCASCADE shared libraries directory: /usr/local/opencascade/lib/lib64
	...
	==============
	Summary report
	==============
	...
	=================================================
	Now run 'cmake --build /usr/local/src/FreeCAD-build' to build FreeCAD
	=================================================

	-- Configuring incomplete, errors occurred!
	See also "/usr/local/src/FreeCAD-build/CMakeFiles/CMakeOutput.log".
	See also "/usr/local/src/FreeCAD-build/CMakeFiles/CMakeError.log".
incorrectly spec'ing the INCLUDE and LIB dirs.

checking, `OpenCASCADE_DIR:PATH` *is* correctly located,

Code: Select all

	grep -i cascade CMakeCache.txt
		//Official OpenCASCADE version or community edition
		//The directory containing a CMake configuration file for OpenCASCADE.
		OpenCASCADE_DIR:PATH=/usr/local/opencascade/lib/cmake/opencascade
		FIND_PACKAGE_MESSAGE_DETAILS_OCC:INTERNAL=[/usr/local/opencascade/lib/include/opencascade][v..()]
but the FIND op is clearly returning incorrect info.

a quick circumventing patch

Code: Select all

	cat << EOF > /usr/local/src/FreeCAD_OCC_INCLUDE_DIR.patch
	--- cMake/FindOpenCasCade.cmake.ORIG	2020-01-12 12:40:14.981532566 -0800
	+++ cMake/FindOpenCasCade.cmake	2020-01-12 12:41:24.848752019 -0800
	@@ -91,6 +91,10 @@
	   endif(OpenCASCADE_FOUND)
	 endif(OCE_FOUND)

	+#TEST
	+set(OCC_INCLUDE_DIR /usr/local/opencascade/include/opencascade)
	+set(OCC_LIBRARY_DIR /usr/local/opencascade/lib64)
	+
	 if(OCC_INCLUDE_DIR)
	   file(STRINGS ${OCC_INCLUDE_DIR}/Standard_Version.hxx OCC_MAJOR
	     REGEX "#define OCC_VERSION_MAJOR.*"
	EOF
	patch -p0 < /usr/local/src/FreeCAD_OCC_INCLUDE_DIR.patch
does the trick.

Code: Select all

	cmake ...

		...
		==============
		Summary report
		==============
		...
		-- Doxygen:             not found
		=================================================
		Now run 'cmake --build /usr/local/src/FreeCAD-build' to build FreeCAD
		=================================================

		-- Configuring done
		-- Generating done
		-- Build files have been written to: /usr/local/src/FreeCAD-build

Post Reply