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

Qt6 + ubuntu #4679

Merged
merged 11 commits into from
Feb 16, 2022
Merged

Qt6 + ubuntu #4679

merged 11 commits into from
Feb 16, 2022

Conversation

daschuer
Copy link
Member

This allows to build and run Mixxx on Ubuntu using https://launchpad.net/~daschuer/+archive/ubuntu/qt6-backports

The main issue was that CMake < 3.21 requires to use qt_finalize_target(mixxx) to ensure that the resources are all linked at the beginning of the mixxx binary.

@github-actions github-actions bot added the build label Feb 15, 2022
CMakeLists.txt Outdated
@@ -1256,7 +1256,12 @@ elseif(UNIX)
endif()

# The mixxx executable
add_executable(mixxx WIN32 src/main.cpp)
if(QT7 AND CMAKE_VERSION VERSION_LESS "3.21")
Copy link
Contributor

Choose a reason for hiding this comment

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

QT7?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ups, that is a debug leftover.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it is the best to rebase this out.

add_executable(mixxx WIN32 src/main.cpp)
if(QT7 AND CMAKE_VERSION VERSION_LESS "3.21")
find_package(Qt6 REQUIRED COMPONENTS Core) # For Qt Core cmake functions
qt_add_executable(mixxx WIN32 src/main.cpp MANUAL_FINALIZATION)
Copy link
Member

Choose a reason for hiding this comment

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

Please add a comment that explains why this is necessary.

Copy link
Member Author

Choose a reason for hiding this comment

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

In my test with cmake 3.16 it was actually not necessary.
It is just mentioned as the counterpart to the required qt-finalize-target which takes care of object order during linking. See https://doc.qt.io/qt-6/qt-finalize-target.html#qt6-finalize-target
So I think it is better to add it and follow the docs.

Copy link
Member

@Holzhaus Holzhaus Feb 16, 2022

Choose a reason for hiding this comment

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

From the docs I don't see any indication why this is only necessary on cmake < 3.21?

Copy link
Member Author

Choose a reason for hiding this comment

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

"This is especially important if using a statically built Qt or a CMake version earlier than 3.21."

There is also a pending PR that removes the related tests in the QT CI for cmake > 3.21. Unfortunately I do not have saved the link.

Copy link
Member

Choose a reason for hiding this comment

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

I read that too, but in my understanding it means "It's always important, but especially important on CMake < 3.21". So I don't think we should use a version guard here. Less code paths = less chances we run into weird bugs that CI doesn't detect or that we can't reproduce.

I tested it with this patch on CMake 3.22.2 and it works fine:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c7c7743072..f0f31773ea 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1265,12 +1265,10 @@ elseif(UNIX)
 endif()

 # The mixxx executable
-if(QT6 AND CMAKE_VERSION VERSION_LESS "3.21")
+if(QT6)
   find_package(Qt6 REQUIRED COMPONENTS Core) # For Qt Core cmake functions
   # qt_add_executable() is the recommended initial call for qt_finalize_target()
   # below that takes care of the correct object order in the resulting binary
-  # According to https://doc.qt.io/qt-6/qt-finalize-target.html it is importand for
-  # builds with Qt < 3.21
   qt_add_executable(mixxx WIN32 src/main.cpp MANUAL_FINALIZATION)
 else()
   add_executable(mixxx WIN32 src/main.cpp)
@@ -2208,11 +2206,9 @@ if(QT6)
   )
   target_link_libraries(mixxx-lib PRIVATE mixxx-qml-mixxxcontrolsplugin)

-  if(CMAKE_VERSION VERSION_LESS "3.21")
-    # qt_finalize_target takes care that the resources :/mixxx.org/imports/Mixxx/
-    # and :/mixxx.org/imports/Mixxx/Controls are placed into beginning of the binary
-    qt_finalize_target(mixxx)
-  endif()
+  # qt_finalize_target takes care that the resources :/mixxx.org/imports/Mixxx/
+  # and :/mixxx.org/imports/Mixxx/Controls are placed into beginning of the binary
+  qt_finalize_target(mixxx)
 endif()

 target_compile_definitions(mixxx-lib PUBLIC QT_TABLET_SUPPORT QT_USE_QSTRINGBUILDER)

@daschuer
Copy link
Member Author

Done

CMakeLists.txt Outdated
add_executable(mixxx WIN32 src/main.cpp)
if(QT6 AND CMAKE_VERSION VERSION_LESS "3.21")
find_package(Qt6 REQUIRED COMPONENTS Core) # For Qt Core cmake functions
# qt_add_executable() is the recomendet initial call for qt_finalize_target()
Copy link
Member

Choose a reason for hiding this comment

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

typo

Suggested change
# qt_add_executable() is the recomendet initial call for qt_finalize_target()
# qt_add_executable() is the recomended initial call for qt_finalize_target()

@ywwg
Copy link
Member

ywwg commented Feb 15, 2022

I get a bunch of this warning on my system for /usr/bin/cmake .. -DCMAKE_BUILD_TYPE=Debug -DOPTIMIZE=native -DQT6=on

CMake Warning (dev) in CMakeLists.txt:
  Policy CMP0099 is not set: Link properties are transitive over private
  dependency on static libraries.  Run "cmake --help-policy CMP0099" for
  policy details.  Use the cmake_policy command to set the policy and
  suppress this warning.
This warning is for project developers.  Use -Wno-dev to suppress it.

@daschuer
Copy link
Member Author

Regarding CMP0099, Qt deals with it if available and works around if it is not, so we can safely enable it since the old behavior is deprecated.

CMakeLists.txt Outdated
@@ -25,6 +25,14 @@ if(POLICY CMP0071)
cmake_policy(SET CMP0071 NEW)
endif()

# propagate interface link properties
if(POLICY CMP0099)
# this avoids a warning when qt deals with it see
Copy link
Member

Choose a reason for hiding this comment

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

Deals with what?

CMakeLists.txt Outdated
@@ -2178,7 +2194,7 @@ if(QT6)
URI Mixxx.Controls
VERSION 0.1
RESOURCE_PREFIX /mixxx.org/imports
OPTIONAL_IMPORTS Mixxx
IMPORTS Mixxx
Copy link
Member

Choose a reason for hiding this comment

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

This looks wrong, not every type in that module imports Mixxx. Also, why is this even part of this PR? It's not necessary to fix Mixxx on Ubuntu, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

It was necessary at one point during debugging. Now it still works even if I ommit the line entirely so it can be reverted.

add_executable(mixxx WIN32 src/main.cpp)
if(QT7 AND CMAKE_VERSION VERSION_LESS "3.21")
find_package(Qt6 REQUIRED COMPONENTS Core) # For Qt Core cmake functions
qt_add_executable(mixxx WIN32 src/main.cpp MANUAL_FINALIZATION)
Copy link
Member

@Holzhaus Holzhaus Feb 16, 2022

Choose a reason for hiding this comment

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

From the docs I don't see any indication why this is only necessary on cmake < 3.21?

@daschuer
Copy link
Member Author

Done.

@ywwg
Copy link
Member

ywwg commented Feb 16, 2022

works on my machine, thanks!

Copy link
Member

@Holzhaus Holzhaus left a comment

Choose a reason for hiding this comment

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

LGTM, thank you. Waiting for CI.

@Holzhaus Holzhaus merged commit d67b057 into mixxxdj:main Feb 16, 2022
@daschuer daschuer deleted the qt6_ubuntu branch April 14, 2022 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants