Skip to content

Commit

Permalink
Prefix new CMake variables with RMM_ and ensure that SUPPORTS_LOGGING…
Browse files Browse the repository at this point in the history
… flags are specific to each project embedding a logger
  • Loading branch information
vyasr committed Nov 7, 2024
1 parent aaf4b7c commit 7c9134c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
16 changes: 8 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ message(STATUS "RMM: RMM_LOGGING_LEVEL = '${RMM_LOGGING_LEVEL}'")
# cudart can be linked statically or dynamically
option(CUDA_STATIC_RUNTIME "Statically link the CUDA runtime" OFF)

option(LOGGING_COMPATIBILITY "Enable backwards compatibility with older logging macros" ON)
option(SUPPORTS_LOGGING "Enable logging support" ON)
if(LOGGING_COMPATIBILITY)
if(NOT SUPPORTS_LOGGING)
message(STATUS "LOGGING_COMPATIBILITY requires SUPPORTS_LOGGING to be enabled")
set(SUPPORTS_LOGGING ON)
option(RMM_LOGGING_COMPATIBILITY "Enable backwards compatibility with older logging macros" ON)
option(RMM_SUPPORTS_LOGGING "Enable logging support" ON)
if(RMM_LOGGING_COMPATIBILITY)
if(NOT RMM_SUPPORTS_LOGGING)
message(STATUS "RMM_LOGGING_COMPATIBILITY requires RMM_SUPPORTS_LOGGING to be enabled")
set(RMM_SUPPORTS_LOGGING ON)
endif()
endif()

Expand All @@ -83,13 +83,13 @@ rapids_find_package(
rapids_cpm_init()

add_subdirectory(rapids_logger)
if(LOGGING_COMPATIBILITY)
if(RMM_LOGGING_COMPATIBILITY)
rapids_make_logger(
rmm EXPORT_SET rmm-exports VISIBILITY_MACRO "__attribute__((visibility(\"default\")))"
SUPPORTS_LOGGING RMM_BACKWARDS_COMPATIBILITY)
else()
set(_logging_support_flag)
if(SUPPORTS_LOGGING)
if(RMM_SUPPORTS_LOGGING)
set(_logging_support_flag "SUPPORTS_LOGGING")
endif()
rapids_make_logger(rmm EXPORT_SET rmm-exports VISIBILITY_MACRO
Expand Down
3 changes: 2 additions & 1 deletion rapids_logger/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ function(rapids_make_logger logger_namespace)
target_compile_definitions(${_RAPIDS_LOGGER_TARGET} INTERFACE CUDF_BACKWARDS_COMPATIBILITY)
endif()
if(_RAPIDS_SUPPORTS_LOGGING)
target_compile_definitions(${_RAPIDS_LOGGER_TARGET} INTERFACE SUPPORTS_LOGGING)
target_compile_definitions(${_RAPIDS_LOGGER_TARGET}
INTERFACE "${_RAPIDS_LOGGER_MACRO_PREFIX}_SUPPORTS_LOGGING")

if(NOT _RAPIDS_RMM_BACKWARDS_COMPATIBILITY)
# Create an interface target that will trigger compilation of the logger implementation in any
Expand Down
8 changes: 4 additions & 4 deletions rapids_logger/logger.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include <ostream>
#include <string>

#ifdef SUPPORTS_LOGGING
#ifdef @_RAPIDS_LOGGER_MACRO_PREFIX@_SUPPORTS_LOGGING

// Forward declare spdlog types that are part of our public API.
namespace spdlog {
Expand Down Expand Up @@ -162,7 +162,7 @@ enum class level_enum : int32_t {
*/
class logger {
public:
#ifdef SUPPORTS_LOGGING
#ifdef @_RAPIDS_LOGGER_MACRO_PREFIX@_SUPPORTS_LOGGING
/**
* @brief Construct a new logger object
*
Expand All @@ -187,7 +187,7 @@ class logger {
BACKWARDS_COMPAT_INLINE logger(logger&&); ///< @default_move_constructor
BACKWARDS_COMPAT_INLINE logger& operator=(logger&&); ///< @default_move_assignment{logger}

#ifdef SUPPORTS_LOGGING
#ifdef @_RAPIDS_LOGGER_MACRO_PREFIX@_SUPPORTS_LOGGING
/**
* @brief Log a message at the specified level.
*
Expand Down Expand Up @@ -373,7 +373,7 @@ class logger {
#ifndef @_RAPIDS_LOGGER_MACRO_PREFIX@_BACKWARDS_COMPATIBILITY
private:
#endif
#ifdef SUPPORTS_LOGGING
#ifdef @_RAPIDS_LOGGER_MACRO_PREFIX@_SUPPORTS_LOGGING
std::unique_ptr<detail::impl> pImpl{}; ///< pimpl idiom
#endif

Expand Down
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ endfunction()

# Create an object library for the logger so that we don't have to recompile it. This is not
# necessary if logging is unsupported since then the header-only implementation is sufficient.
if(SUPPORTS_LOGGING AND NOT LOGGING_COMPATIBILITY)
if(SUPPORTS_LOGGING AND NOT RMM_LOGGING_COMPATIBILITY)
add_library(rmm_test_logger OBJECT)
target_link_libraries(rmm_test_logger PRIVATE rmm_logger_impl)
endif()
Expand Down

0 comments on commit 7c9134c

Please sign in to comment.