realthunder / FreeCAD

Link branch FreeCAD
Other
743 stars 47 forks source link

building linkdaily on macos `make install` issue #297

Open ipatch opened 2 years ago

ipatch commented 2 years ago

hello, 👋

i'm one of the maintainers of the homebrew-freecad tap, and am attempting to build your linkdaily branch on macos and am running into some issues related to pybind11

i'm not experiencing any issues with the make command, but rather the make install.

i believe the issue stems from the CMakeLists.txt within the /src/MacAppBundle directory, and I do not experience these issues compiling and installing the upstream freecad, ie. github.com/freecad/freecad master branch


i'm setting up my build directory with the below cmake command

cmake \
-DHOMEBREW_PREFIX="$bp" \
-DPYTHON_EXECUTABLE="$bp/bin/python3" \
-DPYTHON_INCLUDE_DIR="$bp/opt/python@3.9/Frameworks/Python.framework/Headers" \
-DBUILD_QT5=1 \
-DCMAKE_PREFIX_PATH="$pthxercesc;$pthocc;$pthmedfile;$ptheigen;$pthqt;$pthcoin;$pthtbb;$pthspnav;$pthnetgen;$pthgraphviz" \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DBUILD_ENABLE_CXX_STD=C++17 \
-DFREECAD_CREATE_MAC_APP=1 \
-DFREECAD_USE_PYBIND11=1 \
-DBUILD_FEM_NETGEN=1 \
-DCMAKE_INSTALL_PREFIX="$code/freecad-git/installs/mar22.01.22.linkdaily" \
../../freecad-src

using that above cmake command sets up the below logic in the cmake_install.cmake file

if("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "xUnspecifiedx" OR NOT CMAKE_INSTALL_COMPONENT)                                                               list(APPEND CMAKE_ABSOLUTE_DESTINATION_FILES                                                                                                            "/opt/code/freecad-git/installs/mar22.01.22.linkdaily/FreeCAD.app/Contents/libexec/import site site.addsitedir('/Users/brewmaster/homebrew/Cellar/pybind11/2.9.1/libexec/lib/python3.9/site-packages')/lib/python3.9')/import site;/opt/code/freecad-git/installs/mar22.01.22.linkdaily/FreeCAD.app/Contents/libexec/import site site.addsitedir('/Users/brewmaster/homebrew/Cellar/pybind11/2.9.1/libexec/lib/python3.9/site-packages')/lib/python3.9')/site-packages')")
  if(CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION)
    message(WARNING "ABSOLUTE path INSTALL DESTINATION : ${CMAKE_ABSOLUTE_DESTINATION_FILES}")
  endif()
  if(CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION)                                                                                                          message(FATAL_ERROR "ABSOLUTE path INSTALL DESTINATION forbidden (by caller): ${CMAKE_ABSOLUTE_DESTINATION_FILES}")                                  endif()                                                                                                                                                file(INSTALL DESTINATION "/opt/code/freecad-git/installs/mar22.01.22.linkdaily/FreeCAD.app/Contents/libexec/import site site.addsitedir('/Users/brewmaster/homebrew/Cellar/pybind11/2.9.1/libexec/lib/python3.9/site-packages')/lib/python3.9')" TYPE DIRECTORY FILES
    "/opt/code/freecad-git/freecad-src/src/MacAppBundle/import site"                                                                                       "/opt/code/freecad-git/freecad-src/src/MacAppBundle/ site.addsitedir('/Users/brewmaster/homebrew/Cellar/pybind11/2.9.1/libexec/lib/python3.9/site-packages')"
    )
endif()

forgive me for the formatting of the above code snippet that's how it's being copied to my clipboard FWR 😑

i can obviously go hacking into the CMakeLists.txt file, but prefer to get this working in a less hack way if possible.

and thanks for making such awesome/ambitious fork of freecad, looking forward to publish a release based on your linkdaily branch.


update i've amended my above cmake command with the below python include dir to see it makes a difference, waiting on the rebuild now,

-DPYTHON_INCLUDE_DIR=$(python -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())")
ipatch commented 2 years ago

update

got the same results using either of the two examples for the,

-DPYTHON_INCLUDE_DIR=

results, ouput from make install

CMake Error at src/MacAppBundle/cmake_install.cmake:55 (file):
  file INSTALL cannot find
  "/opt/code/freecad-git/freecad-src/src/MacAppBundle/import site": No such
  file or directory.
Call Stack (most recent call first):
  src/cmake_install.cmake:51 (include)
  cmake_install.cmake:68 (include)

make: *** [install] Error 1
realthunder commented 2 years ago

Can you please post the full cmake command output, with both stdout and stderr capture? I use roughly the same cmake command as yours to build my release, but I am not that familiar with MacOS.

PS. I use a custom branch of Coin3D for my release, which contains some additional visual features. I use brew edit to build a local package for that. It is not compulsory though, as the official Coin3D can still be used.

ipatch commented 2 years ago

a little follow up to my 2nd comment above, the below error message line,

"/opt/code/freecad-git/freecad-src/src/MacAppBundle/import site": No such

is related to the homebrew specific .pth file related to pybind11, specifically

$(brew --prefix)/Cellar/pybind11/2.9.1/lib/python3.9/site-packages/homebrew-pybind11.pth

which contains

import site; site.addsitedir('/Users/brewmaster/homebrew/Cellar/pybind11/2.9.1/libexec/lib/python3.9/site-packages')

i believe the current CMakeLists.txt is unable to process the import site; as it is not run through the python interpreter. the hacky fix is to update the contents of that file to,

/Users/brewmaster/homebrew/Cellar/pybind11/2.9.1/libexec/lib/python3.9/site-packages

obviously that path needs to be updated for the specific $USER homebrew prefix ie. $(brew --prefix)

luzpaz commented 2 years ago

Anymore progress with this?

ipatch commented 2 years ago

been doing some work on an updated build...

i believe if you add the below lines to your mac app bundling CMakeLists.txt it should prevent the error i describing above. i have tested this locally on my machine.

https://github.com/FreeCAD/FreeCAD/blob/cd53c06b9899b03fe88d2a2fe8258422e7ac9c09/src/MacAppBundle/CMakeLists.txt#L35-L38

luzpaz commented 2 years ago

Nice!