使用 Homebrew 在 macOS Big Sur 11.5.1 上编译 FreeCAD,查找 XercesC 文件时出错

Compile FreeCAD on macOS Big Sur 11.5.1 with Homebrew, error finding XercesC files

我在 macOS Big Sur 上编译 FC 卡住了。构建因找不到某些 XercesC 库的错误而中断。但是安装了这些库,路径甚至被CMake准备过程找到了。

我在 https://forum.freecadweb.org/viewtopic.php?f=4&t=60663 下的 FreeCAD 论坛中发布了这个问题,但没有找到任何帮助。如果 Whosebug 的任何人都可以验证此错误或更好地提供解决方案提示,我将不胜感激。提前致谢。

系统信息:

构建过程的完整步骤:

# install freecad dependencies via homebrew
brew tap freecad/freecad
brew install eigen
brew install --only-dependencies freecad --with-packaging-utils

# Freecad source is located in folder freecad-source/
# setup the build folder and change into newly created folder
mkdir -p freecad-build
cd freecad-build

# export path to installed dependencies
export PREFIX_PATH="\
/usr/local/opt/qt5152/lib/cmake;\
/usr/local/opt/nglib/Contents/Resources;\
/usr/local/opt/vtk@8.2.0/lib/cmake;\
/usr/local/opt/opencascade@7.5.0/lib/cmake;\
/usr/local/opt/med-file/share/cmake;\
/usr/local/opt/shiboken2/lib/cmake;\
/usr/local/opt/pyside2/lib/cmake;\
/usr/local/opt/coin@4.0.0;\
/usr/local/opt/boost@1.75.0/lib/cmake;\
/usr/local/opt/boost-python3@1.75.0/lib/cmake"

# initiate build instructions
cmake \
  -DCMAKE_INSTALL_LIBDIR=lib \
  -DCMAKE_BUILD_TYPE="Release" \
  -DCMAKE_FIND_FRAMEWORK=LAST \
  -DCMAKE_VERBOSE_MAKEFILE=OFF \
  -Wno-dev \
  -DBUILD_TESTING=OFF \
  -DCMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk \
  -DBUILD_QT5=ON \
  -DUSE_PYTHON3=1 \
  -DCMAKE_CXX_STANDARD=14 \
  -DBUILD_ENABLE_CXX_STD:STRING=C++14 \
  -DBUILD_FEM_NETGEN=1 \
  -DBUILD_FEM=1 \
  -DBUILD_FEM_NETGEN:BOOL=ON \
  -DBUILD_WEB=ON \
  -DFREECAD_USE_EXTERNAL_KDL=ON \
  -DPYTHON_EXECUTABLE=/usr/local/opt/python3.9/bin/python3 \
  -DPYTHON_INCLUDE_DIR=/usr/local/opt/python3.9/Frameworks/Python.framework/Headers \
  -DCMAKE_PREFIX_PATH="$PREFIX_PATH" \
  -DFREECAD_CREATE_MAC_APP=1 \
  -DCMAKE_INSTALL_PREFIX="./.." \
  ../freecad-source

CMake 进程成功结束,并显示以下摘要报告。请注意,XercesC 正确地位于 -- XercesC: 3.2.3 [/usr/local/lib/libxerces-c.dylib] [/usr/local/include]:

-- The C compiler identification is AppleClang 12.0.5.12050022
-- The CXX compiler identification is AppleClang 12.0.5.12050022
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Compiler: AppleClang, version: 12.0.5.12050022
-- Looking for GL/gl.h
-- Looking for GL/gl.h - not found
-- Looking for C++ include istream
-- Looking for C++ include istream - found
-- Looking for C++ include ostream
-- Looking for C++ include ostream - found
-- Looking for C++ include fstream
-- Looking for C++ include fstream - found
-- Looking for C++ include sstream
-- Looking for C++ include sstream - found
-- Looking for C++ include ios
-- Looking for C++ include ios - found
-- Looking for C++ include iostream
-- Looking for C++ include iostream - found
-- Looking for C++ include iomanip
-- Looking for C++ include iomanip - found
-- Looking for C++ include iostream
-- Looking for C++ include iostream - found
-- Check for STD namespace
-- Check for STD namespace - found
-- Force BOOST_PP_VARIADICS=1 for clang
-- prefix: /Users/dirkolbrich/Freecad
-- bindir: bin
-- datadir: share
-- docdir: share/doc/FreeCAD
-- includedir: include
-- libdir: lib
-- cmake: 3.21.1
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
=====================================================
Doxygen not found, will not build documentation.
=====================================================

-- Detected Homebrew install at /usr/local
-- Found Python3: /usr/local/bin/python3.9 (found version "3.9.6") found components: Interpreter Development Development.Module Development.Embed
-- Found XercesC: /usr/local/lib/libxerces-c.dylib (found version "3.2.3")
-- Found ZLIB: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libz.tbd (found version "1.2.11")

# lots of other setup stuff deleted for clarity
#
#

==============
Summary report
==============

