diff --git a/recipes/log4cxx/all/conandata.yml b/recipes/log4cxx/all/conandata.yml index 6e4b69d1303a5..5f5b6f75de86a 100644 --- a/recipes/log4cxx/all/conandata.yml +++ b/recipes/log4cxx/all/conandata.yml @@ -1,23 +1,46 @@ sources: + "1.2.0": + url: "https://archive.apache.org/dist/logging/log4cxx/1.2.0/apache-log4cxx-1.2.0.tar.gz" + sha256: "09f4748aa5675ef5c0770bedbf5e00488668933c5a935a43ac5b85be2436c48a" "1.1.0": url: "https://archive.apache.org/dist/logging/log4cxx/1.1.0/apache-log4cxx-1.1.0.tar.gz" sha256: "1fc7d82697534184bc0f757348d969d24852b948f63d6b17283fd1ee29c2c28a" + "0.13.0": + url: "https://archive.apache.org/dist/logging/log4cxx/0.13.0/apache-log4cxx-0.13.0.tar.gz" + sha256: "4e5be64b6b1e6de8525f8b87635270b81f772a98902d20d7ac646fdf1ac08284" "0.12.1": url: "https://archive.apache.org/dist/logging/log4cxx/0.12.1/apache-log4cxx-0.12.1.tar.gz" sha256: "7bea5cb477f0e31c838f0e1f4f498cc3b30c2eae74703ddda923e7e8c2268d22" - "0.12.0": - url: "https://archive.apache.org/dist/logging/log4cxx/0.12.0/apache-log4cxx-0.12.0.tar.gz" - sha256: "bd5b5009ca914c8fa7944b92ea6b4ca6fb7d146f65d526f21bf8b3c6a0520e44" patches: + "1.2.0": + - patch_file: "patches/1.2.0-0001-find-apr.patch" + patch_description: "use cci's package name" + patch_type: "conan" "1.1.0": - patch_file: "patches/1.1.0-0001-find-apr.patch" patch_description: "use cci's package name" patch_type: "conan" - "0.12.1": - - patch_file: "patches/0.12.0-0001-find-apr.patch" - patch_description: "use cci's package name" + "0.13.0": + - patch_file: "patches/0.13.0-0001-find-apr.patch" patch_type: "conan" - "0.12.0": - - patch_file: "patches/0.12.0-0001-find-apr.patch" + patch_description: "Use conan generated apr, apr-util target names" + - patch_file: "patches/0.13.0-0001-logchar-type.patch" + patch_type: "bugfix" + patch_description: "Prevent compilation errors when with_wchar_t=False" + patch_source: "https://github.com/apache/logging-log4cxx/commit/5109466a844d1e5fb8b455a23077765a30325a24" + - patch_file: "patches/0.13.0-0001-visual-studio-15.patch" + patch_type: "bugfix" + patch_description: "Prevent Visual Studio 2017 compilation error" + patch_source: "https://github.com/apache/logging-log4cxx/commit/f59bf53f831b8b68ef3a2f3a6705ae626090758e" + - patch_file: "patches/0.13.0-0001-fix-static-library-compilation.patch" + patch_type: "bugfix" + patch_description: "Prevent compilation error when shared=False" + patch_source: "https://github.com/apache/logging-log4cxx/commit/09b5b723a1a210c28bf8b05b0676bb2b104359ba" + "0.12.1": + - patch_file: "patches/0.12.1-0001-find-apr.patch" patch_description: "use cci's package name" patch_type: "conan" + - patch_file: "patches/0.12.1-0001-logchar-type.patch" + patch_type: "bugfix" + patch_description: "Prevent compilation errors when with_wchar_t=False" + patch_source: "https://github.com/apache/logging-log4cxx/commit/5109466a844d1e5fb8b455a23077765a30325a24" diff --git a/recipes/log4cxx/all/conanfile.py b/recipes/log4cxx/all/conanfile.py index f7fedd1522a39..4429e3e63b17f 100644 --- a/recipes/log4cxx/all/conanfile.py +++ b/recipes/log4cxx/all/conanfile.py @@ -24,15 +24,44 @@ class Log4cxxConan(ConanFile): options = { "shared": [True, False], "fPIC": [True, False], + "char_type": ["utf-8", "wchar_t", "unichar"], + "char_encoding": ["utf-8", "locale"], + "with_networking": [True, False], + "with_wchar_t": [True, False], + "with_fmt_layout": [True, False], + "with_odbc_appender": [True, False], + "with_multiprocess_rolling_file_appender": [True, False], + "with_smtp_appender": [True, False], + "with_qt": [True, False], + } + options_description = { + "char_type": "The log4cxx internal character type (selects the std::basic_string template parameter used by log4cxx::LogString)", + "char_encoding": "The external character set used when writing to files", + "with_networking": "Include appenders that use network i/o", + "with_wchar_t": "Include wchar_t API methods in class interfaces", + "with_fmt_layout": "Include the log4cxx::FMTLayout class that uses libfmt to layout messages", + "with_odbc_appender": "Include the log4cxx::ODBCAppender that sends log events to a database", + "with_multiprocess_rolling_file_appender": "Include the appender that allows multiple applications to log to the same file", + "with_smtp_appender": "Include the appender that sends an e-mail when a specific logging event occurs", + "with_qt": "Allow QString values in the LOG4CXX_WARN, LOG4CXX_INFO, LOG4CXX_DEBUG etc. macros", } default_options = { "shared": False, "fPIC": True, + "char_type": "utf-8", + "char_encoding": "utf-8", + "with_networking": True, + "with_wchar_t": False, + "with_fmt_layout": False, + "with_odbc_appender": False, + "with_multiprocess_rolling_file_appender": False, + "with_smtp_appender": False, + "with_qt": False, } @property def _min_cppstd(self): - return 17 + return 11 @property def _compilers_minimum_version(self): @@ -49,7 +78,14 @@ def export_sources(self): def config_options(self): if self.settings.os == "Windows": - del self.options.fPIC + self.options.rm_safe("fPIC") + self.options.rm_safe("with_smtp_appender") # *nix only + elif Version(self.version) <= "1.0.0": # SMTP appender is broken in version 0.12 through 1.0.0 + self.options.rm_safe("with_smtp_appender") + if Version(self.version) < "1.0.0": + self.options.rm_safe("with_multiprocess_rolling_file_appender") + self.options.rm_safe("with_networking") + self.options.rm_safe("with_fmt_layout") def configure(self): if self.options.shared: @@ -61,17 +97,31 @@ def layout(self): def requirements(self): self.requires("apr/1.7.4") self.requires("apr-util/1.6.1") - self.requires("expat/2.5.0") - if self.settings.os != "Windows": + if self.options.get_safe("with_odbc_appender") and self.settings.os != "Windows": self.requires("odbc/2.3.11") + if self.options.get_safe("with_smtp_appender"): + self.requires("libesmtp/1.1.0") + if self.options.get_safe("with_fmt_layout"): + self.requires("fmt/10.2.1") + if self.options.get_safe("with_qt"): + self.requires("qt/5.15.12") def validate(self): - # TODO: if compiler doesn't support C++17, boost can be used instead - if self.settings.compiler.get_safe("cppstd"): - check_min_cppstd(self, self._min_cppstd) - minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) - if minimum_version and Version(self.settings.compiler.version) < minimum_version: - raise ConanInvalidConfiguration(f"{self.ref} requires a compiler that supports at least C++{self._min_cppstd}") + if Version(self.version) < "1.0.0" or self.options.get_safe("with_multiprocess_rolling_file_appender"): + # TODO: if compiler doesn't support C++17, boost can be used instead + if Version(self.version) < "1.0.0": + self.output.info(f"Version {self.version} requires C++17. log4cxx version 1.x does not.") + else: + self.output.info("multiprocess rolling file appender requires C++17.") + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + compiler_version = Version(self.settings.compiler.version) + if compiler_version < minimum_version: + raise ConanInvalidConfiguration(f"{self.settings.compiler} {compiler_version} does not support C++17: {minimum_version} required.") + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, "17") + + def _patch_sources(self): + apply_conandata_patches(self) def build_requirements(self): if self.settings.os != "Windows": @@ -79,15 +129,23 @@ def build_requirements(self): self.tool_requires("pkgconf/2.0.3") def source(self): - # OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: - # 'src\\test\\resources\\output\\xyz\\:' - pattern = "*[!:]" - get(self, **self.conan_data["sources"][self.version], strip_root=True, pattern=pattern) + get(self, **self.conan_data["sources"][self.version], strip_root=True) def generate(self): tc = CMakeToolchain(self) - tc.cache_variables["BUILD_TESTING"] = False - tc.cache_variables["LOG4CXX_INSTALL_PDB"] = False + tc.variables["BUILD_TESTING"] = False + tc.variables["LOG4CXX_INSTALL_PDB"] = False + if Version(self.version) >= "1.0.0": + tc.variables["LOG4CXX_NETWORKING_SUPPORT"] = self.options.with_networking + tc.variables["LOG4CXX_MULTIPROCESS_ROLLING_FILE_APPENDER"] = self.options.with_multiprocess_rolling_file_appender + tc.variables["ENABLE_FMT_LAYOUT"] = self.options.with_fmt_layout + if Version(self.version) > "1.0.0" and self.settings.os != "Windows": + tc.variables["LOG4CXX_ENABLE_ESMTP"] = self.options.with_smtp_appender + tc.variables["LOG4CXX_ENABLE_ODBC"] = self.options.with_odbc_appender + tc.variables["LOG4CXX_CHAR"] = self.options.char_type + tc.variables["LOG4CXX_CHARSET"] = self.options.char_encoding + tc.variables["LOG4CXX_WCHAR_T"] = self.options.with_wchar_t + tc.variables["LOG4CXX_QT_SUPPORT"] = self.options.with_qt tc.generate() tc = CMakeDeps(self) tc.generate() @@ -141,3 +199,4 @@ def package_info(self): # TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] + diff --git a/recipes/log4cxx/all/patches/0.12.0-0001-find-apr.patch b/recipes/log4cxx/all/patches/0.12.1-0001-find-apr.patch similarity index 100% rename from recipes/log4cxx/all/patches/0.12.0-0001-find-apr.patch rename to recipes/log4cxx/all/patches/0.12.1-0001-find-apr.patch diff --git a/recipes/log4cxx/all/patches/0.12.1-0001-logchar-type.patch b/recipes/log4cxx/all/patches/0.12.1-0001-logchar-type.patch new file mode 100644 index 0000000000000..a59e3639553ae --- /dev/null +++ b/recipes/log4cxx/all/patches/0.12.1-0001-logchar-type.patch @@ -0,0 +1,21 @@ +--- a/src/main/include/CMakeLists.txt ++++ b/src/main/include/CMakeLists.txt +@@ -22,9 +22,18 @@ endif() + + if(${LOG4CXX_CHAR} STREQUAL "unichar") + set(LOGCHAR_IS_UNICHAR 1) ++ set(LOGCHAR_IS_WCHAR 0) ++ set(LOGCHAR_IS_UTF8 0) + elseif(${LOG4CXX_CHAR} STREQUAL "wchar_t") + set(LOGCHAR_IS_WCHAR 1) ++ set(LOGCHAR_IS_UNICHAR 0) ++ set(LOGCHAR_IS_UTF8 0) ++elseif(${LOG4CXX_CHAR} STREQUAL "utf-8") ++ set(LOGCHAR_IS_UNICHAR 0) ++ set(LOGCHAR_IS_WCHAR 0) ++ set(LOGCHAR_IS_UTF8 1) + endif() ++ + option(LOG4CXX_WCHAR_T "Enable wchar_t API methods" ON) + option(LOG4CXX_UNICHAR "Enable UniChar API methods" OFF) + set(INIT_IOS_BASE 0) diff --git a/recipes/log4cxx/all/patches/0.13.0-0001-find-apr.patch b/recipes/log4cxx/all/patches/0.13.0-0001-find-apr.patch new file mode 100644 index 0000000000000..174331cfd2a57 --- /dev/null +++ b/recipes/log4cxx/all/patches/0.13.0-0001-find-apr.patch @@ -0,0 +1,17 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -41,10 +41,12 @@ if(NOT BUILD_SHARED_LIBS) + endif() + + # Find Apache Runtime +-find_package(APR REQUIRED) ++find_package(apr REQUIRED) ++set(APR_LIBRARIES apr::apr) + + # Find Apache Runtime Utilities +-find_package(APR-Util REQUIRED) ++find_package(apr-util REQUIRED) ++set(APR_UTIL_LIBRARIES apr-util::apr-util) + + find_package( Threads REQUIRED ) + diff --git a/recipes/log4cxx/all/patches/0.13.0-0001-fix-static-library-compilation.patch b/recipes/log4cxx/all/patches/0.13.0-0001-fix-static-library-compilation.patch new file mode 100644 index 0000000000000..53bcabf38e8da --- /dev/null +++ b/recipes/log4cxx/all/patches/0.13.0-0001-fix-static-library-compilation.patch @@ -0,0 +1,12 @@ +--- a/src/main/cpp/threadutility.cpp ++++ b/src/main/cpp/threadutility.cpp +@@ -16,6 +16,9 @@ + */ + + #include "log4cxx/helpers/threadutility.h" ++#if !defined(LOG4CXX) ++ #define LOG4CXX 1 ++#endif + #include "log4cxx/private/log4cxx_private.h" + #include "log4cxx/helpers/loglog.h" + diff --git a/recipes/log4cxx/all/patches/0.13.0-0001-logchar-type.patch b/recipes/log4cxx/all/patches/0.13.0-0001-logchar-type.patch new file mode 100644 index 0000000000000..cb4669d6873b4 --- /dev/null +++ b/recipes/log4cxx/all/patches/0.13.0-0001-logchar-type.patch @@ -0,0 +1,44 @@ +diff --git a/src/main/cpp/threadutility.cpp b/src/main/cpp/threadutility.cpp +index c14c12fd..057ecd86 100644 +--- a/src/main/cpp/threadutility.cpp ++++ b/src/main/cpp/threadutility.cpp +@@ -113,11 +113,13 @@ void ThreadUtility::threadStartedNameThread(LogString threadName, + std::thread::id /*threadId*/, + std::thread::native_handle_type nativeHandle){ + #if LOG4CXX_HAS_PTHREAD_SETNAME +- if( pthread_setname_np( static_cast( nativeHandle ), threadName.c_str() ) < 0 ){ +- LOGLOG_ERROR( LOG4CXX_STR("unable to set thread name") ); ++ LOG4CXX_ENCODE_CHAR(sthreadName, threadName); ++ if (pthread_setname_np(static_cast(nativeHandle), sthreadName.c_str()) < 0) { ++ LOGLOG_ERROR(LOG4CXX_STR("unable to set thread name")); + } + #elif LOG4CXX_HAS_SETTHREADDESCRIPTION +- HRESULT hr = SetThreadDescription(static_cast(nativeHandle), threadName.c_str()); ++ LOG4CXX_ENCODE_WCHAR(wthreadName, threadName); ++ HRESULT hr = SetThreadDescription(static_cast(nativeHandle), wthreadName.c_str()); + if(FAILED(hr)){ + LOGLOG_ERROR( LOG4CXX_STR("unable to set thread name") ); + } +diff --git a/src/main/include/CMakeLists.txt b/src/main/include/CMakeLists.txt +index e31443fb..32122e41 100644 +--- a/src/main/include/CMakeLists.txt ++++ b/src/main/include/CMakeLists.txt +@@ -39,9 +39,18 @@ endif() + + if(${LOG4CXX_CHAR} STREQUAL "unichar") + set(LOGCHAR_IS_UNICHAR 1) ++ set(LOGCHAR_IS_WCHAR 0) ++ set(LOGCHAR_IS_UTF8 0) + elseif(${LOG4CXX_CHAR} STREQUAL "wchar_t") + set(LOGCHAR_IS_WCHAR 1) ++ set(LOGCHAR_IS_UNICHAR 0) ++ set(LOGCHAR_IS_UTF8 0) ++elseif(${LOG4CXX_CHAR} STREQUAL "utf-8") ++ set(LOGCHAR_IS_UNICHAR 0) ++ set(LOGCHAR_IS_WCHAR 0) ++ set(LOGCHAR_IS_UTF8 1) + endif() ++ + option(LOG4CXX_WCHAR_T "Enable wchar_t API methods" ON) + option(LOG4CXX_UNICHAR "Enable UniChar API methods" OFF) + set(INIT_IOS_BASE 0) diff --git a/recipes/log4cxx/all/patches/0.13.0-0001-visual-studio-15.patch b/recipes/log4cxx/all/patches/0.13.0-0001-visual-studio-15.patch new file mode 100644 index 0000000000000..0c491ee579c3b --- /dev/null +++ b/recipes/log4cxx/all/patches/0.13.0-0001-visual-studio-15.patch @@ -0,0 +1,52 @@ +diff --git a/src/main/cpp/threadutility.cpp b/src/main/cpp/threadutility.cpp +index b57ab66..ef48704 100644 +--- a/src/main/cpp/threadutility.cpp ++++ b/src/main/cpp/threadutility.cpp +@@ -27,7 +27,11 @@ + #include + #endif + +-using log4cxx::helpers::ThreadUtility; ++namespace log4cxx ++{ ++namespace helpers ++{ ++ + + struct ThreadUtility::priv_data{ + priv_data(){ +@@ -36,9 +40,9 @@ struct ThreadUtility::priv_data{ + start_post = nullptr; + } + +- log4cxx::helpers::ThreadStartPre start_pre; +- log4cxx::helpers::ThreadStarted started; +- log4cxx::helpers::ThreadStartPost start_post; ++ ThreadStartPre start_pre; ++ ThreadStarted started; ++ ThreadStartPost start_post; + }; + + #if LOG4CXX_HAS_PTHREAD_SIGMASK +@@ -138,14 +142,18 @@ void ThreadUtility::postThreadUnblockSignals(){ + } + + +-log4cxx::helpers::ThreadStartPre ThreadUtility::preStartFunction(){ ++ThreadStartPre ThreadUtility::preStartFunction(){ + return m_priv->start_pre; + } + +-log4cxx::helpers::ThreadStarted ThreadUtility::threadStartedFunction(){ ++ThreadStarted ThreadUtility::threadStartedFunction(){ + return m_priv->started; + } + +-log4cxx::helpers::ThreadStartPost ThreadUtility::postStartFunction(){ ++ThreadStartPost ThreadUtility::postStartFunction(){ + return m_priv->start_post; + } ++ ++} //namespace helpers ++} //namespace log4cxx ++ diff --git a/recipes/log4cxx/all/patches/1.2.0-0001-find-apr.patch b/recipes/log4cxx/all/patches/1.2.0-0001-find-apr.patch new file mode 100644 index 0000000000000..03f1b1478ec0e --- /dev/null +++ b/recipes/log4cxx/all/patches/1.2.0-0001-find-apr.patch @@ -0,0 +1,26 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 61c0479..6ac3e77 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -51,16 +51,18 @@ endif() + + # Find Apache Runtime + option(APR_STATIC "Link to the APR static library" OFF) +-find_package(APR REQUIRED) ++find_package(apr REQUIRED) ++set(APR_LIBRARIES apr::apr) + + # Find Apache Runtime Utilities + option(APU_STATIC "Link to the APR-Util static library" OFF) +-find_package(APR-Util REQUIRED) ++find_package(apr-util REQUIRED) ++set(APR_UTIL_LIBRARIES apr-util::apr-util) + + find_package( Threads REQUIRED ) + + # Find expat for XML parsing +-find_package(EXPAT REQUIRED) ++find_package(EXPAT REQUIRED MODULE) + if(TARGET EXPAT::EXPAT) + set(EXPAT_LIBRARIES EXPAT::EXPAT) + elseif(TARGET expat::expat) diff --git a/recipes/log4cxx/all/test_package/CMakeLists.txt b/recipes/log4cxx/all/test_package/CMakeLists.txt index a9ec878c74ebe..da8e02ac1cd82 100644 --- a/recipes/log4cxx/all/test_package/CMakeLists.txt +++ b/recipes/log4cxx/all/test_package/CMakeLists.txt @@ -4,5 +4,6 @@ project(test_package LANGUAGES CXX) find_package(log4cxx REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} log4cxx) target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17) +target_include_directories(${PROJECT_NAME} PRIVATE ${log4cxx_INCLUDE_DIR}) +target_link_libraries(${PROJECT_NAME} PRIVATE log4cxx ) diff --git a/recipes/log4cxx/all/test_package/conanfile.py b/recipes/log4cxx/all/test_package/conanfile.py index 382876561a203..c27e4673f4ff9 100644 --- a/recipes/log4cxx/all/test_package/conanfile.py +++ b/recipes/log4cxx/all/test_package/conanfile.py @@ -3,7 +3,6 @@ from conan.tools.cmake import cmake_layout, CMake import os - class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" @@ -22,6 +21,7 @@ def build(self): def test(self): if can_run(self): - bin_path = os.path.join(self.cpp.build.bindir, "test_package") config_xml_name = os.path.join(self.source_folder, "log4cxx_config.xml") - self.run(f"{bin_path} {config_xml_name}", env="conanrun") + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run("{} {}".format(bin_path, config_xml_name), env="conanrun") + diff --git a/recipes/log4cxx/all/test_package/test_package.cpp b/recipes/log4cxx/all/test_package/test_package.cpp index 4e52b04611957..41abd554c33f4 100644 --- a/recipes/log4cxx/all/test_package/test_package.cpp +++ b/recipes/log4cxx/all/test_package/test_package.cpp @@ -1,20 +1,18 @@ -#include "log4cxx/logger.h" +#include "log4cxx/logmanager.h" #include "log4cxx/xml/domconfigurator.h" #include -using namespace log4cxx; -using namespace log4cxx::xml; - int main(int argc, const char* argv[]) { - LoggerPtr logger(Logger::getLogger("TEST")); if (argc < 2) { - std::cerr << "Expected path to config xml\n"; + std::cerr << "Usage error. Expected an argument, the path to a xml configuration file\n"; return -1; } - DOMConfigurator::configure(argv[1]); - LOG4CXX_INFO(logger, "App started!"); - LOG4CXX_ERROR(logger, "Some error!"); + log4cxx::xml::DOMConfigurator::configure(argv[1]); + auto logger = log4cxx::LogManager::getLogger("TEST"); + LOG4CXX_INFO(logger, "App started"); + LOG4CXX_ERROR(logger, "Information message"); + log4cxx::LogManager::shutdown(); return 0; } diff --git a/recipes/log4cxx/config.yml b/recipes/log4cxx/config.yml index 18729d7b4cdc5..fb792fbdf460c 100644 --- a/recipes/log4cxx/config.yml +++ b/recipes/log4cxx/config.yml @@ -1,7 +1,9 @@ versions: + "1.2.0": + folder: all "1.1.0": folder: all - "0.12.1": + "0.13.0": folder: all - "0.12.0": + "0.12.1": folder: all