Skip to content

Commit

Permalink
Do not fail if spdlog already is instantiated but the build folder is…
Browse files Browse the repository at this point in the history
… missing.

Signed-off-by: fruffy <fruffy@nyu.edu>
  • Loading branch information
fruffy committed Feb 8, 2025
1 parent c8b4540 commit d9c25e6
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions backends/tofino/cmake/spdlog.cmake
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
message(STATUS "Fetching spdlog")

include(FetchContent)

# Preserve previous FETCHCONTENT_QUIET setting
set(FETCHCONTENT_QUIET_PREV ${FETCHCONTENT_QUIET})
set(FETCHCONTENT_QUIET OFF)

set(SPDLOG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/spdlog)

# Check if the source directory exists.
if(EXISTS ${SPDLOG_SOURCE_DIR}/CMakeLists.txt)
# If it exists but wasn't built before, manually add it.
set(FETCHCONTENT_SOURCE_DIR_SPDLOG ${SPDLOG_SOURCE_DIR})
# Avoid fetching again.
set(FETCHCONTENT_UPDATES_DISCONNECTED_SPDLOG ON)
endif()

FetchContent_Declare(
spdlog
GIT_REPOSITORY https://github.com/gabime/spdlog.git
GIT_TAG v1.8.3
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/spdlog
SOURCE_DIR ${SPDLOG_SOURCE_DIR}
USES_TERMINAL_DOWNLOAD TRUE
GIT_PROGRESS TRUE
)

FetchContent_MakeAvailable(spdlog)
FetchContent_GetProperties(spdlog)
if(NOT spdlog_POPULATED)
FetchContent_Populate(spdlog)
add_subdirectory(${SPDLOG_SOURCE_DIR} ${CMAKE_BINARY_DIR}/spdlog)
endif()

# Restore FETCHCONTENT_QUIET setting
set(FETCHCONTENT_QUIET ${FETCHCONTENT_QUIET_PREV})

0 comments on commit d9c25e6

Please sign in to comment.