Skip to content

Commit

Permalink
Decouple fmt and spdlog dependencies (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippGrulich authored Sep 30, 2024
1 parent 93d23eb commit 5e6f8fe
Show file tree
Hide file tree
Showing 30 changed files with 20,124 additions and 7,044 deletions.
11 changes: 11 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,27 @@ 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)
disable_target_warnings(fmt)
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
3 changes: 3 additions & 0 deletions nautilus/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ set_target_properties(nautilus PROPERTIES
EXPORT_NAME nautilus
)

target_link_libraries(nautilus PRIVATE fmt::fmt)

if (ENABLE_LOGGING)
target_link_libraries(nautilus PRIVATE spdlog::spdlog)
endif ()
Expand All @@ -54,6 +56,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 5e6f8fe

Please sign in to comment.