Skip to content

SPDLOG_DISABLE_DEFAULT_LOGGER is not a cmake option #1765

@shimaowo

Description

@shimaowo

Is there a reason that SPDLOG_DISABLE_DEFAULT_LOGGER is omitted from cmake options? The other tweakme variables have cmake options as well, which makes things slightly nicer, or at least more uniform, when using spdlog as a dependency.

Without it being a proper option, you instead have to do something like this:

option(SPDLOG_NO_ATOMIC_LEVELS "" ON)
add_subdirectory(vendor/spdlog)
# no cmake option for this for some reason
target_compile_definitions(spdlog PRIVATE
    SPDLOG_DISABLE_DEFAULT_LOGGER
)

or, when building from the command line, it's perhaps even more annoying:
CXXFLAGS="-DSPDLOG_DISABLE_DEFAULT_LOGGER" cmake -S. -Bbuild -G "Unix Makefiles" -DSPDLOG_NO_ATOMIC_LEVELS -DCMAKE_BUILD_TYPE=Release

(CXXFLAGS here must be specified as an env var, rather than using the CMAKE_ version, or it will overwrite and not append. This is sort of unintuitive and messy)

It seems like this could just be added to the existing compiler flag foreach in CMakeLists.txt (as well as adding the option itself, of course)

spdlog/CMakeLists.txt

Lines 195 to 209 in 17c6e6e

foreach(
SPDLOG_OPTION
SPDLOG_WCHAR_TO_UTF8_SUPPORT
SPDLOG_WCHAR_FILENAMES
SPDLOG_NO_EXCEPTIONS
SPDLOG_CLOCK_COARSE
SPDLOG_PREVENT_CHILD_FD
SPDLOG_NO_THREAD_ID
SPDLOG_NO_TLS
SPDLOG_NO_ATOMIC_LEVELS)
if(${SPDLOG_OPTION})
target_compile_definitions(spdlog PUBLIC ${SPDLOG_OPTION})
target_compile_definitions(spdlog_header_only INTERFACE ${SPDLOG_OPTION})
endif()
endforeach()

Was there a reason for this to be omitted?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions