solid: store libcdio package found/not found in config header

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2021-07-05 04:12:07 +03:00
parent 6729cc66d1
commit c35e7f76f3
4 changed files with 11 additions and 10 deletions

View file

@ -148,7 +148,6 @@ if(UDEV_FOUND)
backends/udev/udevopticaldisc.cpp backends/udev/udevopticaldisc.cpp
backends/udev/udevopticaldrive.cpp backends/udev/udevopticaldrive.cpp
) )
add_definitions(-DUDEV_CDIO)
include_directories(${LIBCDIO_INCLUDES}) include_directories(${LIBCDIO_INCLUDES})
set(solid_OPTIONAL_LIBS ${solid_OPTIONAL_LIBS} ${LIBCDIO_LIBRARIES}) set(solid_OPTIONAL_LIBS ${solid_OPTIONAL_LIBS} ${LIBCDIO_LIBRARIES})
endif() endif()

View file

@ -18,6 +18,7 @@
License along with this library. If not, see <http://www.gnu.org/licenses/>. License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "config-solid.h"
#include "udevdevice.h" #include "udevdevice.h"
#include "udevstoragedrive.h" #include "udevstoragedrive.h"
#include "udevstoragevolume.h" #include "udevstoragevolume.h"
@ -42,7 +43,7 @@
#include "kglobal.h" #include "kglobal.h"
#include "klocale.h" #include "klocale.h"
#ifdef UDEV_CDIO #if defined(LIBCDIO_FOUND)
#include "udevopticaldisc.h" #include "udevopticaldisc.h"
#include "udevopticaldrive.h" #include "udevopticaldrive.h"
#endif #endif
@ -175,7 +176,7 @@ QString UDevDevice::icon() const
{ {
if (parentUdi().isEmpty()) { if (parentUdi().isEmpty()) {
return QLatin1String("computer"); return QLatin1String("computer");
#ifdef UDEV_CDIO #if defined(LIBCDIO_FOUND)
// prioritize since it is a storage drive/disc too // prioritize since it is a storage drive/disc too
} else if (queryDeviceInterface(Solid::DeviceInterface::OpticalDrive)) { } else if (queryDeviceInterface(Solid::DeviceInterface::OpticalDrive)) {
const OpticalDrive drive(const_cast<UDevDevice*>(this)); const OpticalDrive drive(const_cast<UDevDevice*>(this));
@ -224,7 +225,7 @@ QString UDevDevice::icon() const
// fallback for every other optical disc // fallback for every other optical disc
return QLatin1String("media-optical"); return QLatin1String("media-optical");
#endif #endif // LIBCDIO_FOUND
} else if (queryDeviceInterface(Solid::DeviceInterface::StorageDrive)) { } else if (queryDeviceInterface(Solid::DeviceInterface::StorageDrive)) {
const StorageDrive storageIface(const_cast<UDevDevice *>(this)); const StorageDrive storageIface(const_cast<UDevDevice *>(this));
Solid::StorageDrive::DriveType drivetype = storageIface.driveType(); Solid::StorageDrive::DriveType drivetype = storageIface.driveType();
@ -315,7 +316,7 @@ QString UDevDevice::description() const
return QObject::tr("Computer"); return QObject::tr("Computer");
} }
#ifdef UDEV_CDIO #if defined(LIBCDIO_FOUND)
// prioritize since it is a storage drive/disc too // prioritize since it is a storage drive/disc too
if (queryDeviceInterface(Solid::DeviceInterface::OpticalDrive)) { if (queryDeviceInterface(Solid::DeviceInterface::OpticalDrive)) {
const OpticalDrive opticalDrive(const_cast<UDevDevice*>(this)); const OpticalDrive opticalDrive(const_cast<UDevDevice*>(this));
@ -378,7 +379,7 @@ QString UDevDevice::description() const
return description; return description;
} }
#endif // UDEV_CDIO #endif // LIBCDIO_FOUND
if (queryDeviceInterface(Solid::DeviceInterface::StorageDrive)) { if (queryDeviceInterface(Solid::DeviceInterface::StorageDrive)) {
const StorageDrive storageIface(const_cast<UDevDevice *>(this)); const StorageDrive storageIface(const_cast<UDevDevice *>(this));
Solid::StorageDrive::DriveType drivetype = storageIface.driveType(); Solid::StorageDrive::DriveType drivetype = storageIface.driveType();
@ -493,7 +494,7 @@ bool UDevDevice::queryDeviceInterface(const Solid::DeviceInterface::Type &type)
case Solid::DeviceInterface::Processor: case Solid::DeviceInterface::Processor:
return m_device.driver() == QLatin1String("processor"); return m_device.driver() == QLatin1String("processor");
#ifdef UDEV_CDIO #if defined(LIBCDIO_FOUND)
case Solid::DeviceInterface::OpticalDrive: case Solid::DeviceInterface::OpticalDrive:
case Solid::DeviceInterface::OpticalDisc: case Solid::DeviceInterface::OpticalDisc:
return (deviceProperty("ID_CDROM").toInt() == 1); return (deviceProperty("ID_CDROM").toInt() == 1);
@ -556,7 +557,7 @@ QObject *UDevDevice::createDeviceInterface(const Solid::DeviceInterface::Type &t
case Solid::DeviceInterface::Processor: case Solid::DeviceInterface::Processor:
return new Processor(this); return new Processor(this);
#ifdef UDEV_CDIO #if defined(LIBCDIO_FOUND)
case Solid::DeviceInterface::OpticalDrive: case Solid::DeviceInterface::OpticalDrive:
return new OpticalDrive(this); return new OpticalDrive(this);
case Solid::DeviceInterface::OpticalDisc: case Solid::DeviceInterface::OpticalDisc:

View file

@ -18,8 +18,8 @@
License along with this library. If not, see <http://www.gnu.org/licenses/>. License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "config-solid.h"
#include "udevmanager.h" #include "udevmanager.h"
#include "udevqt.h" #include "udevqt.h"
#include "udevdevice.h" #include "udevdevice.h"
#include "../shared/rootdevice.h" #include "../shared/rootdevice.h"
@ -152,7 +152,7 @@ UDevManager::UDevManager(QObject *parent)
<< Solid::DeviceInterface::AcAdapter << Solid::DeviceInterface::AcAdapter
<< Solid::DeviceInterface::Battery << Solid::DeviceInterface::Battery
<< Solid::DeviceInterface::Processor << Solid::DeviceInterface::Processor
#ifdef UDEV_CDIO #if defined(LIBCDIO_FOUND)
<< Solid::DeviceInterface::OpticalDrive << Solid::DeviceInterface::OpticalDrive
<< Solid::DeviceInterface::OpticalDisc << Solid::DeviceInterface::OpticalDisc
#endif #endif

View file

@ -21,3 +21,4 @@
#cmakedefine ENABLE_TESTING #cmakedefine ENABLE_TESTING
#cmakedefine UDEV_FOUND #cmakedefine UDEV_FOUND
#cmakedefine LIBCDIO_FOUND