File tree Expand file tree Collapse file tree 6 files changed +42
-19
lines changed Expand file tree Collapse file tree 6 files changed +42
-19
lines changed Original file line number Diff line number Diff line change @@ -171,7 +171,7 @@ else()
171171endif ()
172172
173173# Spdlog
174- if (KOMPUTE_OPT_USE_SPDLOG)
174+ if (NOT KOMPUTE_OPT_LOG_LEVEL_DISABLED AND KOMPUTE_OPT_USE_SPDLOG)
175175 add_compile_definitions (KOMPUTE_OPT_USE_SPDLOG=1)
176176
177177 if (KOMPUTE_OPT_USE_BUILT_IN_SPDLOG)
@@ -185,17 +185,17 @@ if(KOMPUTE_OPT_USE_SPDLOG)
185185 else ()
186186 find_package (spdlog REQUIRED)
187187 endif ()
188- endif ()
189-
190- # fmt
191- if (KOMPUTE_OPT_USE_BUILT_IN_FMT)
192- set (FMT_INSTALL ${KOMPUTE_OPT_INSTALL} )
193- FetchContent_Declare(fmt GIT_REPOSITORY https://github.com/fmtlib/fmt.git
194- GIT_TAG 11.0.0
195- GIT_SHALLOW 1) # Source: https://github.com/fmtlib/fmt/releases
196- FetchContent_MakeAvailable(fmt)
197188else ()
198- find_package (fmt REQUIRED)
189+ # fmt
190+ if (KOMPUTE_OPT_USE_BUILT_IN_FMT)
191+ set (FMT_INSTALL ${KOMPUTE_OPT_INSTALL} )
192+ FetchContent_Declare(fmt GIT_REPOSITORY https://github.com/fmtlib/fmt.git
193+ GIT_TAG 11.0.0
194+ GIT_SHALLOW 1) # Source: https://github.com/fmtlib/fmt/releases
195+ FetchContent_MakeAvailable(fmt)
196+ else ()
197+ find_package (fmt REQUIRED)
198+ endif ()
199199endif ()
200200
201201# GoogleTest
Original file line number Diff line number Diff line change @@ -95,12 +95,12 @@ function(BIN2H)
9595 set (namespaceStart "namespace ${HEADER_NAMESPACE} {" )
9696 set (namespaceEnd "} // namespace ${HEADER_NAMESPACE} " )
9797 set (arrayIncludes "#pragma once\n #include <array>\n #include <cstdint>" )
98- set (arrayDefinition "const std::array<uint32_t, ${arraySize} > ${BIN2H_VARIABLE_NAME} = { ${arrayValues} };" )
98+ set (arrayDefinition "const std::array<uint32_t, ${arraySize} > ${BIN2H_VARIABLE_NAME} = { { ${arrayValues} } };" )
9999
100100 set (declarations "${arrayIncludes} \n\n ${namespaceStart} \n ${arrayDefinition} \n ${namespaceEnd} \n\n " )
101101 if (BIN2H_APPEND)
102102 file (APPEND ${BIN2H_HEADER_FILE} "${declarations} " )
103103 else ()
104104 file (WRITE ${BIN2H_HEADER_FILE} "${declarations} " )
105105 endif ()
106- endfunction ()
106+ endfunction ()
Original file line number Diff line number Diff line change @@ -67,13 +67,22 @@ if(KOMPUTE_OPT_ANDROID_BUILD)
6767 target_link_libraries (kompute PUBLIC vulkanAndroid
6868 android
6969 kp_logger
70- kp_shader
71- fmt::fmt)
70+ kp_shader)
7271else ()
7372 target_link_libraries (kompute PUBLIC Vulkan::Vulkan
7473 kp_logger
75- kp_shader
76- fmt::fmt)
74+ kp_shader)
75+ endif ()
76+
77+ # If OPT_LOG_LEVEL is disabled, kp_logger wont link against fmt::fmt, but we
78+ # still need it for non-logging utilities. Therefore, explicitly link fmt::fmt
79+ # to kompute target.
80+ if (KOMPUTE_OPT_LOG_LEVEL_DISABLED)
81+ if (KOMPUTE_OPT_USE_SPDLOG)
82+ message (FATAL_ERROR "KOMPUTE_OPT_LOG_LEVEL_DISABLED is incompatible with KOMPUTE_OPT_USE_SPDLOG. To continue set either one option to 'OFF'." )
83+ else ()
84+ target_link_libraries (kompute PUBLIC fmt::fmt)
85+ endif ()
7786endif ()
7887
7988if (KOMPUTE_OPT_BUILD_PYTHON)
@@ -94,7 +103,7 @@ add_subdirectory(shaders)
94103add_subdirectory (include )
95104
96105if (KOMPUTE_OPT_INSTALL)
97- if (KOMPUTE_OPT_USE_BUILT_IN_FMT)
106+ if (NOT KOMPUTE_OPT_USE_SPDLOG AND KOMPUTE_OPT_USE_BUILT_IN_FMT)
98107 # We can't export fmt::fmt because it's alias target, so we unwrap the alias and install it.
99108 get_target_property (fmt_aliased_target fmt::fmt ALIASED_TARGET)
100109 install (TARGETS ${fmt_aliased_target}
Original file line number Diff line number Diff line change 22
33#include " kompute/Manager.hpp"
44#include " kompute/logger/Logger.hpp"
5+ #if KOMPUTE_OPT_USE_SPDLOG
6+ #include < spdlog/fmt/fmt.h>
7+ #include < spdlog/fmt/ranges.h>
8+ #else
59#include < fmt/core.h>
610#include < fmt/ranges.h>
11+ #endif
712#include < iterator>
813#include < set>
914#include < sstream>
Original file line number Diff line number Diff line change 33#include " kompute/Memory.hpp"
44#include " kompute/Image.hpp"
55#include " kompute/Tensor.hpp"
6+ #if KOMPUTE_OPT_USE_SPDLOG
7+ #include < spdlog/fmt/fmt.h>
8+ #else
69#include < fmt/core.h>
10+ #endif
711
812namespace kp {
913
Original file line number Diff line number Diff line change 33
44#include " kompute/Core.hpp"
55
6- #include " fmt/format.h"
6+ #if KOMPUTE_OPT_USE_SPDLOG
7+ #include < spdlog/fmt/fmt.h>
8+ #else
9+ #include < fmt/format.h>
10+ #endif
11+
712#include " kompute/Tensor.hpp"
813#include " logger/Logger.hpp"
914
You can’t perform that action at this time.
0 commit comments