Skip to content

Commit

Permalink
use fmt as an own dependency instead of the one included by spdlog.
Browse files Browse the repository at this point in the history
This should make it possible to decouple the formating and logging in nautilus.
  • Loading branch information
PhilippGrulich committed Sep 26, 2024
1 parent 9b6d212 commit 0157394
Show file tree
Hide file tree
Showing 30 changed files with 20,124 additions and 7,044 deletions.
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ option(ENABLE_LOGGING "Enable logging support" ON)
option(ENABLE_STACKTRACE "Enable stacktrace support" ON)
option(ENABLE_TESTS "Enable tests" ON)
option(ENABLE_COMPILER "Enables tracing and backend compilers" ON)
option(USE_EXTERNAL_FMT "Use a externally provided version of fmt" OFF)
option(USE_EXTERNAL_SPDLOG "Use a externally provided version of spdlog" OFF)
option(USE_EXTERNAL_MLIR "Use a externally provided version of MLIR" OFF)
cmake_dependent_option(ENABLE_TRACING "Enable the tracing" ON "ENABLE_COMPILER" OFF)
Expand Down Expand Up @@ -66,17 +67,26 @@ if (ENABLE_TESTS)
list(APPEND EXPORT_TARGETS Catch2)
endif ()

if (USE_EXTERNAL_FMT)
find_package(fmt CONFIG REQUIRED)
else ()
add_subdirectory(${THIRD_PARTY_DIR}/fmt EXCLUDE_FROM_ALL)
list(APPEND EXPORT_TARGETS fmt)
endif ()

if (ENABLE_LOGGING)
if (USE_EXTERNAL_SPDLOG)
find_package(spdlog CONFIG REQUIRED)
else ()
set(SPDLOG_COMPILED_LIB ON)
set(SPDLOG_BUILD_SHARED OFF)
set(SPDLOG_FMT_EXTERNAL ON)
add_subdirectory(${THIRD_PARTY_DIR}/spdlog)
list(APPEND EXPORT_TARGETS spdlog)
endif ()
endif ()


if (ENABLE_STACKTRACE)
# Also requires one of: libbfd (gnu binutils), libdwarf, libdw (elfutils)
add_subdirectory(${THIRD_PARTY_DIR}/backward-cpp)
Expand Down
4 changes: 4 additions & 0 deletions nautilus/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ set_target_properties(nautilus PROPERTIES
EXPORT_NAME nautilus
)

disable_target_warnings(fmt)
target_link_libraries(nautilus PRIVATE fmt::fmt)

if (ENABLE_LOGGING)
target_link_libraries(nautilus PRIVATE spdlog::spdlog)
endif ()
Expand All @@ -54,6 +57,7 @@ install(
TARGETS nautilus ${EXPORT_TARGETS}
EXPORT ${PROJECT_NAME}-config
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/
)

install(
Expand Down
4 changes: 4 additions & 0 deletions third_party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ endif ()
if (ENABLE_LOGGING)
set(SPDLOG_COMPILED_LIB ON)
set(SPDLOG_BUILD_SHARED OFF)
set(SPDLOG_FMT_EXTERNAL ON)
add_subdirectory(spdlog)
endif ()

add_subdirectory(fmt)
disable_target_warnings(fmt)

if (ENABLE_STACKTRACE)
# Also requires one of: libbfd (gnu binutils), libdwarf, libdw (elfutils)
add_subdirectory(backward-cpp)
Expand Down
Loading

0 comments on commit 0157394

Please sign in to comment.