Skip to content

Commit

Permalink
Make sure we can find pyside on osx
Browse files Browse the repository at this point in the history
  • Loading branch information
jzampieron authored and wwmayer committed Sep 3, 2020
1 parent 4b8ebcc commit 29e1117
Show file tree
Hide file tree
Showing 4 changed files with 194 additions and 2 deletions.
61 changes: 61 additions & 0 deletions BUILD_OSX.md
@@ -0,0 +1,61 @@
# Building FreeCAD on Mac OS 10.15.x -- Catalina #

## Obtain Dependencies ##

The [FreeCAD Wiki](https://wiki.freecadweb.org/Third_Party_Libraries) has
a list of required deps. They are reproduced here for developers.

| Library Name | Version | Link to Obtain |
|:------------:|:----------:|:----------------------:|
| Python | >= 3.4 | http://www.python.org/ |
| Boost | >= 1.33 | http://www.boost.org/ |
| OpenCASCADE | >= 6.7 | http://www.opencascade.org |
| Qt | >= 5.6 | https://www.qt.io/ |
| Shiboken2 | same as Qt | https://wiki.qt.io/Qt_for_Python/Shiboken |
| PySide2 | same as Qt | https://wiki.qt.io/Qt_for_Python/Shiboken |
| Coin3D | >= 3.x | https://github.com/coin3d/coin |
| *SoQt | >= 1.2 | https://github.com/coin3d/soqt |
| Quarter | >= 1.0 | https://github.com/coin3d/quarter |
| Pivy | >= 0.6.5 | https://github.com/coin3d/pivy/ |
| FreeType | >= XXX | XXX |
| PyCXX | >= XXX | XXX |
| KDL | >= XXX | XXX |
| Point Cloud Library | >= XXX | XXX |
| Salome SMESH | >= XXX | XXX |
| VTK | >= 6.0 | XXX |
| Ply | >= 3.11 | https://www.dabeaz.com/ply/ |
| Xerces-C++ | >= 3.0 | https://xerces.apache.org/xerces-c/ |
| Eigen3 | >= 3.0 | http://eigen.tuxfamily.org/index.php?title=Main_Page |
| Zipios++ | >= 0.1.5 | https://snapwebsites.org/project/zipios, https://github.com/Zipios/Zipios |
| Zlib | >= 1.0 | http://www.zlib.net/, https://github.com/madler/zlib |
| libarea | >= 0.0.20140514-1 | https://github.com/danielfalck/libarea |

`*`: Deprecated

The easiest way on Mac to get the Dependencies is homebrew.

### Building MED ###

Note that the tests don't compile on GCC 10 or GCC 7. Kind of concerning.
Also we end up w/ MED using HDF5 @ 1.10 and VTK using 1.12... does this work?
```
mkdir build && \
pushd build && \
cmake -G Ninja \
-DMEDFILE_BUILD_TESTS=OFF \
-DHDF5_ROOT_DIR=/usr/local/opt/hdf5@1.10 ../ \
&& ninja \
&& ninja install
```

## Run CMake ##

```
mkdir freecad-build
cd freecad-build
cmake ../freecad-source \
-DBUILD_QT5=ON \
-DPYTHON_EXECUTABLE=/usr/local/bin/python3 \
-DHOMEBREW_PREFIX=/usr/local
make -j$(nproc --ignore=2)
```
27 changes: 27 additions & 0 deletions brew_install_osx_deps.sh
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

BREW_LIST=(ninja \
doxygen \
hdf5@1.10 \
boost \
xerces-c \
opencascade \
vtk \
swig \
qt5 \
freecad/freecad/coin \
boost-python3 \
pcl \
pyside \
libspnav \
pybind11 \
)

for pkg in ${BREW_LIST[@]}; do
echo "Brew Installing Pkg: ${pkg}"
brew install ${pkg}
if [ $? != 0 ]; then
echo "Failed to install ${pkg}"
exit 1
fi
done
104 changes: 104 additions & 0 deletions build.sh
@@ -0,0 +1,104 @@
##!/usr/bin/env bash

HOST=$(uname)

mkdir -p build
cd build

if [[ ${FEATURE_DEBUG} = 1 ]]; then
BUILD_TYPE="Debug"
else
BUILD_TYPE="Release"
fi

declare -a CMAKE_PLATFORM_FLAGS

if [[ ${HOST} =~ "Linux" ]]; then
PREFIX=/usr/local
echo "adding hacks for linux"
# temporary workaround for vtk-cmake setup
# should be applied @vtk-feedstock
sed -i 's#/home/conda/feedstock_root/build_artifacts/vtk_.*_build_env/x86_64-conda_cos6-linux-gnu/sysroot/usr/lib.*;##g' ${PREFIX}/lib/cmake/vtk-8.2/Modules/vtkhdf5.cmake
# temporary workaround for qt-cmake:
sed -i 's|_qt5gui_find_extra_libs(EGL.*)|_qt5gui_find_extra_libs(EGL "EGL" "" "")|g' $PREFIX/lib/cmake/Qt5Gui/Qt5GuiConfigExtras.cmake
sed -i 's|_qt5gui_find_extra_libs(OPENGL.*)|_qt5gui_find_extra_libs(OPENGL "GL" "" "")|g' $PREFIX/lib/cmake/Qt5Gui/Qt5GuiConfigExtras.cmake
CMAKE_PLATFORM_FLAGS+=(-DCMAKE_TOOLCHAIN_FILE="${RECIPE_DIR}/cross-linux.cmake")
CMAKE_PLATFORM_FLAGS+=(-DPYTHON_EXECUTABLE:FILEPATH=$PREFIX/bin/python)
fi


if [[ ${HOST} =~ "Darwin" ]]; then
# add hacks for osx here!
echo "adding hacks for osx"
PREFIX=/usr/local
#ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk

# install space-mouse
#curl -o /tmp/3dFW.dmg -L 'https://download.3dconnexion.com/drivers/mac/10-6-6_360DF97D-ED08-4ccf-A55E-0BF905E58476/3DxWareMac_v10-6-6_r3234.dmg'
#hdiutil attach -readonly /tmp/3dFW.dmg
#sudo installer -package /Volumes/3Dconnexion\ Software/Install\ 3Dconnexion\ software.pkg -target /
#diskutil eject /Volumes/3Dconnexion\ Software
#CMAKE_PLATFORM_FLAGS+=(-D3DCONNEXIONCLIENT_FRAMEWORK:FILEPATH="/Library/Frameworks/3DconnexionClient.framework")
CMAKE_PLATFORM_FLAGS+=(-DFREECAD_USE_3DCONNEXION:BOOL=OFF)
CMAKE_PLATFORM_FLAGS+=(-DFREECAD_CREATE_MAC_APP:BOOL=ON)
CMAKE_PLATFORM_FLAGS+=(-DPYTHON_EXECUTABLE=/usr/local/bin/python3)
CMAKE_PLATFORM_FLAGS+=(-DHOMEBREW_PREFIX=${PREFIX})
CMAKE_PLATFORM_FLAGS+=(-DHDF5_DIR:PATH=/usr/local/opt/hdf5@1.10)
CMAKE_PLATFORM_FLAGS+=(-DQt5Core_DIR=/usr/local/Cellar/qt5/5.15.0/lib/cmake/Qt5Core)
CMAKE_PLATFORM_FLAGS+=(-DQt5Network_DIR=/usr/local/Cellar/qt5/5.15.0/lib/cmake/Qt5Network)
CMAKE_PLATFORM_FLAGS+=(-DQt5Xml_DIR=/usr/local/Cellar/qt5/5.15.0/lib/cmake/Qt5Xml)
CMAKE_PLATFORM_FLAGS+=(-DQt5XmlPatterns_DIR=/usr/local/Cellar/qt5/5.15.0/lib/cmake/Qt5XmlPatterns)
CMAKE_PLATFORM_FLAGS+=(-DQt5Widgets_DIR=/usr/local/Cellar/qt5/5.15.0/lib/cmake/Qt5Widgets)
CMAKE_PLATFORM_FLAGS+=(-DQt5PrintSupport_DIR=/usr/local/Cellar/qt5/5.15.0/lib/cmake/Qt5PrintSupport)
CMAKE_PLATFORM_FLAGS+=(-DQt5OpenGL_DIR=/usr/local/Cellar/qt5/5.15.0/lib/cmake/Qt5OpenGL)
CMAKE_PLATFORM_FLAGS+=(-DQt5Svg_DIR=/usr/local/Cellar/qt5/5.15.0/lib/cmake/Qt5Svg)
CMAKE_PLATFORM_FLAGS+=(-DQt5UiTools_DIR=/usr/local/Cellar/qt5/5.15.0/lib/cmake/Qt5UiTools)
CMAKE_PLATFORM_FLAGS+=(-DQt5Concurrent_DIR=/usr/local/Cellar/qt5/5.15.0/lib/cmake/Qt5Concurrent)
CMAKE_PLATFORM_FLAGS+=(-DQt5WebEngineWidgets_DIR=/usr/local/Cellar/qt5/5.15.0/lib/cmake/Qt5WebEngineWidgets)
fi

cmake -G "Ninja" \
-D BUILD_WITH_CONDA:BOOL=ON \
-D CMAKE_BUILD_TYPE=${BUILD_TYPE} \
-D CMAKE_INSTALL_PREFIX:FILEPATH=$PREFIX \
-D CMAKE_PREFIX_PATH:FILEPATH=$PREFIX \
-D CMAKE_LIBRARY_PATH:FILEPATH=$PREFIX/lib \
-D CMAKE_INSTALL_LIBDIR:FILEPATH=$PREFIX/lib \
-D CMAKE_INCLUDE_PATH:FILEPATH=$PREFIX/include \
-D BUILD_QT5:BOOL=ON \
-D FREECAD_USE_OCC_VARIANT="Official Version" \
-D OCC_INCLUDE_DIR:FILEPATH=$PREFIX/include \
-D USE_BOOST_PYTHON:BOOL=OFF \
-D FREECAD_USE_PYBIND11:BOOL=ON \
-D BUILD_ENABLE_CXX11:BOOL=ON \
-D SMESH_INCLUDE_DIR:FILEPATH=$PREFIX/include/smesh \
-D FREECAD_USE_EXTERNAL_SMESH=ON \
-D BUILD_FLAT_MESH:BOOL=ON \
-D BUILD_FEM_NETGEN:BOOL=ON \
-D BUILD_PLOT:BOOL=OFF \
-D BUILD_SHIP:BOOL=OFF \
-D OCCT_CMAKE_FALLBACK:BOOL=OFF \
-D FREECAD_USE_QT_DIALOG:BOOL=ON \
-D BUILD_DYNAMIC_LINK_PYTHON:BOOL=OFF \
-D Boost_NO_BOOST_CMAKE:BOOL=ON \
-D FREECAD_USE_PCL:BOOL=ON \
-D INSTALL_TO_SITEPACKAGES:BOOL=ON \
${CMAKE_PLATFORM_FLAGS[@]} \
..

if [ $? != 0 ]; then
echo "Failed to configure with cmake."
exit 1
fi

echo "FREECAD_USE_3DCONNEXION=${FREECAD_USE_3DCONNEXION}"

ninja install

if [ $? != 0 ]; then
echo "Failed to compile with ninja"
exit 1
fi
rm -r ${PREFIX}/share/doc/FreeCAD # smaller size of package!
mv ${PREFIX}/bin/FreeCAD ${PREFIX}/bin/freecad
mv ${PREFIX}/bin/FreeCADCmd ${PREFIX}/bin/freecadcmd
4 changes: 2 additions & 2 deletions cMake/FindPySide2Tools.cmake
Expand Up @@ -33,9 +33,9 @@ IF(Qt5Core_VERSION VERSION_LESS 5.14)
set(RCCOPTIONS "")
ELSE(Qt5Core_VERSION VERSION_LESS 5.14)
# New (>= 5.14)
FIND_PROGRAM(PYSIDE2UICBINARY NAMES uic-qt5 uic)
FIND_PROGRAM(PYSIDE2UICBINARY NAMES uic-qt5 uic pyside2-uic)
set(UICOPTIONS "--generator=python")
FIND_PROGRAM(PYSIDE2RCCBINARY NAMES rcc-qt5 rcc)
FIND_PROGRAM(PYSIDE2RCCBINARY NAMES rcc-qt5 rcc pyside2-rcc)
set(RCCOPTIONS "--generator=python" "--compress-algo=zlib" "--compress=1")
ENDIF(Qt5Core_VERSION VERSION_LESS 5.14)

Expand Down

0 comments on commit 29e1117

Please sign in to comment.