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 prepare #11863

Merged
merged 4 commits into from
Aug 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1492,11 +1492,8 @@ if(WIN32)
# max-and-std-cpp-min-not-available-in-visual-c-2010
target_compile_definitions(mixxx-lib PUBLIC NOMINMAX UNICODE)

if(CMAKE_SIZEOF_VOID_P EQUAL 8)
target_compile_definitions(mixxx-lib PUBLIC WIN32)
else()
target_compile_definitions(mixxx-lib PUBLIC WIN64)
endif()
# shoutidjc/shout.h checks for WIN32 to see if we are on Windows.
target_compile_definitions(mixxx-lib PUBLIC WIN32)

target_link_libraries(mixxx-lib PRIVATE shell32)

Expand Down
112 changes: 112 additions & 0 deletions cmake/modules/FindSleef.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# This file is part of Mixxx, Digital DJ'ing software.
# Copyright (C) 2001-2023 Mixxx Development Team
# Distributed under the GNU General Public Licence (GPL) version 2 or any later
# later version. See the LICENSE file for details.

#[=======================================================================[.rst:
FindSleef
--------------

Finds the Sleef library.

Imported Targets
^^^^^^^^^^^^^^^^

This module provides the following imported targets, if found:

``Sleef::sleef``
The Sleef library

Result Variables
^^^^^^^^^^^^^^^^

This will define the following variables:

``Sleef_FOUND``
True if the system has the Sleef library.
``Sleef_INCLUDE_DIRS``
Include directories needed to use Sleef.
``Sleef_LIBRARIES``
Libraries needed to link to Sleef.
``Sleef_DEFINITIONS``
Compile definitions needed to use Sleef.

Cache Variables
^^^^^^^^^^^^^^^

The following cache variables may also be set:

``Sleef_INCLUDE_DIR``
The directory containing ``sleef.h``.
``Sleef_LIBRARY``
The path to the Sleef library.

#]=======================================================================]

find_package(PkgConfig QUIET)
if(PkgConfig_FOUND)
pkg_check_modules(PC_Sleef QUIET sleef)
endif()

find_path(Sleef_INCLUDE_DIR
NAMES sleef.h
PATHS ${PC_sleef_INCLUDE_DIRS}
DOC "Sleef include directory")
mark_as_advanced(Sleef_INCLUDE_DIR)

find_library(Sleef_LIBRARY
NAMES ${PC_Sleef_LIBRARIES}
PATHS ${PC_Sleef_LIBRARY_DIRS})
mark_as_advanced(Sleef_LIBRARY)

if(DEFINED PC_Sleef_VERSION AND NOT PC_Sleef_VERSION STREQUAL "")
set(Sleef_VERSION "${PC_Sleef_VERSION}")
else()
if (EXISTS "${sleef_INCLUDE_DIR}/sleef.h")
file(READ "$sleef{SLEEF_INCLUDE_DIR}/sleef.h" SLEEF_FIND_HEADER_CONTENTS)

set(SLEEF_MAJOR_PREFIX "#define SLEEF_VERSION_MAJOR ")
set(SLEEF_MINOR_PREFIX "#define SLEEF_VERSION_MINOR ")
set(SLEEF_PATCH_PREFIX "#define SLEEF_VERSION_PATCHLEVEL ")

string(REGEX MATCH "${SLEEF_MAJOR_PREFIX}[0-9]+"
SLEEF_MAJOR_VERSION "${SLEEF_FIND_HEADER_CONTENTS}")
string(REPLACE "${SLEEF_MAJOR_PREFIX}" "" SLEEF_MAJOR_VERSION
"${SLEEF_MAJOR_VERSION}")

string(REGEX MATCH "${SLEEF_MINOR_PREFIX}[0-9]+"
SLEEF_MINOR_VERSION "${SLEEF_FIND_HEADER_CONTENTS}")
string(REPLACE "${SLEEF_MINOR_PREFIX}" "" SLEEF_MINOR_VERSION
"${SLEEF_MINOR_VERSION}")

string(REGEX MATCH "${SLEEF_PATCH_PREFIX}[0-9]+"
SLEEF_SUBMINOR_VERSION "${SLEEF_FIND_HEADER_CONTENTS}")
string(REPLACE "${SLEEF_PATCH_PREFIX}" "" SLEEF_SUBMINOR_VERSION
"${SLEEF_SUBMINOR_VERSION}")

set(Sleef_VERSION
"${SLEEF_MAJOR_VERSION}.${SLEEF_MINOR_VERSION}.${SLEEF_SUBMINOR_VERSION}")
endif()
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
Sleef
REQUIRED_VARS Sleef_INCLUDE_DIR Sleef_LIBRARY
VERSION_VAR Sleef_VERSION)

if(Sleef_FOUND)
set(Sleef_LIBRARIES "${Sleef_LIBRARY}")
set(Sleef_INCLUDE_DIRS "${Sleef_INCLUDE_DIR}")
set(Sleef_DEFINITIONS ${PC_Sleef_CFLAGS_OTHER})

