Skip to content

Commit

Permalink
optional spdlog
Browse files Browse the repository at this point in the history
  • Loading branch information
Angelyr committed Nov 15, 2024
1 parent 5856337 commit 20b1f75
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
8 changes: 6 additions & 2 deletions support/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ target_include_directories(support INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/support>
$<INSTALL_INTERFACE:include>)

find_package(spdlog REQUIRED)
target_link_libraries(support PUBLIC spdlog::spdlog)
find_package(spdlog QUIET)
if (spdlog_FOUND)
add_definitions(-DSPDLOG_ENABLED)
target_compile_definitions(support INTERFACE -DSPDLOG_ENABLED)
target_link_libraries(support PUBLIC spdlog::spdlog)
endif()
target_link_libraries(support PUBLIC Kokkos::kokkos)
target_link_libraries(support PUBLIC MPI::MPI_CXX)
if(ENABLE_CABANA)
Expand Down
20 changes: 17 additions & 3 deletions support/ppPrint.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
#pragma once

#include "spdlog/spdlog.h"
#ifdef SPDLOG_ENABLED
#include "spdlog/spdlog.h"
#endif

#include <Kokkos_Core.hpp>

namespace pumipic {

template<typename... Args>
void pPrintError(const char* fmt, const Args&... args) {
spdlog::error(fmt, args...);
#ifdef SPDLOG_ENABLED
spdlog::error(fmt, args...);
#else
fprintf(stderr, fmt, args...);
#endif
}

template<typename... Args>
void pPrintInfo(const char* fmt, const Args&... args) {
spdlog::info(fmt, args...);
#ifdef SPDLOG_ENABLED
spdlog::info(fmt, args...);
#else
Kokkos::printf(fmt, args...);
#endif
}


}

0 comments on commit 20b1f75

Please sign in to comment.