Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix macOS Builds (and/or Build Instructions) #4374

Closed
wants to merge 3 commits into from

Conversation

elsiehupp
Copy link
Member

This is a draft pull request to fix #4365 and #4366.

Signed-off-by: Elsie Hupp <github@elsiehupp.com>
@elsiehupp elsiehupp changed the title Update macOS build instructions with Qt 6 dependency workaround Fix macOS Build Instructions Mar 22, 2022
@elsiehupp elsiehupp marked this pull request as draft March 22, 2022 17:37
@elsiehupp elsiehupp changed the title Fix macOS Build Instructions Fix macOS Builds (and/or Build Instructions) Mar 22, 2022
@elsiehupp
Copy link
Member Author

Hi @claucambra—can you take a look at this and maybe edit it so that it reflects the process necessary for build Nextcloud for Mac?

FWIW the existing instructions are almost 100% command-line-based, and if you're using the Qt Creator GUI, it may be obfuscating issues that would otherwise exist in the CMake scripts.

Ideally the build process should work with both the command line and the GUI, rather than requiring one or the other.

doc/building.rst Outdated
that depend on it. An update fixing the build process so that it will
work with both packages installed is forthcoming.

1. Certain Homebrew packages are not automatically linked in places where
the build scripts can find them, so you can create a shell-profile script
that will find and load them dynamically when you run a build:

Copy link
Collaborator

@claucambra claucambra Mar 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably add QtKeychain to the commands below:

echo 'export Qt5Keychain_DIR=$(brew --prefix qtkeychain)/lib/cmake/' >> ~/.nextcloud_build_variables

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or, why don't we just provide a CMake command here? Seems like it would be a lot easier to just say "go run this in the build folder":

cmake .. -DOPENSSL_ROOT_DIR=$(brew --prefix openssl) -DQt5_DIR=$(brew --prefix qt5)/lib/cmake/Qt5/ -DQt5Keychain_DIR=$(brew --prefix qtkeychain)/lib/cmake/ -DQt5LinguistTools_DIR=$(brew --prefix qt5)/lib/cmake/Qt5LinguistTools/

@claucambra
Copy link
Collaborator

Oh, and we will need to add instructions for build for Apple Silicon

At the moment I believe this involves building Qt5 and the other dependencies on an M1 equipped machine

@elsiehupp
Copy link
Member Author

I don't remember all of the reasons why the build instructions are the way they are, but the main thing is that the build command you end up using every time you run a build has to be simple enough to remember off the top of your head.

You can read through the gazillion comments here as well as the reasons why this isn't handled via CMake here and here. I really don't feel like revisiting either of those debates, but you can dive in if you feel so inclined.

My goal in this particular pull request is just to get macOS developer builds and the macOS build instructions actually working again. Like, the particulars aside, a good baseline should be the documentation not being broken, lol.

@claucambra
Copy link
Collaborator

I don't remember all of the reasons why the build instructions are the way they are, but the main thing is that the build command you end up using every time you run a build has to be simple enough to remember off the top of your head.

You can read through the gazillion comments here as well as the reasons why this isn't handled via CMake here and here. I really don't feel like revisiting either of those debates, but you can dive in if you feel so inclined.

My goal in this particular pull request is just to get macOS developer builds and the macOS build instructions actually working again. Like, the particulars aside, a good baseline should be the documentation not being broken, lol.

I wasn't around back then to know about this debate but if things are the way they are then there must be a good reason for it 🙂

AFAICT these instructions should work, at least on Intel Macs. Things get a little hairier on Apple Silicon Macs due to the architectures of the dependencies, primarily Qt5

Signed-off-by: Elsie Hupp <github@elsiehupp.com>
@elsiehupp
Copy link
Member Author

Replacing the following:

% echo 'export QT_PATH=$(brew --prefix qt5)/bin' >> ~/.nextcloud_build_variables

with the following:

% echo 'export Qt5_DIR=$(brew --prefix qt5)/lib/cmake/Qt5/' >> ~/.nextcloud_build_variables

Actually breaks the instructions:

CMake Error at src/CMakeLists.txt:7 (find_package):
  By not providing "FindQt5.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Qt5", but
  CMake did not find one.

  Could not find a package configuration file provided by "Qt5" (requested
  version 5.15) with any of the following names:

    Qt5Config.cmake
    qt5-config.cmake

  Add the installation prefix of "Qt5" to CMAKE_PREFIX_PATH or set "Qt5_DIR"
  to a directory containing one of the above files.  If "Qt5" provides a
  separate development package or SDK, be sure it has been installed.

Could you specify exactly what environmental variables need to be used here in order to avoid the conflict with Qt 6?

We also still need to correct the installation script at the end so that CMake spits out an application package rather than installing the build spread across the Linux-standard directories.

Signed-off-by: Elsie Hupp <github@elsiehupp.com>
@elsiehupp
Copy link
Member Author

AFAICT these instructions should work, at least on Intel Macs. Things get a little hairier on Apple Silicon Macs due to the architectures of the dependencies, primarily Qt5

Could you try and run the instructions from the top and see if they work for you? I'm still running into problems. Like uninstall all the dependencies (except maybe Xcode), wipe the environmental variables, and set them up again from scratch? Yes, this is tedious, but it's what I had to do last year to make sure the instructions worked back then.

FWIW with the changed Qt environmental variable I'm getting this error instead:


CMake Error at /usr/local/opt/qt@5/lib/cmake/Qt5Gui/Qt5GuiConfigExtras.cmake:9 (message):
  Failed to find "gl.h" in
  "/System/Library/Frameworks/OpenGL.framework/Headers;/System/Library/Frameworks/AGL.framework/Headers".
Call Stack (most recent call first):
  /usr/local/opt/qt@5/lib/cmake/Qt5Gui/Qt5GuiConfig.cmake:227 (include)
  /usr/local/opt/qt@5/lib/cmake/Qt5Quick/Qt5QuickConfig.cmake:93 (find_package)
  /usr/local/opt/qt@5/lib/cmake/Qt5WebEngineCore/Qt5WebEngineCoreConfig.cmake:93 (find_package)
  /usr/local/opt/qt@5/lib/cmake/Qt5WebEngineWidgets/Qt5WebEngineWidgetsConfig.cmake:93 (find_package)
  /usr/local/opt/qt@5/lib/cmake/Qt5/Qt5Config.cmake:28 (find_package)
  src/CMakeLists.txt:8 (find_package)

Also I'm getting this warning, which may have something to do with upgrading to 12.3:

CMake Warning at /usr/local/Cellar/cmake/3.22.3/share/cmake/Modules/Platform/Darwin-Initialize.cmake:303 (message):
  Ignoring CMAKE_OSX_SYSROOT value:

   /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk

  because the directory does not exist.
Call Stack (most recent call first):
  /usr/local/Cellar/cmake/3.22.3/share/cmake/Modules/CMakeSystemSpecificInitialize.cmake:21 (include)
  CMakeLists.txt:5 (project)

@nextcloud-desktop-bot
Copy link

AppImage file: Nextcloud-PR-4374-a1c78728bce9a6d36fba55835c7104ace0d38c14-x86_64.AppImage

To test this change/fix you can simply download above AppImage file and test it.

Please make sure to quit your existing Nextcloud app and backup your data.

@sonarcloud
Copy link

sonarcloud bot commented Mar 25, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@mgallien
Copy link
Collaborator

@elsiehupp thanks for your contribution
once we reach a state where this PR can be merged we will wait a bit more due to the preparation of the next feature release

@claucambra
Copy link
Collaborator

Hi @elsiehupp sorry for the lack of communication over the past 2 years (!!!), that's our bad

Today our build instructions and procedures have changed a lot on the macOS side of things, we have the mac-crafter helper that automates most things away. We have also moved to Qt 6 so a lot of things have changed

Thanks for all of your contributions, they are really appreciated (even if we take very long to review them properly)

@claucambra claucambra closed this Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build fails on macOS if qt6 is installed
4 participants