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

🚀 Replace vcpkg with conan #641

Open
wants to merge 84 commits into
base: master
Choose a base branch
from

Conversation

AnotherFoxGuy
Copy link
Contributor

@AnotherFoxGuy AnotherFoxGuy commented Sep 24, 2023

This PR is still a work in progress, but the interface should built and run on both Windows and Linux

TODO

  • Fix broken avatars
  • Replace cmake/externals with conan packages
  • Update GitHub actions to use conan
  • Fix other components
  • Fix Debug build
  • Fix tests build
  • Fix manual tests build
  • Fix tools build
  • Fix and test WebRTC

How to build on Windows with conan
Add the remote
conan remote add overte https://git.anotherfoxguy.com/api/packages/overte/conan
Install the deps with conan
conan install . -b missing -pr:b=tools/conan-profiles/vs-19-release -pr=tools/conan-profiles/vs-19-release -of build
Generate the VS project files
cmake --preset conan-default
(Note: Currently only the Release build can be built)

How to build on Linux with conan
Let conan detect the build environment
conan profile detect
Add the remote
conan remote add overte https://git.anotherfoxguy.com/api/packages/overte/conan
Install the deps with conan
conan install . -s build_type=Release -b missing -of build
Generate the make files
cmake --preset conan-default
Build the interface
cd build && make

@AnotherFoxGuy

This comment was marked as resolved.

@AnotherFoxGuy AnotherFoxGuy force-pushed the conan branch 2 times, most recently from 1f6bfe1 to 705a375 Compare September 27, 2023 11:55
@AnotherFoxGuy AnotherFoxGuy marked this pull request as ready for review September 27, 2023 14:04
Copy link
Member

@JulianGro JulianGro left a comment

Choose a reason for hiding this comment

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

A little comment on vhacd-util: As far as I know this is somewhat legacy. Our engine will automatically generate collision hulls and doesn't use vhacd-util for that. vhacd-util could be very useful for generating performant collision hulls for more complicated objects, but I don't think anyone does that. In fact, I have never even tried using it, and don't even know if it works.

tc.variables["BUILD_TOOLS"] = "OFF"
tc.variables["USE_CUDA"] = "OFF"
if self.settings.os == "Linux":
tc.variables["CMAKE_CXX_FLAGS"] = "-march=msse3 -fPIC"
Copy link
Member

Choose a reason for hiding this comment

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

This would break on aarch64, which technically Overte can currently run on.

cmake/macros/AutoScribeShader.cmake Outdated Show resolved Hide resolved
set(QTAUDIO_PATH "$<TARGET_FILE_DIR:${TARGET_NAME}>/audio")
set(QTAUDIO_WIN7_PATH "$<TARGET_FILE_DIR:${TARGET_NAME}>/audioWin7/audio")
set(QTAUDIO_WIN8_PATH "$<TARGET_FILE_DIR:${TARGET_NAME}>/audioWin8/audio")
# TODO: Is this still needed? needs testing
Copy link
Member

Choose a reason for hiding this comment

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

Windows 7 and Windows 8(.1) are End Of Life and therefore also not supported by us anymore.

@@ -7,5 +7,9 @@
#
macro(TARGET_JSON)
# We use vcpkg for both json and glm, so we just re-use the target_glm macro here
Copy link
Member

Choose a reason for hiding this comment

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

We will have to remember to remove this.

CMakeLists.txt Outdated
@@ -15,67 +15,32 @@ endif()
# 3.14 is the minimum version that supports symlinks on Windows
cmake_minimum_required(VERSION 3.14)
Copy link
Member

Choose a reason for hiding this comment

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

Don't be shy about bumping this version if there is a reason to. VCPKG required a much higher CMake version than this anyway.

@@ -0,0 +1,3 @@
versions:
"2019.02":
Copy link
Member

Choose a reason for hiding this comment

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

Does this version the conan-recipe?

"qt*:qtxmlpatterns": "True",
"glad*:spec": "gl",
"glad*:gl_profile": "core",
"glad*:gl_version": "4.6",
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if you know, but Overte supports multiple OpenGL versions. For example, it will fall back to OpenGL 4.1 if OpenGL 4.6 is not available. It can also be built for OpenGL ES 3.2.
I don't know how this part of the Conan code works though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just the targeted version for glad, I just copied the settings from the vcpkg package

@@ -68,8 +68,8 @@ foreach(EXTERNAL ${OPTIONAL_EXTERNALS})
endif ()
endforeach()

find_package(Qt5LinguistTools REQUIRED)
find_package(Qt5LinguistToolsMacros)
# find_package(Qt5LinguistTools REQUIRED)
Copy link
Member

Choose a reason for hiding this comment

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

As you might know, we would like to add (more) localization support to Overte, but this is currently unused.

@@ -0,0 +1,8 @@
[settings]
os=Windows
arch=x86_64
Copy link
Member

Choose a reason for hiding this comment

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

We don't currently have any plans for an aarch64 Windows version, but would it make sense to have the profile name reflect the architecture?

@@ -217,7 +217,7 @@ def processCommand(line):
executeSubprocess(scribeArgs)

