From 5a733bdfd373ec5e6d5f3ea57358d58189391af3 Mon Sep 17 00:00:00 2001 From: "Mads R. B. Kristensen" Date: Thu, 3 Oct 2024 18:44:06 +0200 Subject: [PATCH] Fix no-cuda build (#484) Closes #482 Authors: - Mads R. B. Kristensen (https://github.com/madsbk) Approvers: - Lawrence Mitchell (https://github.com/wence-) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/kvikio/pull/484 --- cpp/CMakeLists.txt | 5 ++++- cpp/include/kvikio/utils.hpp | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index b82ceb2a02..5990405b1c 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -145,7 +145,10 @@ if(KvikIO_BUILD_EXAMPLES) add_subdirectory(examples) endif() -if(KvikIO_BUILD_TESTS AND CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) +if(CUDAToolkit_FOUND + AND KvikIO_BUILD_TESTS + AND CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME +) include(cmake/thirdparty/get_gtest.cmake) # include CTest module -- automatically calls enable_testing() diff --git a/cpp/include/kvikio/utils.hpp b/cpp/include/kvikio/utils.hpp index acdafba4da..3c77c1c853 100644 --- a/cpp/include/kvikio/utils.hpp +++ b/cpp/include/kvikio/utils.hpp @@ -25,7 +25,9 @@ #include #include +#ifdef KVIKIO_CUDA_FOUND #include +#endif #include #include @@ -291,6 +293,7 @@ inline bool is_future_done(const T& future) return future.wait_for(std::chrono::seconds(0)) != std::future_status::timeout; } +#ifdef KVIKIO_CUDA_FOUND /** * @brief Tag type for libkvikio's NVTX domain. */ @@ -309,6 +312,7 @@ struct libkvikio_domain { } \ } #define GET_KVIKIO_NVTX_FUNC_RANGE_MACRO(_1, _2, NAME, ...) NAME +#endif /** * @brief Convenience macro for generating an NVTX range in the `libkvikio` domain @@ -329,9 +333,15 @@ struct libkvikio_domain { * } * ``` */ +#ifdef KVIKIO_CUDA_FOUND #define KVIKIO_NVTX_FUNC_RANGE(...) \ GET_KVIKIO_NVTX_FUNC_RANGE_MACRO( \ __VA_ARGS__, KVIKIO_NVTX_FUNC_RANGE_2, KVIKIO_NVTX_FUNC_RANGE_1) \ (__VA_ARGS__) +#else +#define KVIKIO_NVTX_FUNC_RANGE(...) \ + do { \ + } while (0) +#endif } // namespace kvikio