From 9f31886711addbcb4d9be314b82bb3177a7e38ca Mon Sep 17 00:00:00 2001 From: ymd-stella <7959916+ymd-stella@users.noreply.github.com> Date: Mon, 18 Sep 2023 20:00:33 +0900 Subject: [PATCH] Use spdlog on system if available (#165) --- CMakeLists.txt | 9 +++++++-- src/CMakeLists.txt | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5cdfaab..6316a87 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -153,8 +153,13 @@ include_directories(${EIGEN3_INCLUDE_DIR}) find_package(yaml-cpp REQUIRED) # spdlog -set(spdlog_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/3rd/spdlog/include) -include_directories(${spdlog_INCLUDE_DIR}) +find_package(spdlog QUIET) +if(spdlog_FOUND) + message(STATUS "Use spdlog on system: ${spdlog_VERSION}") +else() + set(spdlog_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/3rd/spdlog/include) + include_directories(${spdlog_INCLUDE_DIR}) +endif() # filesystem set(filesystem_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/3rd/filesystem/include) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d393d63..a5266b9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -51,4 +51,8 @@ foreach(EXECUTABLE_TARGET IN LISTS EXECUTABLE_TARGETS) target_link_libraries(${EXECUTABLE_TARGET} PRIVATE yaml-cpp) + if(spdlog_FOUND) + target_link_libraries(${EXECUTABLE_TARGET} PRIVATE + spdlog::spdlog) + endif() endforeach()