# Generate the un-optimized output
executeSubprocess([glslangExec, '-V110', '-o', upoptSpirvFile, unoptGlslFile])
executeSubprocess([glslangExec, '-V100', '-o', upoptSpirvFile, unoptGlslFile])
Copy link
Member

Choose a reason for hiding this comment

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

Could you explain what this change is doing? Looking it up online it seems like this switches to an older Visual Studio toolchain?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The glslangValidator from the conan package is too old to support that version, it needs to be updated

@JulianGro
Copy link
Member

A comment on building this on Linux:
Since Conan is not available as a distribution package (at least not on Debian), but rather a pip package, the installation procedure is not that trivial.

# Install python3 virtual environment
sudo apt install python3-venv
# Create a virtual environment in the Overte codebase
python3 -m venv .venv
# Install pip dependencies
.venv/bin/pip3 install conan
# Now one can run conan
.venv/bin/conan profile detect

@JulianGro

This comment was marked as resolved.

@AnotherFoxGuy

This comment was marked as resolved.

@JulianGro
Copy link
Member

Am I understanding it right that Conan is supposed to only get dependencies of its own if the system doesn't already provide them?
If yes, we should probably always depend on a version range, from the oldest version that we know works, to the newest version that we know works. With libopus we would get version 1.3.1 from the system on Ubuntu 20.04.
Or does Conan "only" provide the tools for us to conditionally use system packages on our own?

@AnotherFoxGuy
Copy link
Contributor Author

Am I understanding it right that Conan is supposed to only get dependencies of its own if the system doesn't already provide them?

That is really dependent on how the conan recipes are written.
The recipes provided by the conan-center are always using conan packages to make packaging easier and more reproducible.
But it is possible to script conan to install system packages, for example the xorg recipe just installs the appropriate system packages https://github.com/conan-io/conan-center-index/blob/master/recipes/xorg/all/conanfile.py#L26

@JulianGro

This comment was marked as resolved.

@JulianGro
Copy link
Member

JulianGro commented Oct 2, 2023

It would be nice if you could put a README into the conan-recipes directory on how to consume those and how to update them.

It seems like I can build node for example using a command like

../../.venv/bin/conan create all/conanfile.py --version 18.17.1

@JulianGro

This comment was marked as resolved.

@AnotherFoxGuy

This comment was marked as resolved.

@JulianGro
Copy link
Member

Something to figure out later: The resulting binary seems to be searching for the Qt platform plugins in the wrong directory.

juliangro@x299-desktop:~/git/overte/build$ QT_DEBUG_PLUGINS=1 ./interface/interface --disable-displays "OpenVR (Vive)" --disable-inputs "OpenVR (Vive)","Sdl2" --allowMultipleInstances
[10/02 23:02:35] [DEBUG] [hifi.shared] Settings file: "/home/juliangro/.config/Overte - dev/Interface.json"
[10/02 23:02:35] [DEBUG] [settings.manager] Initializing settings write thread
[10/02 23:02:35] [WARNING] [default] QEventLoop: Cannot be used without QApplication
[10/02 23:02:35] [DEBUG] [default] UserActivityLogger is enabled: false
[10/02 23:02:35] [INFO] [default] Disabling following display plugins: ("OpenVR (Vive)")
[10/02 23:02:35] [WARNING] [default] DependencyManager::get(): No instance available for 13PluginManager
[10/02 23:02:35] [INFO] [default] Disabling following input plugins: ("OpenVR (Vive)", "Sdl2")
[10/02 23:02:35] [WARNING] [default] DependencyManager::get(): No instance available for 13PluginManager
[10/02 23:02:35] [DEBUG] [default] QFactoryLoader::QFactoryLoader() checking directory path "/home/juliangro/git/overte/build/interface/platforms" ...
[10/02 23:02:35] [WARNING] [qt.qpa.plugin] Could not find the Qt platform plugin "xcb" in ""
[10/02 23:02:35] [FATAL] [default] This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
[10/02 23:02:35] [FATAL] [default] 
Abgebrochen (Speicherabzug geschrieben)
juliangro@x299-desktop:~/git/overte/build$ 

@JulianGro
Copy link
Member

Building libnode through conan fails on Ubuntu 20.04.
profile detect seems to have chosen C++14, while libnode seems to require C++17 or higher to build.
Log: https://bin.linux.pizza/?3ad49c3deaebf232#5NxEbsMUNagxtaMvnFJxm3dpWXTt2Ja5CJQrYio89wAR

@JulianGro
Copy link
Member

Just tried on aarch64 postmarketOS. (I cannot select text or pipe it to file for some reason.)
Screenshot_20231007_202237
It looks like it is trying to install gl through the Alpine Package manager, which is not a valid package name. Unfortunately, Conan Center is having issues, so I don't know how to take a look at the source code.

@AnotherFoxGuy
Copy link
Contributor Author

I don't know how to take a look at the source code.

The source for the package is here:
https://github.com/conan-io/conan-center-index/blob/master/recipes/opengl/all/conanfile.py

@JulianGro
Copy link
Member

