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

easyloggingpp: add options #14332

Merged
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
40 changes: 40 additions & 0 deletions recipes/easyloggingpp/all/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ option(enable_crash_log "Enable crash log handler" OFF)
option(enable_thread_safe "Enable thread safety for use in multithreaded env" OFF)
option(enable_debug_errors "Enable debug errors in case of configuration issues" OFF)
option(enable_default_logfile "Enable creation of default logfile" ON)
option(disable_logs "Disables all logs" OFF)
option(disable_debug_logs "Disables debug logs" OFF)
option(disable_info_logs "Disables info logs" OFF)
option(disable_warning_logs "Disables warning logs" OFF)
option(disable_error_logs "Disables error logs" OFF)
option(disable_fatal_logs "Disables fatal logs" OFF)
option(disable_verbose_logs "Disables verbose logs" OFF)
option(disable_trace_logs "Disables trace logs" OFF)

if (enable_crash_log)
add_definitions(-DELPP_FEATURE_CRASH_LOG)
Expand All @@ -24,4 +32,36 @@ if (NOT enable_default_logfile)
add_definitions(-DELPP_NO_DEFAULT_LOG_FILE)
endif()

if (disable_logs)
add_definitions(-DELPP_DISABLE_LOGS)
endif()

if (disable_debug_logs)
add_definitions(-DELPP_DISABLE_DEBUG_LOGS)
endif()

if (disable_info_logs)
add_definitions(-DELPP_DISABLE_INFO_LOGS)
endif()

if (disable_warning_logs)
add_definitions(-DELPP_DISABLE_WARNING_LOGS)
endif()

if (disable_error_logs)
add_definitions(-DELPP_DISABLE_ERROR_LOGS)
endif()

if (disable_fatal_logs)
add_definitions(-DELPP_DISABLE_FATAL_LOGS)
endif()

if (disable_verbose_logs)
add_definitions(-DELPP_DISABLE_VERBOSE_LOGS)
endif()

if (disable_trace_logs)
add_definitions(-DELPP_DISABLE_TRACE_LOGS)
endif()

add_subdirectory("source_subfolder")
49 changes: 46 additions & 3 deletions recipes/easyloggingpp/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import os
from conans import ConanFile, CMake, tools
from conans import CMake
from conan.tools import files
from conan import ConanFile


required_conan_version = ">=1.33.0"
Expand All @@ -19,12 +21,28 @@ class EasyloggingppConan(ConanFile):
"enable_thread_safe": [True, False],
"enable_debug_errors": [True, False],
"enable_default_logfile": [True, False],
"disable_logs": [True, False],
"disable_debug_logs": [True, False],
"disable_info_logs": [True, False],
"disable_warning_logs": [True, False],
"disable_error_logs": [True, False],
"disable_fatal_logs": [True, False],
"disable_verbose_logs": [True, False],
"disable_trace_logs": [True, False]
}
default_options = {
"enable_crash_log": False,
"enable_thread_safe": False,
"enable_debug_errors": False,
"enable_default_logfile": True,
"disable_logs": False,
"disable_debug_logs": False,
"disable_info_logs": False,
"disable_warning_logs": False,
"disable_error_logs": False,
"disable_fatal_logs": False,
"disable_verbose_logs": False,
"disable_trace_logs": False
}
_cmake = None

Expand All @@ -45,11 +63,19 @@ def _configure_cmake(self):
self._cmake.definitions["enable_thread_safe"] = self.options.enable_thread_safe
self._cmake.definitions["enable_debug_errors"] = self.options.enable_debug_errors
self._cmake.definitions["enable_default_logfile"] = self.options.enable_default_logfile
self._cmake.definitions["disable_logs"] = self.options.disable_logs
self._cmake.definitions["disable_debug_logs"] = self.options.disable_debug_logs
self._cmake.definitions["disable_info_logs"] = self.options.disable_info_logs
self._cmake.definitions["disable_warning_logs"] = self.options.disable_warning_logs
self._cmake.definitions["disable_error_logs"] = self.options.disable_error_logs
self._cmake.definitions["disable_fatal_logs"] = self.options.disable_fatal_logs
self._cmake.definitions["disable_verbose_logs"] = self.options.disable_verbose_logs
self._cmake.definitions["disable_trace_logs"] = self.options.disable_trace_logs
self._cmake.configure(build_folder=self._build_subfolder)
return self._cmake

def source(self):
tools.get(**self.conan_data["sources"][self.version],
files.get(self, **self.conan_data["sources"][self.version],
destination=self._source_subfolder, strip_root=True)

def build(self):
Expand All @@ -59,7 +85,7 @@ def build(self):
def package(self):
cmake = self._configure_cmake()
cmake.install()
tools.rmdir(os.path.join(self.package_folder, "share"))
files.rmdir(self, os.path.join(self.package_folder, "share"))
self.copy(pattern="LICENSE",
dst="licenses",
src=self._source_subfolder)
Expand All @@ -76,3 +102,20 @@ def package_info(self):
self.cpp_info.defines.append("ELPP_DEBUG_ERRORS")
if self.options.enable_default_logfile:
self.cpp_info.defines.append("ELPP_NO_DEFAULT_LOG_FILE")
if self.options.disable_logs:
self.cpp_info.defines.append("ELPP_DISABLE_LOGS")
if self.options.disable_debug_logs:
self.cpp_info.defines.append("ELPP_DISABLE_DEBUG_LOGS")
if self.options.disable_info_logs:
self.cpp_info.defines.append("ELPP_DISABLE_INFO_LOGS")
if self.options.disable_warning_logs:
self.cpp_info.defines.append("ELPP_DISABLE_WARNING_LOGS")
if self.options.disable_error_logs:
self.cpp_info.defines.append("ELPP_DISABLE_ERROR_LOGS")
if self.options.disable_fatal_logs:
self.cpp_info.defines.append("ELPP_DISABLE_FATAL_LOGS")
if self.options.disable_verbose_logs:
self.cpp_info.defines.append("ELPP_DISABLE_VERBOSE_LOGS")
if self.options.disable_trace_logs:
self.cpp_info.defines.append("ELPP_DISABLE_TRACE_LOGS")