Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ else()
endif()

# Spdlog
if(KOMPUTE_OPT_USE_SPDLOG)
if(NOT KOMPUTE_OPT_LOG_LEVEL_DISABLED AND KOMPUTE_OPT_USE_SPDLOG)
add_compile_definitions(KOMPUTE_OPT_USE_SPDLOG=1)

if(KOMPUTE_OPT_USE_BUILT_IN_SPDLOG)
Expand All @@ -183,17 +183,17 @@ if(KOMPUTE_OPT_USE_SPDLOG)
else()
find_package(spdlog REQUIRED)
endif()
endif()

# fmt
if(KOMPUTE_OPT_USE_BUILT_IN_FMT)
set(FMT_INSTALL ${KOMPUTE_OPT_INSTALL})
FetchContent_Declare(fmt GIT_REPOSITORY https://github.com/fmtlib/fmt.git
GIT_TAG 11.0.0
GIT_SHALLOW 1) # Source: https://github.com/fmtlib/fmt/releases
FetchContent_MakeAvailable(fmt)
else()
find_package(fmt REQUIRED)
# fmt
if(KOMPUTE_OPT_USE_BUILT_IN_FMT)
set(FMT_INSTALL ${KOMPUTE_OPT_INSTALL})
FetchContent_Declare(fmt GIT_REPOSITORY https://github.com/fmtlib/fmt.git
GIT_TAG 11.0.0
GIT_SHALLOW 1) # Source: https://github.com/fmtlib/fmt/releases
FetchContent_MakeAvailable(fmt)
else()
find_package(fmt REQUIRED)
endif()
endif()

# GoogleTest
Expand Down
4 changes: 2 additions & 2 deletions cmake/bin2h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ function(BIN2H)
set(namespaceStart "namespace ${HEADER_NAMESPACE} {")
set(namespaceEnd "} // namespace ${HEADER_NAMESPACE}")
set(arrayIncludes "#pragma once\n#include <array>\n#include <cstdint>")
set(arrayDefinition "const std::array<uint32_t, ${arraySize}> ${BIN2H_VARIABLE_NAME} = { ${arrayValues} };")
set(arrayDefinition "const std::array<uint32_t, ${arraySize}> ${BIN2H_VARIABLE_NAME} = { { ${arrayValues} } };")

set(declarations "${arrayIncludes}\n\n${namespaceStart}\n${arrayDefinition}\n${namespaceEnd}\n\n")
if(BIN2H_APPEND)
file(APPEND ${BIN2H_HEADER_FILE} "${declarations}")
else()
file(WRITE ${BIN2H_HEADER_FILE} "${declarations}")
endif()
endfunction()
endfunction()
19 changes: 14 additions & 5 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,22 @@ if(KOMPUTE_OPT_ANDROID_BUILD)
target_link_libraries(kompute PUBLIC vulkanAndroid
android
kp_logger
kp_shader
fmt::fmt)
kp_shader)
else()
target_link_libraries(kompute PUBLIC Vulkan::Vulkan
kp_logger
kp_shader
fmt::fmt)
kp_shader)
endif()

# If OPT_LOG_LEVEL is disabled, kp_logger wont link against fmt::fmt, but we
# still need it for non-logging utilities. Therefore, explicitly link fmt::fmt
# to kompute target.
if(KOMPUTE_OPT_LOG_LEVEL_DISABLED)
if(KOMPUTE_OPT_USE_SPDLOG)
message(FATAL_ERROR "KOMPUTE_OPT_LOG_LEVEL_DISABLED is incompatible with KOMPUTE_OPT_USE_SPDLOG. To continue set either one option to 'OFF'.")
else()
target_link_libraries(kompute PUBLIC fmt::fmt)
endif()
endif()

if(KOMPUTE_OPT_BUILD_PYTHON)
Expand All @@ -94,7 +103,7 @@ add_subdirectory(shaders)
add_subdirectory(include)

if(KOMPUTE_OPT_INSTALL)
if (KOMPUTE_OPT_USE_BUILT_IN_FMT)
if (NOT KOMPUTE_OPT_USE_SPDLOG AND KOMPUTE_OPT_USE_BUILT_IN_FMT)
# We can't export fmt::fmt because it's alias target, so we unwrap the alias and install it.
get_target_property(fmt_aliased_target fmt::fmt ALIASED_TARGET)
install(TARGETS ${fmt_aliased_target}
Expand Down
5 changes: 5 additions & 0 deletions src/Manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@

#include "kompute/Manager.hpp"
#include "kompute/logger/Logger.hpp"
#if KOMPUTE_OPT_USE_SPDLOG
#include <spdlog/fmt/fmt.h>
#include <spdlog/fmt/ranges.h>
#else
#include <fmt/core.h>
#include <fmt/ranges.h>
#endif
#include <iterator>
#include <set>
#include <sstream>
Expand Down
4 changes: 4 additions & 0 deletions src/Memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
#include "kompute/Memory.hpp"
#include "kompute/Image.hpp"
#include "kompute/Tensor.hpp"
#if KOMPUTE_OPT_USE_SPDLOG
#include <spdlog/fmt/fmt.h>
#else
#include <fmt/core.h>
#endif

namespace kp {

Expand Down
7 changes: 6 additions & 1 deletion src/include/kompute/Algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@

#include "kompute/Core.hpp"

#include "fmt/format.h"
#if KOMPUTE_OPT_USE_SPDLOG
#include <spdlog/fmt/fmt.h>
#else
#include <fmt/format.h>
#endif

#include "kompute/Tensor.hpp"
#include "logger/Logger.hpp"

Expand Down