Installing a bunch of packages fixed the gl issue.
Screenshot_20231007_221300

@ksuprynowicz
Copy link
Member

I built it from source and tested, Interface works perfectly, and build time is so much faster than vcpkg :)

@ksuprynowicz
Copy link
Member

I tested server too and works well

@ksuprynowicz
Copy link
Member

What else should we do before merging?

@ksuprynowicz
Copy link
Member

Maybe test Windows version once github actions work on this PR?

@JulianGro
Copy link
Member

JulianGro commented Jan 22, 2025

Well, technically there is a lot:

  • Make sure AppImages still build (fix them if needed)
  • Make sure server packages still build (fix them if needed)
  • Update GitHub Actions to use Conan (shouldn't take much work at all)
  • Make sure that aarch64 still builds (fix if needed)
  • Fix libraries without searchpaths being copied next to the Interface binary (thought, as long as Interface doesn't link to them, this shouldn't be causing problems)
  • Figure out where to get Qt from

@JulianGro
Copy link
Member

Also, I am perfectly fine with doing the GitHub Actions stuff. Last time I just waited because I saw Edgar experimenting with some cool stuff, like calling Conan from CMake (instead of calling Conan before CMake).

@JulianGro
Copy link
Member

JulianGro commented Jan 23, 2025

So, there is the problem of Qt:
In master, we get Qt as part of the pre-build step on systems where it isn't available through a package manager.
On Windows, I wouldn't be against having people just run the Qt installer, but on Linux this sounds like a mess. People are already going to have Qt, so installing it will make that multiple versions which we have to pick from. Not to mention the Qt installer requiring a Qt account to use, which is a deal breaker in my opinion.

Personally, the best solution I can think of is to do exactly what we already do in master: Run a pre-build step, which gets Qt for us if necessary. This also allows us to get and run Conan automagically, same as we do with VCPKG on master.

This still fails as upstream Qt includes an old bug in qtlocation/src/3rdparty/mapbox-gl-native/include/mbgl/util/geometry.hpp; We should switch to KDE's Qt patchset as it has issues like this patched and we already use it on VCPKG. (https://invent.kde.org/qt/qt/qt5/-/tree/kde/5.15)
@JulianGro

This comment was marked as resolved.

@AnotherFoxGuy
Copy link
Contributor Author

Run a pre-build step, which gets Qt for us if necessary

I think it would be better to create a conan package for the prebuild QT, otherwise you can run into weird issues with other conan packages that depend on QT

@JulianGro
Copy link
Member

Yeah, right now I am thinking we should use Conan's Qt package on any system where it is necessary.
I was thinking we should have a prebuild step to decide which package to use, but I think right now we should probably just get this out of the door and think about a prebuild step later.

@JulianGro
Copy link
Member

@AnotherFoxGuy I tried getting Qt to build, but upstream isn't compatible with GCC13 and above. As mentioned in 992221b I believe we should use KDE's Qt patchset instead of Trolltech's Qt upstream. That would entail us adding yet another recipe. I have to go for now though, so if you have time and want to give it a try…

@JulianGro
Copy link
Member

JulianGro commented Jan 24, 2025

I need a break.
Current issues:

  • Building with system Qt causes some ssl issues later down the line, both on my machine and on GitHub Actions:
-- Conan: Target declared 'openssl::openssl'
CMake Error at build/generators/cmakedeps_macros.cmake:67 (message):
  Library 'ssl' not found in package.  If 'ssl' is a system library, declare
  it with 'cpp_info.system_libs' property
Call Stack (most recent call first):
  build/generators/openssl_system-Target-release.cmake:23 (conan_package_library_targets)
  build/generators/openssl_systemTargets.cmake:24 (include)
  build/generators/openssl_system-config.cmake:16 (include)
  /usr/share/cmake-3.31/Modules/CMakeFindDependencyMacro.cmake:76 (find_package)
  build/generators/libnode-config.cmake:24 (find_dependency)
  cmake/macros/TargetV8.cmake:10 (find_package)
  libraries/script-engine/CMakeLists.txt:10 (target_v8)


-- Configuring incomplete, errors occurred!
  • Building with Conan Qt fails on GitHub Actions with some weird undefined symbol error in cpython. This doesn't happen on my local machine.
  • Windows has issues with Python when building Qt.
  • Building locally with Qt fails for me during the Overte build process. It throws tons of undefined references. Looking at libscript-engine.so, it doesn't link against libnode! I double checked and it is definitely supposed to link against libnode (at least it does so outside of the conan branch).
[ 38%] Linking CXX executable skeleton-dump
/usr/bin/ld: ../../libraries/script-engine/libscript-engine.so: undefined reference to `v8::CpuProfileNode::GetChildrenCount() const'
/usr/bin/ld: ../../libraries/script-engine/libscript-engine.so: undefined reference to `v8::PropertyDescriptor::~PropertyDescriptor()'
/usr/bin/ld: ../../libraries/script-engine/libscript-engine.so: undefined reference to `v8::Locker::Initialize(v8::Isolate*)'
…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs QA This pull request needs to be tested NLnet
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

6 participants