if(NOT TARGET Sleef::sleef)
add_library(Sleef::sleef UNKNOWN IMPORTED)
set_target_properties(Sleef::sleef
PROPERTIES
IMPORTED_LOCATION "${Sleef_LIBRARY}"
INTERFACE_COMPILE_OPTIONS "${PC_Sleef_CFLAGS_OTHER}"
INTERFACE_INCLUDE_DIRECTORIES "${Sleef_INCLUDE_DIR}"
)
endif()
endif()
18 changes: 15 additions & 3 deletions cmake/modules/Findrubberband.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,26 @@ if(rubberband_FOUND)
INTERFACE_COMPILE_OPTIONS "${PC_rubberband_CFLAGS_OTHER}"
INTERFACE_INCLUDE_DIRECTORIES "${rubberband_INCLUDE_DIR}"
)
is_static_library(rubberband_IS_STATIC Chromaprint::Chromaprint)
is_static_library(rubberband_IS_STATIC rubberband::rubberband)
if(rubberband_IS_STATIC)
find_package(FFTW REQUIRED)
find_library(SAMPLERATE_LIBRARY samplerate REQUIRED)
set_property(TARGET rubberband::rubberband APPEND PROPERTY INTERFACE_LINK_LIBRARIES
FFTW::FFTW
${SAMPLERATE_LIBRARY}
)
find_package(FFTW)
if (FFTW_FOUND)
set_property(TARGET rubberband::rubberband APPEND PROPERTY INTERFACE_LINK_LIBRARIES
FFTW::FFTW
)
endif()
find_package(Sleef)
if (Sleef_FOUND)
find_library(sleefdft_path sleefdft REQUIRED)
set_property(TARGET rubberband::rubberband APPEND PROPERTY INTERFACE_LINK_LIBRARIES
Sleef::sleef
${sleefdft_path}
)
endif()
Copy link
Member

Choose a reason for hiding this comment

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

whats the error like if neither sleef nor fftw is found?

Copy link
Member Author

Choose a reason for hiding this comment

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

Rubberband is linked one of it, which is the choice of the package provider. If the library is not found build will fail with a significant linker error.
I have no idea how to investigate which library is used to fail early.
We need to wait for the Rubberband CONFIG mode.

Copy link
Member

Choose a reason for hiding this comment

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

Couldn't we just detect if !fftw_FOUND && !Sleef_FOUND and error out early then? Sorry for the dumb questions, I'm not familiar enough with cmake. I'm just trying to wrap my head around it.

endif()
endif()
endif()
7 changes: 0 additions & 7 deletions src/broadcast/broadcastmanager.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
// shout.h checks for WIN32 to see if we are on Windows.
#ifdef WIN64
#define WIN32
#endif
#include <shoutidjc/shout.h>
#ifdef WIN64
#undef WIN32
#endif

#include "broadcast/broadcastmanager.h"
#include "broadcast/defs_broadcast.h"
Expand Down
7 changes: 0 additions & 7 deletions src/engine/sidechain/shoutconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,7 @@
#include <unistd.h>
#endif

// shout.h checks for WIN32 to see if we are on Windows.
#ifdef WIN64
#define WIN32
#endif
#include <shoutidjc/shout.h>
#ifdef WIN64
#undef WIN32
#endif

#include "broadcast/defs_broadcast.h"
#include "control/controlpushbutton.h"
Expand Down
2 changes: 1 addition & 1 deletion src/library/dao/trackdao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1381,7 +1381,7 @@ TrackPointer TrackDAO::getTrackById(TrackId trackId) const {
QString columnsStr;
int columnsSize = 0;
for (int i = 0; i < columnsCount; ++i) {
columnsSize += qstrlen(columns[i].name) + 1;
columnsSize += static_cast<int>(qstrlen(columns[i].name)) + 1;
}
columnsStr.reserve(columnsSize);
Comment on lines 1382 to 1386
Copy link
Member

Choose a reason for hiding this comment

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

I would've preferred changing columnsSize to std::size_t/qsizetype instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes that world be nice. However QT provides no common ground with qsizetype for QString.reserve(). So using int is the compatible solution.

Copy link
Member

Choose a reason for hiding this comment

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

What do you mean, "no common ground"? QString.reserve() takes a qsizetype on Qt6...

Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't auto use int on Qt5 and size_t on Qt6?

Copy link
Member Author

Choose a reason for hiding this comment

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

We need a cast anyway, because Qt6 uses std::ptrdifsize for reserve()

for (int i = 0; i < columnsCount; ++i) {
Expand Down
7 changes: 0 additions & 7 deletions src/preferences/dialog/dlgprefbroadcast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,8 @@
#include <QMessageBox>
#include <QHeaderView>

// shout.h checks for WIN32 to see if we are on Windows
#ifdef WIN64
#define WIN32
#endif
// this is needed to define SHOUT_META_* macros used in version guard
#include <shoutidjc/shout.h>
#ifdef WIN64
#undef WIN32
#endif

#include "broadcast/defs_broadcast.h"
#include "control/controlproxy.h"
Expand Down
7 changes: 0 additions & 7 deletions src/util/versionstore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,9 @@
#include <QtDebug>
#include <QtGlobal>

// shout.h checks for WIN32 to see if we are on Windows.
#ifdef WIN64
#define WIN32
#endif
#ifdef __BROADCAST__
#include <shoutidjc/shout.h>
#endif
#ifdef WIN64
#undef WIN32
#endif

#include <FLAC/format.h>
#include <chromaprint.h>
Expand Down