-- Build type:          Release
-- Compiler:            /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ (12.0.5.12050022)
-- Flags:               -Wall -Wextra -Wpedantic -Wno-write-strings  -Wno-undefined-var-template
-- Standard:            Requires C++14
-- Python:              3.9.6 [/usr/local/bin/python3.9] [.cpython-39-darwin]
-- PCL:                 not enabled
-- pybind11:            not enabled
-- Boost:               1.75.0 (1.75.0)
-- XercesC:             3.2.3 [/usr/local/lib/libxerces-c.dylib] [/usr/local/include]
-- ZLIB:                1.2.11
-- PyCXX:               6.2.8 [/Users/dirkolbrich/Freecad/freecad-source/src]
-- OCC:                 7.5.0 [TKFillet;TKMesh;TKernel;TKG2d;TKG3d;TKMath;TKIGES;TKSTL;TKShHealing;TKXSBase;TKBool;TKBO;TKBRep;TKTopAlgo;TKGeomAlgo;TKGeomBase;TKOffset;TKPrim;TKSTEPBase;TKSTEPAttr;TKSTEP209;TKSTEP;TKHLR;TKFeat] [/usr/local/opt/opencascade@7.5.0/lib] [/usr/local/opt/opencascade@7.5.0/include/opencascade]
-- SMESH:               build internal
--  MEDFile:            4.0.0 [/usr/local/lib/libmedC.dylib;/usr/local/lib/libmed.dylib] [/usr/local/include]
--  HDF5:               1.12.1
--  VTK:                8.2.0
-- NETGEN:              6.2.2101 (6.2.2101) [-DNO_PARALLEL_THREADS;-DOCCGEOMETRY;-DNETGEN_VERSION=395829] [] [/usr/local/opt/nglib/Contents/Resources/include/include;/usr/local/opt/nglib/Contents/Resources/include] [nglib] [/usr/local/opt/nglib/Contents/Resources/include/include;/usr/local/opt/nglib/Contents/Resources/include]
-- SWIG:                4.0.2
-- Eigen3               3.3.9
-- Qt5Core:             5.15.2
-- Qt5Network:          5.15.2
-- Qt5Xml:              5.15.2
-- Qt5XmlPatterns:      5.15.2
-- Qt5Widgets:          5.15.2
-- Qt5PrintSupport:     5.15.2
-- Qt5OpenGL:           5.15.2
-- Qt5Svg:              5.15.2
-- Qt5UiTools:          5.15.2
-- Qt5Concurrent:       5.15.2
-- Qt5WebEngineWidgets: 5.15.2
-- Shiboken2:           5.15.2 [/usr/local/opt/shiboken2/lib/cmake/Shiboken2-5.15.2] [/usr/local/opt/shiboken2/include/shiboken2;/usr/local/opt/python3.9/Frameworks/Python.framework/Headers]
-- PySide2:             5.15.2 [/usr/local/opt/pyside2/include/PySide2]
-- PySide2Tools:        [/usr/local/bin/uic] [/usr/local/bin/rcc]
-- Freetype:            2.11.0
-- OpenGL:              /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework
-- OpenGLU:             [/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework][/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework]
-- Coin3D:              4.0.0 [/usr/local/opt/coin@4.0.0/lib/libCoin.dylib] [/usr/local/opt/coin@4.0.0/include]
-- Pivy:                0.6.5
-- SPNAV:               [SPNAV_LIBRARY-NOTFOUND] [SPNAV_INCLUDE_DIR-NOTFOUND]
-- Matplotlib:          2.1.1
-- Rift:                not enabled (BUILD_VR)
-- Doxygen:             not found
=================================================
Now run 'cmake --build /Users/dirkolbrich/Freecad/freecad-build' to build FreeCAD
=================================================

-- Configuring done
-- Generating done
-- Build files have been written to: /Users/dirkolbrich/Freecad/freecad-build

现在我按照以下步骤开始构建过程:

# set path to icu4c
# see https://forum.freecadweb.org/viewtopic.php?p=507588#p507588
export LIBRARY_PATH="/usr/local/opt/icu4c/lib"

#start the build according to the last line of the cmake summary report
cmake --build /Users/dirkolbrich/freecad/freecad-build/release

在完成前不久出现构建错误,错误是找不到 XercesC 库文件:

[ 91%] Building CXX object src/Mod/Measure/App/CMakeFiles/Measure.dir/AppMeasure.cpp.o
In file included from /Users/dirkolbrich/freecad/freecad-source/src/Mod/Measure/App/AppMeasure.cpp:32:
In file included from /Users/dirkolbrich/freecad/freecad-source/src/Mod/Measure/App/Measurement.h:29:
In file included from /Users/dirkolbrich/freecad/freecad-source/src/App/DocumentObject.h:28:
In file included from /Users/dirkolbrich/freecad/freecad-source/src/App/TransactionalObject.h:27:
In file included from /Users/dirkolbrich/freecad/freecad-source/src/App/ExtensionContainer.h:33:
/Users/dirkolbrich/freecad/freecad-source/src/Base/Reader.h:32:10: fatal error: 'xercesc/framework/XMLPScanToken.hpp' file not found
#include <xercesc/framework/XMLPScanToken.hpp>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [src/Mod/Measure/App/CMakeFiles/Measure.dir/AppMeasure.cpp.o] Error 1
make[1]: *** [src/Mod/Measure/App/CMakeFiles/Measure.dir/all] Error 2
make: *** [all] Error 2

未找到的文件存在于 /usr/local/include/xercesc/framework/XMLPScanToken.hpp 的指定路径下,根据摘要报告并手动验证。

即使在 cmake 命令中添加 -DXERCESC_INCLUDE_DIR=/usr/include/xercesc 也无济于事。

构建脚本中有错字。 final report 打印出 XercesC_INCLUDE_DIRS, 但是该子目录的 CMakeLists.txt 使用 XERCESC_INCLUDE_DIR.

我建议您修正 src/Mod/Measure/App/CMakeLists.txt 中的拼写错误(改为 XercesC_INCLUDE_DIRS)并提交拉取请求。