From c5cad121e5b68c2209fee2aa4611b1b609e2d4cf Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Mon, 26 Aug 2024 13:30:58 +0200 Subject: [PATCH] Add a CUPS config header In line with what's done for most optional, build-time configurable features, use a config header `config_cups.h` that has a `ENABLE_CUPS` define, include that header in the relevant source file and use #if ENABLE_CUPS for code depending on CUPS being enabled instead of defining a macro and using #ifdef ENABLE_CUPS This also aligns this with the `ENABLE_CPDB` macro used in the same source file. Change-Id: I71a5205fd63f9fc18470afcaf808c489ff833319 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172397 Tested-by: Jenkins Reviewed-by: Michael Weghorn --- RepositoryExternal.mk | 3 --- config_host/config_cups.h.in | 14 ++++++++++++++ configure.ac | 2 ++ sfx2/Library_sfx.mk | 4 ---- vcl/unx/generic/printer/ppdparser.cxx | 7 ++++--- 5 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 config_host/config_cups.h.in diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk index 1b2f147df595..2d35152eb0b8 100644 --- a/RepositoryExternal.mk +++ b/RepositoryExternal.mk @@ -2594,9 +2594,6 @@ endif # ENABLE_CPDB ifeq ($(ENABLE_CUPS),TRUE) define gb_LinkTarget__use_cups -$(call gb_LinkTarget_add_defs,$(1),\ - -DENABLE_CUPS \ -) $(call gb_LinkTarget_add_libs,$(1),\ -lcups \ diff --git a/config_host/config_cups.h.in b/config_host/config_cups.h.in new file mode 100644 index 000000000000..5dd46d67ba49 --- /dev/null +++ b/config_host/config_cups.h.in @@ -0,0 +1,14 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#define ENABLE_CUPS 0 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/configure.ac b/configure.ac index 98ec7071cba1..f441745f0b4b 100644 --- a/configure.ac +++ b/configure.ac @@ -6421,6 +6421,7 @@ if test "$test_cups" = yes -a "$enable_cups" != no; then if test "$ac_cv_lib_cups_cupsPrintFiles" != "yes" -o "$ac_cv_header_cups_cups_h" != "yes"; then AC_MSG_ERROR([Could not find CUPS. Install libcups2-dev or cups-devel.]) fi + AC_DEFINE([ENABLE_CUPS],[1]) else AC_MSG_RESULT([no]) fi @@ -15722,6 +15723,7 @@ AC_CONFIG_HEADERS([config_host/config_box2d.h]) AC_CONFIG_HEADERS([config_host/config_clang.h]) AC_CONFIG_HEADERS([config_host/config_cpdb.h]) AC_CONFIG_HEADERS([config_host/config_crypto.h]) +AC_CONFIG_HEADERS([config_host/config_cups.h]) AC_CONFIG_HEADERS([config_host/config_dconf.h]) AC_CONFIG_HEADERS([config_host/config_eot.h]) AC_CONFIG_HEADERS([config_host/config_extensions.h]) diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk index cda747e3d9b0..db88eaa72b40 100644 --- a/sfx2/Library_sfx.mk +++ b/sfx2/Library_sfx.mk @@ -44,10 +44,6 @@ $(eval $(call gb_Library_set_include,sfx,\ $(eval $(call gb_Library_add_defs,sfx,-DSFX2_DLLIMPLEMENTATION)) -$(eval $(call gb_Library_add_defs,sfx,\ - $(if $(filter TRUE,$(ENABLE_CUPS)),-DENABLE_CUPS) \ -)) - $(eval $(call gb_Library_use_libraries,sfx,\ basegfx \ comphelper \ diff --git a/vcl/unx/generic/printer/ppdparser.cxx b/vcl/unx/generic/printer/ppdparser.cxx index 40ba184603da..cc16c4f563bb 100644 --- a/vcl/unx/generic/printer/ppdparser.cxx +++ b/vcl/unx/generic/printer/ppdparser.cxx @@ -19,6 +19,7 @@ #include #include +#include #include @@ -55,7 +56,7 @@ #include #include -#ifdef ENABLE_CUPS +#if ENABLE_CUPS #include #endif @@ -568,7 +569,7 @@ const PPDParser* PPDParser::getParser( const OUString& rFile ) PrinterInfoManager& rMgr = PrinterInfoManager::get(); if( rMgr.getType() == PrinterInfoManager::Type::CUPS ) { -#ifdef ENABLE_CUPS +#if ENABLE_CUPS pNewParser = const_cast(static_cast(rMgr).createCUPSParser( aFile )); #endif } else if ( rMgr.getType() == PrinterInfoManager::Type::CPD ) @@ -617,7 +618,7 @@ PPDParser::PPDParser(OUString aFile, const std::vector& keys) if ( pKey ) { std::unique_ptr pImageableAreas(new PPDKey(u"ImageableArea"_ustr)); std::unique_ptr pPaperDimensions(new PPDKey(u"PaperDimension"_ustr)); -#ifdef ENABLE_CUPS +#if ENABLE_CUPS for (int i = 0; i < pKey->countValues(); i++) { const PPDValue* pValue = pKey -> getValue(i); OUString aValueName = pValue -> m_aOption;