Skip to content

Commit e9ba108

Browse files
committed
fix(utils): link fmt as direct dependency and remove spdlog fmt detection logic
1 parent d5b2933 commit e9ba108

File tree

1 file changed

+12
-29
lines changed

1 file changed

+12
-29
lines changed

CMakeLists.txt

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -111,38 +111,21 @@ else()
111111
message(FATAL_ERROR "[utils] spdlog target not found.")
112112
endif()
113113

114-
target_link_libraries(vix_utils PRIVATE ${_VIX_SPDLOG_TARGET})
115-
116-
# Detect if spdlog requires external fmt (SPDLOG_FMT_EXTERNAL)
117-
set(_VIX_SPDLOG_NEEDS_FMT OFF)
118-
119-
get_target_property(_spd_defs_iface ${_VIX_SPDLOG_TARGET} INTERFACE_COMPILE_DEFINITIONS)
120-
if (_spd_defs_iface)
121-
foreach(d IN LISTS _spd_defs_iface)
122-
if (d STREQUAL "SPDLOG_FMT_EXTERNAL" OR d MATCHES "^SPDLOG_FMT_EXTERNAL=")
123-
set(_VIX_SPDLOG_NEEDS_FMT ON)
124-
endif()
125-
endforeach()
114+
# fmt is a direct dependency because Logger.hpp includes <fmt/ostream.h>
115+
if (TARGET fmt::fmt)
116+
set(_VIX_FMT_TARGET fmt::fmt)
117+
elseif (TARGET fmt::fmt-header-only)
118+
set(_VIX_FMT_TARGET fmt::fmt-header-only)
119+
else()
120+
message(FATAL_ERROR "[utils] fmt target not found.")
126121
endif()
127122

128-
get_target_property(_spd_defs ${_VIX_SPDLOG_TARGET} COMPILE_DEFINITIONS)
129-
if (_spd_defs)
130-
foreach(d IN LISTS _spd_defs)
131-
if (d STREQUAL "SPDLOG_FMT_EXTERNAL" OR d MATCHES "^SPDLOG_FMT_EXTERNAL=")
132-
set(_VIX_SPDLOG_NEEDS_FMT ON)
133-
endif()
134-
endforeach()
135-
endif()
123+
target_link_libraries(vix_utils
124+
PUBLIC
125+
${_VIX_SPDLOG_TARGET}
126+
${_VIX_FMT_TARGET}
127+
)
136128

137-
if (_VIX_SPDLOG_NEEDS_FMT)
138-
if (TARGET fmt::fmt)
139-
target_link_libraries(vix_utils PRIVATE fmt::fmt)
140-
elseif (TARGET fmt::fmt-header-only)
141-
target_link_libraries(vix_utils PRIVATE fmt::fmt-header-only)
142-
else()
143-
message(FATAL_ERROR "[utils] spdlog requires external fmt (SPDLOG_FMT_EXTERNAL) but fmt package was not found.")
144-
endif()
145-
endif()
146129
# -------------------------
147130
# Windows: prevent Win32 API usage by spdlog
148131
# -------------------------

0 commit comments

Comments
 (0)