From 3a5fbd68d9db4108be9345d4461cff7bd17920eb Mon Sep 17 00:00:00 2001 From: jakirkham Date: Tue, 18 Feb 2025 20:37:54 -0800 Subject: [PATCH 1/5] Add cuCIM pronunciation to README (#823) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Include a pronunciation guide for cuCIM with audio playback Thanks Bradley for the idea! 🙏 Authors: - https://github.com/jakirkham Approvers: - Gigon Bae (https://github.com/gigony) URL: https://github.com/rapidsai/cucim/pull/823 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c20ff1cfc..ae3c4ed28 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ #
 cuCIM
-[RAPIDS](https://rapids.ai) cuCIM is an open-source, accelerated computer vision and image processing software library for multidimensional images used in biomedical, geospatial, material and life science, and remote sensing use cases. +[RAPIDS](https://rapids.ai) cuCIM (pronounced "koo-sim", see [here]( https://ipa-reader.com/?text=ku%CB%90%CB%88s%C9%AAm&voice=Joey )) is an open-source, accelerated computer vision and image processing software library for multidimensional images used in biomedical, geospatial, material and life science, and remote sensing use cases. cuCIM offers: From 760be37adb73190741a8406d8571f0e51960617b Mon Sep 17 00:00:00 2001 From: James Lamb Date: Fri, 21 Feb 2025 14:47:30 -0600 Subject: [PATCH 2/5] require sphinx<8.2.0 (#840) Contributes to https://github.com/rapidsai/build-planning/issues/155 Fixes docs builds by temporarily putting a ceiling on `sphinx`. Authors: - James Lamb (https://github.com/jameslamb) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/cucim/pull/840 --- conda/environments/all_cuda-118_arch-x86_64.yaml | 2 +- conda/environments/all_cuda-128_arch-x86_64.yaml | 2 +- dependencies.yaml | 3 ++- python/cucim/pyproject.toml | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index d811336db..cd3a25c2c 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -42,7 +42,7 @@ dependencies: - recommonmark - scikit-image>=0.19.0,<0.26.0a0 - scipy>=1.11.2 -- sphinx>=8.0.0 +- sphinx>=8.0.0,<8.2.0 - sysroot_linux-64==2.28 - tifffile>=2022.8.12 - yasm diff --git a/conda/environments/all_cuda-128_arch-x86_64.yaml b/conda/environments/all_cuda-128_arch-x86_64.yaml index 95fb3ac09..349607400 100644 --- a/conda/environments/all_cuda-128_arch-x86_64.yaml +++ b/conda/environments/all_cuda-128_arch-x86_64.yaml @@ -41,7 +41,7 @@ dependencies: - recommonmark - scikit-image>=0.19.0,<0.26.0a0 - scipy>=1.11.2 -- sphinx>=8.0.0 +- sphinx>=8.0.0,<8.2.0 - sysroot_linux-64==2.28 - tifffile>=2022.8.12 - yasm diff --git a/dependencies.yaml b/dependencies.yaml index 56add54da..62f6bde51 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -251,7 +251,8 @@ dependencies: - &numpydoc numpydoc>=1.7 - pydata-sphinx-theme - recommonmark - - sphinx>=8.0.0 + # the ceiling on sphinx can be removed when https://github.com/spatialaudio/nbsphinx/issues/825 is resolved + - sphinx>=8.0.0,<8.2.0 py_version: specific: - output_types: conda diff --git a/python/cucim/pyproject.toml b/python/cucim/pyproject.toml index 44c4d130a..1f4ee6944 100644 --- a/python/cucim/pyproject.toml +++ b/python/cucim/pyproject.toml @@ -83,7 +83,7 @@ docs = [ "numpydoc>=1.7", "pydata-sphinx-theme", "recommonmark", - "sphinx>=8.0.0", + "sphinx>=8.0.0,<8.2.0", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. [project.entry-points."console_scripts"] From 2826e2c0ec3a3bf403072124b8607eba0e4bab3b Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Tue, 25 Feb 2025 15:49:57 -0500 Subject: [PATCH 3/5] Require CMake 3.30.4 (#834) Update CMake minimum required to 3.30.4 across all of RAPIDS Authors: - Robert Maynard (https://github.com/robertmaynard) - Bradley Dice (https://github.com/bdice) Approvers: - Gigon Bae (https://github.com/gigony) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/cucim/pull/834 --- CMakeLists.txt | 3 +- ci/build_wheel.sh | 3 + .../all_cuda-118_arch-x86_64.yaml | 2 +- .../all_cuda-128_arch-x86_64.yaml | 2 +- conda/recipes/cucim/conda_build_config.yaml | 2 +- .../recipes/libcucim/conda_build_config.yaml | 2 +- cpp/cmake/deps/abseil.cmake | 16 ++-- cpp/cmake/deps/boost-header-only.cmake | 43 +++------- cpp/cmake/deps/boost.cmake | 7 +- cpp/cmake/deps/catch2.cmake | 13 ++- cpp/cmake/deps/cli11.cmake | 17 ++-- cpp/cmake/deps/fmt.cmake | 15 ++-- cpp/cmake/deps/googlebenchmark.cmake | 15 ++-- cpp/cmake/deps/googletest.cmake | 14 ++-- cpp/cmake/deps/json.cmake | 16 ++-- cpp/cmake/deps/libcuckoo.cmake | 38 ++------- cpp/cmake/deps/nvtx3.cmake | 19 ++--- cpp/cmake/deps/openslide.cmake | 2 +- cpp/cmake/deps/pybind11.cmake | 19 ++--- cpp/cmake/deps/rmm.cmake | 15 ++-- cpp/cmake/deps/taskflow.cmake | 14 ++-- cpp/include/cucim/profiler/nvtx3.h | 4 +- cpp/plugins/cucim.kit.cumed/CMakeLists.txt | 2 +- .../cucim.kit.cumed/cmake/deps/catch2.cmake | 13 ++- .../cucim.kit.cumed/cmake/deps/cli11.cmake | 17 ++-- .../cucim.kit.cumed/cmake/deps/fmt.cmake | 20 ++--- .../cmake/deps/googlebenchmark.cmake | 15 ++-- .../cmake/deps/googletest.cmake | 14 ++-- cpp/plugins/cucim.kit.cuslide/CMakeLists.txt | 2 +- .../cucim.kit.cuslide/cmake/deps/boost.cmake | 9 +- .../cucim.kit.cuslide/cmake/deps/catch2.cmake | 13 ++- .../cucim.kit.cuslide/cmake/deps/cli11.cmake | 17 ++-- .../cucim.kit.cuslide/cmake/deps/fmt.cmake | 20 ++--- .../cmake/deps/googlebenchmark.cmake | 15 ++-- .../cmake/deps/googletest.cmake | 14 ++-- .../cucim.kit.cuslide/cmake/deps/json.cmake | 16 ++-- .../cmake/deps/libculibos.cmake | 2 +- .../cmake/deps/libdeflate.cmake | 7 +- .../cmake/deps/libjpeg-turbo.cmake | 13 ++- .../cmake/deps/libopenjpeg.cmake | 84 +++++++++---------- .../cmake/deps/libtiff.cmake | 14 ++-- .../cucim.kit.cuslide/cmake/deps/nvjpeg.cmake | 2 +- .../cmake/deps/openslide.cmake | 2 +- .../cmake/deps/pugixml.cmake | 14 ++-- dependencies.yaml | 2 +- python/CMakeLists.txt | 2 +- python/cmake/deps/fmt.cmake | 15 ++-- python/cmake/deps/json.cmake | 16 ++-- python/cmake/deps/pybind11.cmake | 23 ++--- python/cmake/deps/pybind11_json.cmake | 13 ++- 50 files changed, 290 insertions(+), 387 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ff7e7ca8e..dfed54574 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ # limitations under the License. # -cmake_minimum_required(VERSION 3.26.4) +cmake_minimum_required(VERSION 3.30.4 FATAL_ERROR) ################################################################################ # Prerequisite statements @@ -209,7 +209,6 @@ install(DIRECTORY install(DIRECTORY ${deps-fmt_SOURCE_DIR}/include/ ${deps-nvtx3_SOURCE_DIR}/c/include/ - ${deps-nvtx3_SOURCE_DIR}/cpp/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${CUCIM_PACKAGE_NAME}/3rdparty) diff --git a/ci/build_wheel.sh b/ci/build_wheel.sh index da560074d..80054cde0 100755 --- a/ci/build_wheel.sh +++ b/ci/build_wheel.sh @@ -32,6 +32,9 @@ rapids-pip-retry install \ sccache --zero-stats +rapids-logger "pyenv rehash" +pyenv rehash + # First build the C++ lib using CMake via the run script ./run build_local all ${CMAKE_BUILD_TYPE} diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index cd3a25c2c..5d1d1dd6b 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -8,7 +8,7 @@ channels: dependencies: - c-compiler - click -- cmake>=3.26.4,!=3.30.0 +- cmake>=3.30.4 - cuda-version=11.8 - cudatoolkit - cupy>=12.0.0 diff --git a/conda/environments/all_cuda-128_arch-x86_64.yaml b/conda/environments/all_cuda-128_arch-x86_64.yaml index 349607400..494b1a08e 100644 --- a/conda/environments/all_cuda-128_arch-x86_64.yaml +++ b/conda/environments/all_cuda-128_arch-x86_64.yaml @@ -8,7 +8,7 @@ channels: dependencies: - c-compiler - click -- cmake>=3.26.4,!=3.30.0 +- cmake>=3.30.4 - cuda-cudart-dev - cuda-nvcc - cuda-version=12.8 diff --git a/conda/recipes/cucim/conda_build_config.yaml b/conda/recipes/cucim/conda_build_config.yaml index 83f5ebcb1..0a1108eb5 100644 --- a/conda/recipes/cucim/conda_build_config.yaml +++ b/conda/recipes/cucim/conda_build_config.yaml @@ -17,4 +17,4 @@ c_stdlib_version: - "2.28" cmake_version: - - ">=3.26.4,!=3.30.0" + - ">=3.30.4" diff --git a/conda/recipes/libcucim/conda_build_config.yaml b/conda/recipes/libcucim/conda_build_config.yaml index 246946266..f7372d75d 100644 --- a/conda/recipes/libcucim/conda_build_config.yaml +++ b/conda/recipes/libcucim/conda_build_config.yaml @@ -17,7 +17,7 @@ c_stdlib_version: - "2.28" cmake_version: - - ">=3.26.4,!=3.30.0" + - ">=3.30.4" # The CTK libraries below are missing from the conda-forge::cudatoolkit package # for CUDA 11. The "*_host_*" version specifiers correspond to `11.8` packages diff --git a/cpp/cmake/deps/abseil.cmake b/cpp/cmake/deps/abseil.cmake index 72b27f2a2..591d7e1c0 100644 --- a/cpp/cmake/deps/abseil.cmake +++ b/cpp/cmake/deps/abseil.cmake @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2025, NVIDIA CORPORATION. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -19,18 +19,16 @@ if (NOT TARGET deps::abseil) GIT_REPOSITORY https://github.com/abseil/abseil-cpp.git GIT_TAG 20200225.2 GIT_SHALLOW TRUE + EXCLUDE_FROM_ALL ) - FetchContent_GetProperties(deps-abseil) - if (NOT deps-abseil_POPULATED) - message(STATUS "Fetching abseil sources") - FetchContent_Populate(deps-abseil) - message(STATUS "Fetching abseil sources - done") - endif () # Create static library cucim_set_build_shared_libs(OFF) - set(BUILD_TESTING FALSE) # Disable BUILD_TESTING (cmake-build-debug/_deps/deps-abseil-src/CMakeLists.txt:97) - add_subdirectory(${deps-abseil_SOURCE_DIR} ${deps-abseil_BINARY_DIR} EXCLUDE_FROM_ALL) + # Disable BUILD_TESTING (cmake-build-debug/_deps/deps-abseil-src/CMakeLists.txt:97) + set(BUILD_TESTING FALSE) + message(STATUS "Fetching abseil sources") + FetchContent_MakeAvailable(deps-abseil) + message(STATUS "Fetching abseil sources - done") # Set PIC to prevent the following error message # : /usr/bin/ld: ../lib/libabsl_strings.a(escaping.cc.o): relocation R_X86_64_PC32 against symbol `_ZN4absl14lts_2020_02_2516numbers_internal8kHexCharE' can not be used when making a shared object; recompile with -fPIC diff --git a/cpp/cmake/deps/boost-header-only.cmake b/cpp/cmake/deps/boost-header-only.cmake index 67624a201..104c0b910 100644 --- a/cpp/cmake/deps/boost-header-only.cmake +++ b/cpp/cmake/deps/boost-header-only.cmake @@ -1,5 +1,5 @@ # -# Copyright (c) 2021, NVIDIA CORPORATION. +# Copyright (c) 2021-2025, NVIDIA CORPORATION. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -14,42 +14,19 @@ # if (NOT TARGET deps::boost-header-only) + find_package(Git REQUIRED) set(Boost_VERSION 1.75.0) set(boost_component_list "interprocess" "config" "intrusive" "move" "assert" "static_assert" "container" "core" "date_time" "smart_ptr" "throw_exception" "utility" "type_traits" "numeric/conversion" "mpl" "preprocessor" "container_hash" "integer" "detail") - FetchContent_Declare( - deps-boost-header-only - GIT_REPOSITORY https://github.com/boostorg/boost.git - GIT_TAG boost-${Boost_VERSION} - GIT_SHALLOW TRUE - ) - - FetchContent_GetProperties(deps-boost-header-only) - if (NOT deps-boost-header-only_POPULATED) - message(STATUS "Fetching boost-header-only sources") - FetchContent_Populate(deps-boost-header-only) - message(STATUS "Fetching boost-header-only sources - done") - message(STATUS "Applying patch for boost-header-only") - find_package(Git) - if(Git_FOUND OR GIT_FOUND) - execute_process( - COMMAND bash -c "${GIT_EXECUTABLE} reset HEAD --hard && ${GIT_EXECUTABLE} apply ${CMAKE_CURRENT_LIST_DIR}/boost-header-only.patch" - WORKING_DIRECTORY "${deps-boost-header-only_SOURCE_DIR}/libs/interprocess" - RESULT_VARIABLE exec_result - ERROR_VARIABLE exec_error - ERROR_STRIP_TRAILING_WHITESPACE - OUTPUT_VARIABLE exec_output - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - if(exec_result EQUAL 0) - message(STATUS "Applying patch for boost-header-only - done") - else() - message(STATUS "Applying patch for boost-header-only - failed") - message(FATAL_ERROR "${exec_output}\n${exec_error}") - endif() - endif () - endif () + message(STATUS "Fetching boost-header-only sources") + FetchContent_Populate(deps-boost-header-only + GIT_REPOSITORY https://github.com/boostorg/boost.git + GIT_TAG boost-${Boost_VERSION} + GIT_SHALLOW TRUE + PATCH_COMMAND ${GIT_EXECUTABLE} apply "${CMAKE_CURRENT_LIST_DIR}/boost-header-only.patch" --directory=libs/interprocess) + message(STATUS "Fetching boost-header-only sources - done") + FetchContent_GetProperties(deps-boost-header-only) add_library(deps::boost-header-only INTERFACE IMPORTED GLOBAL) unset(boost_include_string) diff --git a/cpp/cmake/deps/boost.cmake b/cpp/cmake/deps/boost.cmake index 3fb6db1e9..57e04a07f 100644 --- a/cpp/cmake/deps/boost.cmake +++ b/cpp/cmake/deps/boost.cmake @@ -1,5 +1,5 @@ # -# Copyright (c) 2020-2021, NVIDIA CORPORATION. +# Copyright (c) 2020-2025, NVIDIA CORPORATION. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -14,6 +14,9 @@ # if (NOT TARGET deps::boost) + cmake_policy(PUSH) + cmake_policy(SET CMP0169 OLD) + set(Boost_VERSION 1.75.0) set(Boost_BUILD_COMPONENTS container) set(Boost_BUILD_OPTIONS "threading=multi cxxflags=-fPIC runtime-link=static variant=release link=static address-model=64 --layout=system") @@ -72,4 +75,6 @@ if (NOT TARGET deps::boost) set(deps-boost_SOURCE_DIR ${deps-boost_SOURCE_DIR} CACHE INTERNAL "" FORCE) mark_as_advanced(deps-boost_SOURCE_DIR) + + cmake_policy(POP) endif () diff --git a/cpp/cmake/deps/catch2.cmake b/cpp/cmake/deps/catch2.cmake index 4ee4bfabd..666aa5627 100644 --- a/cpp/cmake/deps/catch2.cmake +++ b/cpp/cmake/deps/catch2.cmake @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2025, NVIDIA CORPORATION. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -19,15 +19,12 @@ if (NOT TARGET deps::catch2) GIT_REPOSITORY https://github.com/catchorg/Catch2.git GIT_TAG v3.4.0 GIT_SHALLOW TRUE + EXCLUDE_FROM_ALL ) - FetchContent_GetProperties(deps-catch2) - if (NOT deps-catch2_POPULATED) - message(STATUS "Fetching catch2 sources") - FetchContent_Populate(deps-catch2) - message(STATUS "Fetching catch2 sources - done") - endif () - add_subdirectory(${deps-catch2_SOURCE_DIR} ${deps-catch2_BINARY_DIR} EXCLUDE_FROM_ALL) + message(STATUS "Fetching catch2 sources") + FetchContent_MakeAvailable(deps-catch2) + message(STATUS "Fetching catch2 sources - done") # Include Append catch2's cmake module path so that we can use `include(Catch)`. # https://github.com/catchorg/Catch2/blob/devel/docs/cmake-integration.md#catchcmake-and-catchaddtestscmake diff --git a/cpp/cmake/deps/cli11.cmake b/cpp/cmake/deps/cli11.cmake index 185913c8e..b4d7b5e10 100644 --- a/cpp/cmake/deps/cli11.cmake +++ b/cpp/cmake/deps/cli11.cmake @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2025, NVIDIA CORPORATION. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -19,15 +19,14 @@ if (NOT TARGET deps::cli11) GIT_REPOSITORY https://github.com/CLIUtils/CLI11.git GIT_TAG v1.9.1 GIT_SHALLOW TRUE + EXCLUDE_FROM_ALL ) - FetchContent_GetProperties(deps-cli11) - if (NOT deps-cli11_POPULATED) - message(STATUS "Fetching cli11 sources") - FetchContent_Populate(deps-cli11) - message(STATUS "Fetching cli11 sources - done") - endif () - - add_subdirectory(${deps-cli11_SOURCE_DIR} ${deps-cli11_BINARY_DIR} EXCLUDE_FROM_ALL) + message(STATUS "Fetching cli11 sources") + set(CLI11_BUILD_DOCS OFF) + set(CLI11_BUILD_EXAMPLES OFF) + set(CLI11_BUILD_TESTS OFF) + FetchContent_MakeAvailable(deps-cli11) + message(STATUS "Fetching cli11 sources - done") add_library(deps::cli11 INTERFACE IMPORTED GLOBAL) target_link_libraries(deps::cli11 INTERFACE CLI11::CLI11) diff --git a/cpp/cmake/deps/fmt.cmake b/cpp/cmake/deps/fmt.cmake index ef2797e18..2e08bc3bb 100644 --- a/cpp/cmake/deps/fmt.cmake +++ b/cpp/cmake/deps/fmt.cmake @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2025, NVIDIA CORPORATION. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -19,17 +19,16 @@ if (NOT TARGET deps::fmt) GIT_REPOSITORY https://github.com/fmtlib/fmt.git GIT_TAG 7.0.1 GIT_SHALLOW TRUE + EXCLUDE_FROM_ALL ) - FetchContent_GetProperties(deps-fmt) - if (NOT deps-fmt_POPULATED) - message(STATUS "Fetching fmt sources") - FetchContent_Populate(deps-fmt) - message(STATUS "Fetching fmt sources - done") - endif () + + message(STATUS "Fetching fmt sources") # Create static library cucim_set_build_shared_libs(OFF) - add_subdirectory(${deps-fmt_SOURCE_DIR} ${deps-fmt_BINARY_DIR} EXCLUDE_FROM_ALL) + + FetchContent_MakeAvailable(deps-fmt) + message(STATUS "Fetching fmt sources - done") # Set PIC to prevent the following error message # : /usr/bin/ld: ../lib/libfmtd.a(format.cc.o): relocation R_X86_64_PC32 against symbol `stderr@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC diff --git a/cpp/cmake/deps/googlebenchmark.cmake b/cpp/cmake/deps/googlebenchmark.cmake index c5f46ba3e..362942c84 100644 --- a/cpp/cmake/deps/googlebenchmark.cmake +++ b/cpp/cmake/deps/googlebenchmark.cmake @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2025, NVIDIA CORPORATION. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -19,18 +19,17 @@ if (NOT TARGET deps::googlebenchmark) GIT_REPOSITORY https://github.com/google/benchmark.git GIT_TAG v1.5.1 GIT_SHALLOW TRUE + EXCLUDE_FROM_ALL ) - FetchContent_GetProperties(deps-googlebenchmark) - if (NOT deps-googlebenchmark_POPULATED) - message(STATUS "Fetching googlebenchmark sources") - FetchContent_Populate(deps-googlebenchmark) - message(STATUS "Fetching googlebenchmark sources - done") - endif () + + message(STATUS "Fetching googlebenchmark sources") # Create static library cucim_set_build_shared_libs(OFF) set(BENCHMARK_ENABLE_GTEST_TESTS OFF) - add_subdirectory(${deps-googlebenchmark_SOURCE_DIR} ${deps-googlebenchmark_BINARY_DIR} EXCLUDE_FROM_ALL) + FetchContent_MakeAvailable(deps-googlebenchmark) + message(STATUS "Fetching googlebenchmark sources - done") + cucim_restore_build_shared_libs() add_library(deps::googlebenchmark INTERFACE IMPORTED GLOBAL) diff --git a/cpp/cmake/deps/googletest.cmake b/cpp/cmake/deps/googletest.cmake index f85dd85b6..c4acc3f51 100644 --- a/cpp/cmake/deps/googletest.cmake +++ b/cpp/cmake/deps/googletest.cmake @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2025, NVIDIA CORPORATION. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -19,17 +19,13 @@ if (NOT TARGET deps::googletest) GIT_REPOSITORY https://github.com/google/googletest.git GIT_TAG release-1.10.0 GIT_SHALLOW TRUE + EXCLUDE_FROM_ALL ) - FetchContent_GetProperties(deps-googletest) - if (NOT deps-googletest_POPULATED) - message(STATUS "Fetching googletest sources") - FetchContent_Populate(deps-googletest) - message(STATUS "Fetching googletest sources - done") - endif () - + message(STATUS "Fetching googletest sources") # Create static library cucim_set_build_shared_libs(OFF) - add_subdirectory(${deps-googletest_SOURCE_DIR} ${deps-googletest_BINARY_DIR} EXCLUDE_FROM_ALL) + FetchContent_MakeAvailable(deps-googletest) + message(STATUS "Fetching googletest sources - done") cucim_restore_build_shared_libs() add_library(deps::googletest INTERFACE IMPORTED GLOBAL) diff --git a/cpp/cmake/deps/json.cmake b/cpp/cmake/deps/json.cmake index c3f258ee1..a22f3c638 100644 --- a/cpp/cmake/deps/json.cmake +++ b/cpp/cmake/deps/json.cmake @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2025, NVIDIA CORPORATION. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -19,19 +19,17 @@ if (NOT TARGET deps::json) GIT_REPOSITORY https://github.com/nlohmann/json.git GIT_TAG v3.9.1 GIT_SHALLOW TRUE + EXCLUDE_FROM_ALL ) - FetchContent_GetProperties(deps-json) - if (NOT deps-json_POPULATED) - message(STATUS "Fetching json sources") - FetchContent_Populate(deps-json) - message(STATUS "Fetching json sources - done") - endif () + + message(STATUS "Fetching json sources") # Typically you don't care so much for a third party library's tests to be # run from your own project's code. - set(JSON_BuildTests OFF CACHE INTERNAL "") + option(JSON_BuildTests OFF) - add_subdirectory(${deps-json_SOURCE_DIR} ${deps-json_BINARY_DIR} EXCLUDE_FROM_ALL) + FetchContent_MakeAvailable(deps-json) + message(STATUS "Fetching json sources - done") add_library(deps::json INTERFACE IMPORTED GLOBAL) target_link_libraries(deps::json INTERFACE nlohmann_json::nlohmann_json) diff --git a/cpp/cmake/deps/libcuckoo.cmake b/cpp/cmake/deps/libcuckoo.cmake index 3089730bc..a3423dd32 100644 --- a/cpp/cmake/deps/libcuckoo.cmake +++ b/cpp/cmake/deps/libcuckoo.cmake @@ -1,5 +1,5 @@ # Apache License, Version 2.0 -# Copyright 2021 NVIDIA Corporation +# Copyright 2021-2025 NVIDIA Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,42 +14,22 @@ # limitations under the License. if (NOT TARGET deps::libcuckoo) + find_package(Git REQUIRED) + FetchContent_Declare( deps-libcuckoo GIT_REPOSITORY https://github.com/efficient/libcuckoo GIT_TAG v0.3 GIT_SHALLOW TRUE + PATCH_COMMAND ${GIT_EXECUTABLE} apply "${CMAKE_CURRENT_LIST_DIR}/libcuckoo.patch" + EXCLUDE_FROM_ALL ) - FetchContent_GetProperties(deps-libcuckoo) - if (NOT deps-libcuckoo_POPULATED) - message(STATUS "Fetching libcuckoo sources") - FetchContent_Populate(deps-libcuckoo) - message(STATUS "Fetching libcuckoo sources - done") - - message(STATUS "Applying patch for libcuckoo") - find_package(Git) - if(Git_FOUND OR GIT_FOUND) - execute_process( - COMMAND bash -c "${GIT_EXECUTABLE} reset HEAD --hard && ${GIT_EXECUTABLE} apply ${CMAKE_CURRENT_LIST_DIR}/libcuckoo.patch" - WORKING_DIRECTORY "${deps-libcuckoo_SOURCE_DIR}" - RESULT_VARIABLE exec_result - ERROR_VARIABLE exec_error - ERROR_STRIP_TRAILING_WHITESPACE - OUTPUT_VARIABLE exec_output - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - if(exec_result EQUAL 0) - message(STATUS "Applying patch for libcuckoo - done") - else() - message(STATUS "Applying patch for libcuckoo - failed") - message(FATAL_ERROR "${exec_output}\n${exec_error}") - endif() - endif () - endif () - + message(STATUS "Fetching libcuckoo sources") # Create static library cucim_set_build_shared_libs(OFF) - add_subdirectory(${deps-libcuckoo_SOURCE_DIR} ${deps-libcuckoo_BINARY_DIR} EXCLUDE_FROM_ALL) + FetchContent_MakeAvailable(deps-libcuckoo) + message(STATUS "Fetching libcuckoo sources - done") + # libcuckoo's CMakeLists.txt is not compatible with `add_subdirectory` method (it uses ${CMAKE_SOURCE_DIR} instead of ${CMAKE_CURRENT_SOURCE_DIR}) # so add include directories explicitly. target_include_directories(libcuckoo INTERFACE diff --git a/cpp/cmake/deps/nvtx3.cmake b/cpp/cmake/deps/nvtx3.cmake index f079181ab..35d6d9003 100644 --- a/cpp/cmake/deps/nvtx3.cmake +++ b/cpp/cmake/deps/nvtx3.cmake @@ -1,5 +1,5 @@ # -# Copyright (c) 2021, NVIDIA CORPORATION. +# Copyright (c) 2021-2025, NVIDIA CORPORATION. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -17,15 +17,12 @@ if (NOT TARGET deps::nvtx3) FetchContent_Declare( deps-nvtx3 GIT_REPOSITORY https://github.com/NVIDIA/NVTX.git - GIT_TAG 3c98c8425b0376fd8653aac7cfc6a864f3897752 - # GIT_SHALLOW TRUE # TODO (#168): Uncomment this when the official release of nvtx3-cpp is available + GIT_TAG v3.1.1 + GIT_SHALLOW TRUE + SOURCE_SUBDIR c + EXCLUDE_FROM_ALL ) - FetchContent_GetProperties(deps-nvtx3) - if (NOT deps-nvtx3_POPULATED) - message(STATUS "Fetching nvtx3 sources") - FetchContent_Populate(deps-nvtx3) - message(STATUS "Fetching nvtx3 sources - done") - endif () + message(STATUS "Fetching nvtx3 sources") # Create shared library cucim_set_build_shared_libs(ON) # since nvtx3 is header-only library, this may not needed. @@ -33,7 +30,9 @@ if (NOT TARGET deps::nvtx3) set(BUILD_TESTS OFF) set(BUILD_BENCHMARKS OFF) - add_subdirectory(${deps-nvtx3_SOURCE_DIR}/cpp ${deps-nvtx3_BINARY_DIR} EXCLUDE_FROM_ALL) + FetchContent_MakeAvailable(deps-nvtx3) + message(STATUS "Fetching nvtx3 sources - done") + cucim_restore_build_shared_libs() add_library(deps::nvtx3 INTERFACE IMPORTED GLOBAL) diff --git a/cpp/cmake/deps/openslide.cmake b/cpp/cmake/deps/openslide.cmake index 8e44e33a5..2ec1e3fd0 100644 --- a/cpp/cmake/deps/openslide.cmake +++ b/cpp/cmake/deps/openslide.cmake @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2025, NVIDIA CORPORATION. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/cpp/cmake/deps/pybind11.cmake b/cpp/cmake/deps/pybind11.cmake index e4ea6f583..19aab2ec4 100644 --- a/cpp/cmake/deps/pybind11.cmake +++ b/cpp/cmake/deps/pybind11.cmake @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2025, NVIDIA CORPORATION. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -14,24 +14,21 @@ # if (NOT TARGET deps::pybind11) + find_package(Git REQUIRED) + FetchContent_Declare( deps-pybind11 GIT_REPOSITORY https://github.com/pybind/pybind11.git GIT_TAG v2.11.1 GIT_SHALLOW TRUE - PATCH_COMMAND git apply "${CMAKE_CURRENT_LIST_DIR}/pybind11_pr4857_4877.patch" || true + PATCH_COMMAND ${GIT_EXECUTABLE} apply "${CMAKE_CURRENT_LIST_DIR}/pybind11_pr4857_4877.patch" + EXCLUDE_FROM_ALL ) - FetchContent_GetProperties(deps-pybind11) - if (NOT deps-pybind11_POPULATED) - message(STATUS "Fetching pybind11 sources") - FetchContent_Populate(deps-pybind11) - message(STATUS "Fetching pybind11 sources - done") - endif () + message(STATUS "Fetching pybind11 sources") + FetchContent_MakeAvailable(deps-pybind11) + message(STATUS "Fetching pybind11 sources - done") # https://pybind11.readthedocs.io/en/stable/compiling.html#configuration-variables - - add_subdirectory(${deps-pybind11_SOURCE_DIR} ${deps-pybind11_BINARY_DIR} EXCLUDE_FROM_ALL) - add_library(deps::pybind11 INTERFACE IMPORTED GLOBAL) target_link_libraries(deps::pybind11 INTERFACE pybind11::module) set(deps-pybind11_SOURCE_DIR ${deps-pybind11_SOURCE_DIR} CACHE INTERNAL "" FORCE) diff --git a/cpp/cmake/deps/rmm.cmake b/cpp/cmake/deps/rmm.cmake index 9363ce188..06aa12466 100644 --- a/cpp/cmake/deps/rmm.cmake +++ b/cpp/cmake/deps/rmm.cmake @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2025, NVIDIA CORPORATION. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -24,18 +24,15 @@ if (NOT TARGET deps::rmm) GIT_REPOSITORY https://github.com/rapidsai/rmm.git GIT_TAG branch-0.17 GIT_SHALLOW TRUE + EXCLUDE_FROM_ALL ) - FetchContent_GetProperties(deps-rmm) - if (NOT deps-rmm_POPULATED) - message(STATUS "Fetching rmm sources") - FetchContent_Populate(deps-rmm) - message(STATUS "Fetching rmm sources - done") - endif () - + message(STATUS "Fetching rmm sources") # Create shared library cucim_set_build_shared_libs(ON) # Since rmm doesn't use BUILD_SHARED_LIBS, it always build shared library - add_subdirectory(${deps-rmm_SOURCE_DIR} ${deps-rmm_BINARY_DIR} EXCLUDE_FROM_ALL) + FetchContent_MakeAvailable(deps-rmm) + message(STATUS "Fetching rmm sources - done") + cucim_restore_build_shared_libs() add_library(deps::rmm INTERFACE IMPORTED GLOBAL) diff --git a/cpp/cmake/deps/taskflow.cmake b/cpp/cmake/deps/taskflow.cmake index 147b6f4c3..5081c9b38 100644 --- a/cpp/cmake/deps/taskflow.cmake +++ b/cpp/cmake/deps/taskflow.cmake @@ -1,5 +1,5 @@ # -# Copyright (c) 2021, NVIDIA CORPORATION. +# Copyright (c) 2021-2025, NVIDIA CORPORATION. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -19,18 +19,14 @@ if (NOT TARGET deps::taskflow) GIT_REPOSITORY https://github.com/taskflow/taskflow.git GIT_TAG v3.2.0 GIT_SHALLOW TRUE + EXCLUDE_FROM_ALL ) - FetchContent_GetProperties(deps-taskflow) - if (NOT deps-taskflow_POPULATED) - message(STATUS "Fetching taskflow sources") - FetchContent_Populate(deps-taskflow) - message(STATUS "Fetching taskflow sources - done") - endif () - + message(STATUS "Fetching taskflow sources") set(TF_BUILD_TESTS OFF) set(TF_BUILD_EXAMPLES OFF) - add_subdirectory(${deps-taskflow_SOURCE_DIR} ${deps-taskflow_BINARY_DIR} EXCLUDE_FROM_ALL) + FetchContent_MakeAvailable(deps-taskflow) + message(STATUS "Fetching taskflow sources - done") add_library(deps::taskflow INTERFACE IMPORTED GLOBAL) target_link_libraries(deps::taskflow INTERFACE Taskflow) diff --git a/cpp/include/cucim/profiler/nvtx3.h b/cpp/include/cucim/profiler/nvtx3.h index e438a305a..b8b259167 100644 --- a/cpp/include/cucim/profiler/nvtx3.h +++ b/cpp/include/cucim/profiler/nvtx3.h @@ -136,8 +136,8 @@ struct domain // Aliases using scoped_range = nvtx3::cucim_scoped_range_in; -using category = nvtx3::named_category; -using message = nvtx3::registered_string; +using category = nvtx3::named_category_in; +using message = nvtx3::registered_string_in; // Category struct category_io diff --git a/cpp/plugins/cucim.kit.cumed/CMakeLists.txt b/cpp/plugins/cucim.kit.cumed/CMakeLists.txt index b1743e70a..04b72544b 100644 --- a/cpp/plugins/cucim.kit.cumed/CMakeLists.txt +++ b/cpp/plugins/cucim.kit.cumed/CMakeLists.txt @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -cmake_minimum_required(VERSION 3.26.4) +cmake_minimum_required(VERSION 3.30.4 FATAL_ERROR) ################################################################################ # Prerequisite statements diff --git a/cpp/plugins/cucim.kit.cumed/cmake/deps/catch2.cmake b/cpp/plugins/cucim.kit.cumed/cmake/deps/catch2.cmake index 6a35a9c0b..7d9773474 100644 --- a/cpp/plugins/cucim.kit.cumed/cmake/deps/catch2.cmake +++ b/cpp/plugins/cucim.kit.cumed/cmake/deps/catch2.cmake @@ -1,5 +1,5 @@ # -# Copyright (c) 2021, NVIDIA CORPORATION. +# Copyright (c) 2021-2025, NVIDIA CORPORATION. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -19,15 +19,12 @@ if (NOT TARGET deps::catch2) GIT_REPOSITORY https://github.com/catchorg/Catch2.git GIT_TAG v3.4.0 GIT_SHALLOW TRUE + EXCLUDE_FROM_ALL ) - FetchContent_GetProperties(deps-catch2) - if (NOT deps-catch2_POPULATED) - message(STATUS "Fetching catch2 sources") - FetchContent_Populate(deps-catch2) - message(STATUS "Fetching catch2 sources - done") - endif () - add_subdirectory(${deps-catch2_SOURCE_DIR} ${deps-catch2_BINARY_DIR} EXCLUDE_FROM_ALL) + message(STATUS "Fetching catch2 sources") + FetchContent_MakeAvailable(deps-catch2) + message(STATUS "Fetching catch2 sources - done") # Include Append catch2's cmake module path so that we can use `include(Catch)`. # https://github.com/catchorg/Catch2/blob/devel/docs/cmake-integration.md#catchcmake-and-catchaddtestscmake diff --git a/cpp/plugins/cucim.kit.cumed/cmake/deps/cli11.cmake b/cpp/plugins/cucim.kit.cumed/cmake/deps/cli11.cmake index 2afb77841..03c2888c6 100644 --- a/cpp/plugins/cucim.kit.cumed/cmake/deps/cli11.cmake +++ b/cpp/plugins/cucim.kit.cumed/cmake/deps/cli11.cmake @@ -1,5 +1,5 @@ # -# Copyright (c) 2021, NVIDIA CORPORATION. +# Copyright (c) 2021-2025, NVIDIA CORPORATION. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -19,15 +19,14 @@ if (NOT TARGET deps::cli11) GIT_REPOSITORY https://github.com/CLIUtils/CLI11.git GIT_TAG v1.9.1 GIT_SHALLOW TRUE + EXCLUDE_FROM_ALL ) - FetchContent_GetProperties(deps-cli11) - if (NOT deps-cli11_POPULATED) - message(STATUS "Fetching cli11 sources") - FetchContent_Populate(deps-cli11) - message(STATUS "Fetching cli11 sources - done") - endif () - - add_subdirectory(${deps-cli11_SOURCE_DIR} ${deps-cli11_BINARY_DIR} EXCLUDE_FROM_ALL) + message(STATUS "Fetching cli11 sources") + set(CLI11_BUILD_DOCS OFF) + set(CLI11_BUILD_EXAMPLES OFF) + set(CLI11_BUILD_TESTS OFF) + FetchContent_MakeAvailable(deps-cli11) + message(STATUS "Fetching cli11 sources - done") add_library(deps::cli11 INTERFACE IMPORTED GLOBAL) target_link_libraries(deps::cli11 INTERFACE CLI11::CLI11) diff --git a/cpp/plugins/cucim.kit.cumed/cmake/deps/fmt.cmake b/cpp/plugins/cucim.kit.cumed/cmake/deps/fmt.cmake index cdf40f061..965e21530 100644 --- a/cpp/plugins/cucim.kit.cumed/cmake/deps/fmt.cmake +++ b/cpp/plugins/cucim.kit.cumed/cmake/deps/fmt.cmake @@ -1,17 +1,17 @@ -# Apache License, Version 2.0 -# Copyright 2021 NVIDIA Corporation # +# Copyright (c) 2021-2025, NVIDIA CORPORATION. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +# if (NOT TARGET deps::fmt) FetchContent_Declare( @@ -19,17 +19,17 @@ if (NOT TARGET deps::fmt) GIT_REPOSITORY https://github.com/fmtlib/fmt.git GIT_TAG 7.0.1 GIT_SHALLOW TRUE + EXCLUDE_FROM_ALL ) - FetchContent_GetProperties(deps-fmt) - if (NOT deps-fmt_POPULATED) - message(STATUS "Fetching fmt sources") - FetchContent_Populate(deps-fmt) - message(STATUS "Fetching fmt sources - done") - endif () + + message(STATUS "Fetching fmt sources") # Create static library cucim_set_build_shared_libs(OFF) - add_subdirectory(${deps-fmt_SOURCE_DIR} ${deps-fmt_BINARY_DIR} EXCLUDE_FROM_ALL) + + FetchContent_MakeAvailable(deps-fmt) + message(STATUS "Fetching fmt sources - done") + # Set PIC to prevent the following error message # : /usr/bin/ld: ../lib/libfmtd.a(format.cc.o): relocation R_X86_64_PC32 against symbol `stderr@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC set_target_properties(fmt PROPERTIES POSITION_INDEPENDENT_CODE ON) diff --git a/cpp/plugins/cucim.kit.cumed/cmake/deps/googlebenchmark.cmake b/cpp/plugins/cucim.kit.cumed/cmake/deps/googlebenchmark.cmake index 05dc2d696..86411f349 100644 --- a/cpp/plugins/cucim.kit.cumed/cmake/deps/googlebenchmark.cmake +++ b/cpp/plugins/cucim.kit.cumed/cmake/deps/googlebenchmark.cmake @@ -1,5 +1,5 @@ # -# Copyright (c) 2021, NVIDIA CORPORATION. +# Copyright (c) 2021-2025, NVIDIA CORPORATION. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -19,18 +19,17 @@ if (NOT TARGET deps::googlebenchmark) GIT_REPOSITORY https://github.com/google/benchmark.git GIT_TAG v1.5.1 GIT_SHALLOW TRUE + EXCLUDE_FROM_ALL ) - FetchContent_GetProperties(deps-googlebenchmark) - if (NOT deps-googlebenchmark_POPULATED) - message(STATUS "Fetching googlebenchmark sources") - FetchContent_Populate(deps-googlebenchmark) - message(STATUS "Fetching googlebenchmark sources - done") - endif () + + message(STATUS "Fetching googlebenchmark sources") # Create static library cucim_set_build_shared_libs(OFF) set(BENCHMARK_ENABLE_GTEST_TESTS OFF) - add_subdirectory(${deps-googlebenchmark_SOURCE_DIR} ${deps-googlebenchmark_BINARY_DIR} EXCLUDE_FROM_ALL) + FetchContent_MakeAvailable(deps-googlebenchmark) + message(STATUS "Fetching googlebenchmark sources - done") + cucim_restore_build_shared_libs() add_library(deps::googlebenchmark INTERFACE IMPORTED GLOBAL) diff --git a/cpp/plugins/cucim.kit.cumed/cmake/deps/googletest.cmake b/cpp/plugins/cucim.kit.cumed/cmake/deps/googletest.cmake index a9e878601..e78f7fbd4 100644 --- a/cpp/plugins/cucim.kit.cumed/cmake/deps/googletest.cmake +++ b/cpp/plugins/cucim.kit.cumed/cmake/deps/googletest.cmake @@ -1,5 +1,5 @@ # -# Copyright (c) 2021, NVIDIA CORPORATION. +# Copyright (c) 2021-2025, NVIDIA CORPORATION. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -19,17 +19,13 @@ if (NOT TARGET deps::googletest) GIT_REPOSITORY https://github.com/google/googletest.git GIT_TAG release-1.10.0 GIT_SHALLOW TRUE + EXCLUDE_FROM_ALL ) - FetchContent_GetProperties(deps-googletest) - if (NOT deps-googletest_POPULATED) - message(STATUS "Fetching googletest sources") - FetchContent_Populate(deps-googletest) - message(STATUS "Fetching googletest sources - done") - endif () - + message(STATUS "Fetching googletest sources") # Create static library cucim_set_build_shared_libs(OFF) - add_subdirectory(${deps-googletest_SOURCE_DIR} ${deps-googletest_BINARY_DIR} EXCLUDE_FROM_ALL) + FetchContent_MakeAvailable(deps-googletest) + message(STATUS "Fetching googletest sources - done") cucim_restore_build_shared_libs() add_library(deps::googletest INTERFACE IMPORTED GLOBAL) diff --git a/cpp/plugins/cucim.kit.cuslide/CMakeLists.txt b/cpp/plugins/cucim.kit.cuslide/CMakeLists.txt index c52c564d8..32f19a09b 100644 --- a/cpp/plugins/cucim.kit.cuslide/CMakeLists.txt +++ b/cpp/plugins/cucim.kit.cuslide/CMakeLists.txt @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -cmake_minimum_required(VERSION 3.26.4) +cmake_minimum_required(VERSION 3.30.4 FATAL_ERROR) ################################################################################ # Prerequisite statements diff --git a/cpp/plugins/cucim.kit.cuslide/cmake/deps/boost.cmake b/cpp/plugins/cucim.kit.cuslide/cmake/deps/boost.cmake index 3fb6db1e9..44734c201 100644 --- a/cpp/plugins/cucim.kit.cuslide/cmake/deps/boost.cmake +++ b/cpp/plugins/cucim.kit.cuslide/cmake/deps/boost.cmake @@ -1,5 +1,5 @@ # -# Copyright (c) 2020-2021, NVIDIA CORPORATION. +# Copyright (c) 2020-2025, NVIDIA CORPORATION. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -14,6 +14,9 @@ # if (NOT TARGET deps::boost) + cmake_policy(PUSH) + cmake_policy(SET CMP0169 OLD) + set(Boost_VERSION 1.75.0) set(Boost_BUILD_COMPONENTS container) set(Boost_BUILD_OPTIONS "threading=multi cxxflags=-fPIC runtime-link=static variant=release link=static address-model=64 --layout=system") @@ -28,7 +31,7 @@ if (NOT TARGET deps::boost) set(Boost_USE_STATIC_RUNTIME ON) foreach(component_name ${Boost_BUILD_COMPONENTS}) - list(APPEND Boost_BUILD_VARIANTS --with-${component_name}) + list(APPEND Boost_BUILD_VARIANTS --with-${component_name}) endforeach() FetchContent_Declare( @@ -72,4 +75,6 @@ if (NOT TARGET deps::boost) set(deps-boost_SOURCE_DIR ${deps-boost_SOURCE_DIR} CACHE INTERNAL "" FORCE) mark_as_advanced(deps-boost_SOURCE_DIR) + + cmake_policy(POP) endif () diff --git a/cpp/plugins/cucim.kit.cuslide/cmake/deps/catch2.cmake b/cpp/plugins/cucim.kit.cuslide/cmake/deps/catch2.cmake index 4ee4bfabd..666aa5627 100644 --- a/cpp/plugins/cucim.kit.cuslide/cmake/deps/catch2.cmake +++ b/cpp/plugins/cucim.kit.cuslide/cmake/deps/catch2.cmake @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2025, NVIDIA CORPORATION. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -19,15 +19,12 @@ if (NOT TARGET deps::catch2) GIT_REPOSITORY https://github.com/catchorg/Catch2.git GIT_TAG v3.4.0 GIT_SHALLOW TRUE + EXCLUDE_FROM_ALL ) - FetchContent_GetProperties(deps-catch2) - if (NOT deps-catch2_POPULATED) - message(STATUS "Fetching catch2 sources") - FetchContent_Populate(deps-catch2) - message(STATUS "Fetching catch2 sources - done") - endif () - add_subdirectory(${deps-catch2_SOURCE_DIR} ${deps-catch2_BINARY_DIR} EXCLUDE_FROM_ALL) + message(STATUS "Fetching catch2 sources") + FetchContent_MakeAvailable(deps-catch2) + message(STATUS "Fetching catch2 sources - done") # Include Append catch2's cmake module path so that we can use `include(Catch)`. # https://github.com/catchorg/Catch2/blob/devel/docs/cmake-integration.md#catchcmake-and-catchaddtestscmake diff --git a/cpp/plugins/cucim.kit.cuslide/cmake/deps/cli11.cmake b/cpp/plugins/cucim.kit.cuslide/cmake/deps/cli11.cmake index 185913c8e..b4d7b5e10 100644 --- a/cpp/plugins/cucim.kit.cuslide/cmake/deps/cli11.cmake +++ b/cpp/plugins/cucim.kit.cuslide/cmake/deps/cli11.cmake @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2025, NVIDIA CORPORATION. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -19,15 +19,14 @@ if (NOT TARGET deps::cli11) GIT_REPOSITORY https://github.com/CLIUtils/CLI11.git GIT_TAG v1.9.1 GIT_SHALLOW TRUE + EXCLUDE_FROM_ALL ) - FetchContent_GetProperties(deps-cli11) - if (NOT deps-cli11_POPULATED) - message(STATUS "Fetching cli11 sources") - FetchContent_Populate(deps-cli11) - message(STATUS "Fetching cli11 sources - done") - endif () - - add_subdirectory(${deps-cli11_SOURCE_DIR} ${deps-cli11_BINARY_DIR} EXCLUDE_FROM_ALL) + message(STATUS "Fetching cli11 sources") + set(CLI11_BUILD_DOCS OFF) + set(CLI11_BUILD_EXAMPLES OFF) + set(CLI11_BUILD_TESTS OFF) + FetchContent_MakeAvailable(deps-cli11) + message(STATUS "Fetching cli11 sources - done") add_library(deps::cli11 INTERFACE IMPORTED GLOBAL) target_link_libraries(deps::cli11 INTERFACE CLI11::CLI11) diff --git a/cpp/plugins/cucim.kit.cuslide/cmake/deps/fmt.cmake b/cpp/plugins/cucim.kit.cuslide/cmake/deps/fmt.cmake index 2ca43a98d..2e08bc3bb 100644 --- a/cpp/plugins/cucim.kit.cuslide/cmake/deps/fmt.cmake +++ b/cpp/plugins/cucim.kit.cuslide/cmake/deps/fmt.cmake @@ -1,17 +1,17 @@ -# Apache License, Version 2.0 -# Copyright 2020 NVIDIA Corporation # +# Copyright (c) 2020-2025, NVIDIA CORPORATION. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +# if (NOT TARGET deps::fmt) FetchContent_Declare( @@ -19,17 +19,17 @@ if (NOT TARGET deps::fmt) GIT_REPOSITORY https://github.com/fmtlib/fmt.git GIT_TAG 7.0.1 GIT_SHALLOW TRUE + EXCLUDE_FROM_ALL ) - FetchContent_GetProperties(deps-fmt) - if (NOT deps-fmt_POPULATED) - message(STATUS "Fetching fmt sources") - FetchContent_Populate(deps-fmt) - message(STATUS "Fetching fmt sources - done") - endif () + + message(STATUS "Fetching fmt sources") # Create static library cucim_set_build_shared_libs(OFF) - add_subdirectory(${deps-fmt_SOURCE_DIR} ${deps-fmt_BINARY_DIR} EXCLUDE_FROM_ALL) + + FetchContent_MakeAvailable(deps-fmt) + message(STATUS "Fetching fmt sources - done") + # Set PIC to prevent the following error message # : /usr/bin/ld: ../lib/libfmtd.a(format.cc.o): relocation R_X86_64_PC32 against symbol `stderr@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC set_target_properties(fmt PROPERTIES POSITION_INDEPENDENT_CODE ON) diff --git a/cpp/plugins/cucim.kit.cuslide/cmake/deps/googlebenchmark.cmake b/cpp/plugins/cucim.kit.cuslide/cmake/deps/googlebenchmark.cmake index c5f46ba3e..362942c84 100644 --- a/cpp/plugins/cucim.kit.cuslide/cmake/deps/googlebenchmark.cmake +++ b/cpp/plugins/cucim.kit.cuslide/cmake/deps/googlebenchmark.cmake @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2025, NVIDIA CORPORATION. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -19,18 +19,17 @@ if (NOT TARGET deps::googlebenchmark) GIT_REPOSITORY https://github.com/google/benchmark.git GIT_TAG v1.5.1 GIT_SHALLOW TRUE + EXCLUDE_FROM_ALL ) - FetchContent_GetProperties(deps-googlebenchmark) - if (NOT deps-googlebenchmark_POPULATED) - message(STATUS "Fetching googlebenchmark sources") - FetchContent_Populate(deps-googlebenchmark) - message(STATUS "Fetching googlebenchmark sources - done") - endif () + + message(STATUS "Fetching googlebenchmark sources") # Create static library cucim_set_build_shared_libs(OFF) set(BENCHMARK_ENABLE_GTEST_TESTS OFF) - add_subdirectory(${deps-googlebenchmark_SOURCE_DIR} ${deps-googlebenchmark_BINARY_DIR} EXCLUDE_FROM_ALL) + FetchContent_MakeAvailable(deps-googlebenchmark) + message(STATUS "Fetching googlebenchmark sources - done") + cucim_restore_build_shared_libs() add_library(deps::googlebenchmark INTERFACE IMPORTED GLOBAL) diff --git a/cpp/plugins/cucim.kit.cuslide/cmake/deps/googletest.cmake b/cpp/plugins/cucim.kit.cuslide/cmake/deps/googletest.cmake index f85dd85b6..c4acc3f51 100644 --- a/cpp/plugins/cucim.kit.cuslide/cmake/deps/googletest.cmake +++ b/cpp/plugins/cucim.kit.cuslide/cmake/deps/googletest.cmake @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2025, NVIDIA CORPORATION. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -19,17 +19,13 @@ if (NOT TARGET deps::googletest) GIT_REPOSITORY https://github.com/google/googletest.git GIT_TAG release-1.10.0 GIT_SHALLOW TRUE + EXCLUDE_FROM_ALL ) - FetchContent_GetProperties(deps-googletest) - if (NOT deps-googletest_POPULATED) - message(STATUS "Fetching googletest sources") - FetchContent_Populate(deps-googletest) - message(STATUS "Fetching googletest sources - done") - endif () - + message(STATUS "Fetching googletest sources") # Create static library cucim_set_build_shared_libs(OFF) - add_subdirectory(${deps-googletest_SOURCE_DIR} ${deps-googletest_BINARY_DIR} EXCLUDE_FROM_ALL) + FetchContent_MakeAvailable(deps-googletest) + message(STATUS "Fetching googletest sources - done") cucim_restore_build_shared_libs() add_library(deps::googletest INTERFACE IMPORTED GLOBAL) diff --git a/cpp/plugins/cucim.kit.cuslide/cmake/deps/json.cmake b/cpp/plugins/cucim.kit.cuslide/cmake/deps/json.cmake index c3f258ee1..a22f3c638 100644 --- a/cpp/plugins/cucim.kit.cuslide/cmake/deps/json.cmake +++ b/cpp/plugins/cucim.kit.cuslide/cmake/deps/json.cmake @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2025, NVIDIA CORPORATION. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -19,19 +19,17 @@ if (NOT TARGET deps::json) GIT_REPOSITORY https://github.com/nlohmann/json.git GIT_TAG v3.9.1 GIT_SHALLOW TRUE + EXCLUDE_FROM_ALL ) - FetchContent_GetProperties(deps-json) - if (NOT deps-json_POPULATED) - message(STATUS "Fetching json sources") - FetchContent_Populate(deps-json) - message(STATUS "Fetching json sources - done") - endif () + + message(STATUS "Fetching json sources") # Typically you don't care so much for a third party library's tests to be # run from your own project's code. - set(JSON_BuildTests OFF CACHE INTERNAL "") + option(JSON_BuildTests OFF) - add_subdirectory(${deps-json_SOURCE_DIR} ${deps-json_BINARY_DIR} EXCLUDE_FROM_ALL) + FetchContent_MakeAvailable(deps-json) + message(STATUS "Fetching json sources - done") add_library(deps::json INTERFACE IMPORTED GLOBAL) target_link_libraries(deps::json INTERFACE nlohmann_json::nlohmann_json) diff --git a/cpp/plugins/cucim.kit.cuslide/cmake/deps/libculibos.cmake b/cpp/plugins/cucim.kit.cuslide/cmake/deps/libculibos.cmake index 2938198ea..3ebffeb84 100644 --- a/cpp/plugins/cucim.kit.cuslide/cmake/deps/libculibos.cmake +++ b/cpp/plugins/cucim.kit.cuslide/cmake/deps/libculibos.cmake @@ -1,5 +1,5 @@ # -# Copyright (c) 2022, NVIDIA CORPORATION. +# Copyright (c) 2022-2025, NVIDIA CORPORATION. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/cpp/plugins/cucim.kit.cuslide/cmake/deps/libdeflate.cmake b/cpp/plugins/cucim.kit.cuslide/cmake/deps/libdeflate.cmake index 675a5c718..47b21ea57 100644 --- a/cpp/plugins/cucim.kit.cuslide/cmake/deps/libdeflate.cmake +++ b/cpp/plugins/cucim.kit.cuslide/cmake/deps/libdeflate.cmake @@ -1,5 +1,5 @@ # -# Copyright (c) 2021, NVIDIA CORPORATION. +# Copyright (c) 2021-2025, NVIDIA CORPORATION. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -14,6 +14,9 @@ # if (NOT TARGET deps::libdeflate) + cmake_policy(PUSH) + cmake_policy(SET CMP0169 OLD) + FetchContent_Declare( deps-libdeflate GIT_REPOSITORY https://github.com/ebiggers/libdeflate.git @@ -56,4 +59,6 @@ if (NOT TARGET deps::libdeflate) set(deps-libdeflate_SOURCE_DIR ${deps-libdeflate_SOURCE_DIR} CACHE INTERNAL "" FORCE) mark_as_advanced(deps-libdeflate_SOURCE_DIR) + + cmake_policy(POP) endif () diff --git a/cpp/plugins/cucim.kit.cuslide/cmake/deps/libjpeg-turbo.cmake b/cpp/plugins/cucim.kit.cuslide/cmake/deps/libjpeg-turbo.cmake index fa0a9f2f5..3067ee3d4 100644 --- a/cpp/plugins/cucim.kit.cuslide/cmake/deps/libjpeg-turbo.cmake +++ b/cpp/plugins/cucim.kit.cuslide/cmake/deps/libjpeg-turbo.cmake @@ -1,5 +1,5 @@ # Apache License, Version 2.0 -# Copyright 2020-2021 NVIDIA Corporation +# Copyright 2020-2025 NVIDIA Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -26,13 +26,8 @@ if (NOT TARGET deps::libjpeg-turbo) GIT_REPOSITORY https://github.com/libjpeg-turbo/libjpeg-turbo.git GIT_TAG 2.0.6 GIT_SHALLOW TRUE + EXCLUDE_FROM_ALL ) - FetchContent_GetProperties(deps-libjpeg-turbo) - if (NOT deps-libjpeg-turbo_POPULATED) - message(STATUS "Fetching libjpeg-turbo sources") - FetchContent_Populate(deps-libjpeg-turbo) - message(STATUS "Fetching libjpeg-turbo sources - done") - endif () # Set policies for libjpeg-turbo set(CMAKE_PROJECT_INCLUDE_BEFORE "${CMAKE_CURRENT_LIST_DIR}/libjpeg-turbo-policies-fix.cmake") @@ -48,7 +43,9 @@ if (NOT TARGET deps::libjpeg-turbo) set(CMAKE_ASM_NASM_COMPILER yasm) set(REQUIRE_SIMD 1) # CMP0077 - add_subdirectory(${deps-libjpeg-turbo_SOURCE_DIR} ${deps-libjpeg-turbo_BINARY_DIR} EXCLUDE_FROM_ALL) + message(STATUS "Fetching libjpeg-turbo sources") + FetchContent_MakeAvailable(deps-libjpeg-turbo) + message(STATUS "Fetching libjpeg-turbo sources - done") # Disable visibility to not expose unnecessary symbols set_target_properties(turbojpeg-static diff --git a/cpp/plugins/cucim.kit.cuslide/cmake/deps/libopenjpeg.cmake b/cpp/plugins/cucim.kit.cuslide/cmake/deps/libopenjpeg.cmake index b080554f9..01d543f9e 100644 --- a/cpp/plugins/cucim.kit.cuslide/cmake/deps/libopenjpeg.cmake +++ b/cpp/plugins/cucim.kit.cuslide/cmake/deps/libopenjpeg.cmake @@ -1,5 +1,5 @@ # Apache License, Version 2.0 -# Copyright 2020-2021 NVIDIA Corporation +# Copyright 2020-2025 NVIDIA Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -21,12 +21,6 @@ if (NOT TARGET deps::libopenjpeg) GIT_TAG v2.5.0 GIT_SHALLOW TRUE ) - FetchContent_GetProperties(deps-libopenjpeg) - if (NOT deps-libopenjpeg_POPULATED) - message(STATUS "Fetching libopenjpeg sources") - FetchContent_Populate(deps-libopenjpeg) - message(STATUS "Fetching libopenjpeg sources - done") - endif () # Create static library # It build a static library when both BUILD_SHARED_LIBS and BUILD_STATIC_LIBS are ON @@ -35,46 +29,12 @@ if (NOT TARGET deps::libopenjpeg) # if(BUILD_SHARED_LIBS AND BUILD_STATIC_LIBS) cucim_set_build_shared_libs(ON) - ########################################################################### - # Build liblcms2 with the source in libopenjpeg - ########################################################################### - - add_subdirectory(${deps-libopenjpeg_SOURCE_DIR}/thirdparty/liblcms2 ${deps-libopenjpeg_BINARY_DIR}/thirdparty/liblcms2) - - # Override the output library folder path - set_target_properties(lcms2 - PROPERTIES - OUTPUT_NAME "lcms2" - ARCHIVE_OUTPUT_DIRECTORY ${deps-libopenjpeg_BINARY_DIR}/thirdparty/lib) - - # Override definition of OPJ_HAVE_LIBLCMS2 to build color_apply_icc_profile() method - target_compile_definitions(lcms2 - PUBLIC - OPJ_HAVE_LIBLCMS2=1 - ) - - # Set PIC to prevent the following error message - # : /usr/bin/ld: _deps/deps-libopenjpeg-build/thirdparty/lib/liblcms2.a(cmserr.c.o): relocation R_X86_64_PC32 against symbol `_cmsMemPluginChunk' can not be used when making a shared object; recompile with -fPIC - # /usr/bin/ld: final link failed: bad value - set_target_properties(lcms2 PROPERTIES POSITION_INDEPENDENT_CODE ON) - - add_library(deps::libopenjpeg-lcms2 INTERFACE IMPORTED GLOBAL) - target_link_libraries(deps::libopenjpeg-lcms2 INTERFACE lcms2) - target_include_directories(deps::libopenjpeg-lcms2 - INTERFACE - # lcms2.h is not included in 'lcms2' so manually include - ${deps-libopenjpeg_SOURCE_DIR}/thirdparty/liblcms2/include - ) - - set(deps-libopenjpeg-lcms2_SOURCE_DIR ${deps-libopenjpeg_SOURCE_DIR}/thirdparty/liblcms2 CACHE INTERNAL "" FORCE) - mark_as_advanced(deps-libopenjpeg-lcms2_SOURCE_DIR) - set(deps-libopenjpeg-lcms2_BINARY_DIR ${deps-libopenjpeg_BINARY_DIR}/thirdparty/liblcms2 CACHE INTERNAL "" FORCE) - mark_as_advanced(deps-libopenjpeg-lcms2_BINARY_DIR) + message(STATUS "Fetching libopenjpeg sources") + FetchContent_MakeAvailable(deps-libopenjpeg) + message(STATUS "Fetching libopenjpeg sources - done") ########################################################################### - add_subdirectory(${deps-libopenjpeg_SOURCE_DIR} ${deps-libopenjpeg_BINARY_DIR} EXCLUDE_FROM_ALL) - # Disable visibility to not expose unnecessary symbols set_target_properties(openjp2_static PROPERTIES @@ -108,4 +68,40 @@ if (NOT TARGET deps::libopenjpeg) mark_as_advanced(deps-libopenjpeg_SOURCE_DIR) set(deps-libopenjpeg_BINARY_DIR ${deps-libopenjpeg_BINARY_DIR} CACHE INTERNAL "" FORCE) mark_as_advanced(deps-libopenjpeg_BINARY_DIR) + + ########################################################################### + # Build liblcms2 with the source in libopenjpeg + ########################################################################### + + add_subdirectory(${deps-libopenjpeg_SOURCE_DIR}/thirdparty/liblcms2 ${deps-libopenjpeg_BINARY_DIR}/thirdparty/liblcms2) + + # Set PIC to prevent the following error message + # : /usr/bin/ld: _deps/deps-libopenjpeg-build/thirdparty/lib/liblcms2.a(cmserr.c.o): relocation R_X86_64_PC32 against symbol `_cmsMemPluginChunk' can not be used when making a shared object; recompile with -fPIC + # /usr/bin/ld: final link failed: bad value + set_target_properties(lcms2 PROPERTIES POSITION_INDEPENDENT_CODE ON) + + # Override the output library folder path + set_target_properties(lcms2 + PROPERTIES + OUTPUT_NAME "lcms2" + ARCHIVE_OUTPUT_DIRECTORY ${deps-libopenjpeg_BINARY_DIR}/thirdparty/lib) + + # Override definition of OPJ_HAVE_LIBLCMS2 to build color_apply_icc_profile() method + target_compile_definitions(lcms2 + PUBLIC + OPJ_HAVE_LIBLCMS2=1 + ) + + add_library(deps::libopenjpeg-lcms2 INTERFACE IMPORTED GLOBAL) + target_link_libraries(deps::libopenjpeg-lcms2 INTERFACE lcms2) + target_include_directories(deps::libopenjpeg-lcms2 + INTERFACE + # lcms2.h is not included in 'lcms2' so manually include + ${deps-libopenjpeg_SOURCE_DIR}/thirdparty/liblcms2/include + ) + + set(deps-libopenjpeg-lcms2_SOURCE_DIR ${deps-libopenjpeg_SOURCE_DIR}/thirdparty/liblcms2 CACHE INTERNAL "" FORCE) + mark_as_advanced(deps-libopenjpeg-lcms2_SOURCE_DIR) + set(deps-libopenjpeg-lcms2_BINARY_DIR ${deps-libopenjpeg_BINARY_DIR}/thirdparty/liblcms2 CACHE INTERNAL "" FORCE) + mark_as_advanced(deps-libopenjpeg-lcms2_BINARY_DIR) endif () diff --git a/cpp/plugins/cucim.kit.cuslide/cmake/deps/libtiff.cmake b/cpp/plugins/cucim.kit.cuslide/cmake/deps/libtiff.cmake index fd20e7f0e..dedee740a 100644 --- a/cpp/plugins/cucim.kit.cuslide/cmake/deps/libtiff.cmake +++ b/cpp/plugins/cucim.kit.cuslide/cmake/deps/libtiff.cmake @@ -1,5 +1,5 @@ # Apache License, Version 2.0 -# Copyright 2020 NVIDIA Corporation +# Copyright 2020-2025 NVIDIA Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -26,13 +26,10 @@ if (NOT TARGET deps::libtiff) GIT_REPOSITORY https://gitlab.com/libtiff/libtiff.git GIT_TAG v4.1.0 GIT_SHALLOW TRUE + EXCLUDE_FROM_ALL ) - FetchContent_GetProperties(deps-libtiff) - if (NOT deps-libtiff_POPULATED) - message(STATUS "Fetching libtiff sources") - FetchContent_Populate(deps-libtiff) - message(STATUS "Fetching libtiff sources - done") - endif () + + message(STATUS "Fetching libtiff sources") # Set policies for libtiff set(CMAKE_PROJECT_INCLUDE_BEFORE "${CMAKE_CURRENT_LIST_DIR}/libtiff-policies-fix.cmake") @@ -64,7 +61,8 @@ if (NOT TARGET deps::libtiff) set(jbig OFF) set(webp OFF) - add_subdirectory(${deps-libtiff_SOURCE_DIR} ${deps-libtiff_BINARY_DIR} EXCLUDE_FROM_ALL) + FetchContent_MakeAvailable(deps-libtiff) + message(STATUS "Fetching libtiff sources - done") # Disable visibility to not expose unnecessary symbols set_target_properties(tiff tiffxx diff --git a/cpp/plugins/cucim.kit.cuslide/cmake/deps/nvjpeg.cmake b/cpp/plugins/cucim.kit.cuslide/cmake/deps/nvjpeg.cmake index 8bcf8c911..26ac14cb7 100644 --- a/cpp/plugins/cucim.kit.cuslide/cmake/deps/nvjpeg.cmake +++ b/cpp/plugins/cucim.kit.cuslide/cmake/deps/nvjpeg.cmake @@ -1,5 +1,5 @@ # -# Copyright (c) 2021, NVIDIA CORPORATION. +# Copyright (c) 2021-2025, NVIDIA CORPORATION. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/cpp/plugins/cucim.kit.cuslide/cmake/deps/openslide.cmake b/cpp/plugins/cucim.kit.cuslide/cmake/deps/openslide.cmake index 8e44e33a5..2ec1e3fd0 100644 --- a/cpp/plugins/cucim.kit.cuslide/cmake/deps/openslide.cmake +++ b/cpp/plugins/cucim.kit.cuslide/cmake/deps/openslide.cmake @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2025, NVIDIA CORPORATION. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/cpp/plugins/cucim.kit.cuslide/cmake/deps/pugixml.cmake b/cpp/plugins/cucim.kit.cuslide/cmake/deps/pugixml.cmake index 827a50ec6..7db330324 100644 --- a/cpp/plugins/cucim.kit.cuslide/cmake/deps/pugixml.cmake +++ b/cpp/plugins/cucim.kit.cuslide/cmake/deps/pugixml.cmake @@ -1,5 +1,5 @@ # Apache License, Version 2.0 -# Copyright 2020 NVIDIA Corporation +# Copyright 2020-2025 NVIDIA Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -19,19 +19,15 @@ if (NOT TARGET deps::pugixml) GIT_REPOSITORY https://github.com/zeux/pugixml.git GIT_TAG v1.11.1 GIT_SHALLOW TRUE + EXCLUDE_FROM_ALL ) - FetchContent_GetProperties(deps-pugixml) - if (NOT deps-pugixml_POPULATED) - message(STATUS "Fetching pugixml sources") - FetchContent_Populate(deps-pugixml) - message(STATUS "Fetching pugixml sources - done") - endif () + message(STATUS "Fetching pugixml sources") # Create static library cucim_set_build_shared_libs(OFF) + FetchContent_MakeAvailable(deps-pugixml) - add_subdirectory(${deps-pugixml_SOURCE_DIR} ${deps-pugixml_BINARY_DIR} EXCLUDE_FROM_ALL) - + message(STATUS "Fetching pugixml sources - done") # Disable visibility to not expose unnecessary symbols set_target_properties(pugixml-static PROPERTIES diff --git a/dependencies.yaml b/dependencies.yaml index 62f6bde51..0f513a368 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -96,7 +96,7 @@ dependencies: # python/cucim/src/cucim/clara/ before calling `pip install .`. - output_types: [conda, requirements] packages: - - cmake>=3.26.4,!=3.30.0 + - cmake>=3.30.4 - ninja - output_types: conda packages: diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 70334a980..5b6bdd009 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -13,7 +13,7 @@ # limitations under the License. # -cmake_minimum_required(VERSION 3.26.4) +cmake_minimum_required(VERSION 3.30.4 FATAL_ERROR) ################################################################################ # Prerequisite statements diff --git a/python/cmake/deps/fmt.cmake b/python/cmake/deps/fmt.cmake index ef2797e18..2e08bc3bb 100644 --- a/python/cmake/deps/fmt.cmake +++ b/python/cmake/deps/fmt.cmake @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2025, NVIDIA CORPORATION. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -19,17 +19,16 @@ if (NOT TARGET deps::fmt) GIT_REPOSITORY https://github.com/fmtlib/fmt.git GIT_TAG 7.0.1 GIT_SHALLOW TRUE + EXCLUDE_FROM_ALL ) - FetchContent_GetProperties(deps-fmt) - if (NOT deps-fmt_POPULATED) - message(STATUS "Fetching fmt sources") - FetchContent_Populate(deps-fmt) - message(STATUS "Fetching fmt sources - done") - endif () + + message(STATUS "Fetching fmt sources") # Create static library cucim_set_build_shared_libs(OFF) - add_subdirectory(${deps-fmt_SOURCE_DIR} ${deps-fmt_BINARY_DIR} EXCLUDE_FROM_ALL) + + FetchContent_MakeAvailable(deps-fmt) + message(STATUS "Fetching fmt sources - done") # Set PIC to prevent the following error message # : /usr/bin/ld: ../lib/libfmtd.a(format.cc.o): relocation R_X86_64_PC32 against symbol `stderr@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC diff --git a/python/cmake/deps/json.cmake b/python/cmake/deps/json.cmake index c3f258ee1..a22f3c638 100644 --- a/python/cmake/deps/json.cmake +++ b/python/cmake/deps/json.cmake @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2025, NVIDIA CORPORATION. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -19,19 +19,17 @@ if (NOT TARGET deps::json) GIT_REPOSITORY https://github.com/nlohmann/json.git GIT_TAG v3.9.1 GIT_SHALLOW TRUE + EXCLUDE_FROM_ALL ) - FetchContent_GetProperties(deps-json) - if (NOT deps-json_POPULATED) - message(STATUS "Fetching json sources") - FetchContent_Populate(deps-json) - message(STATUS "Fetching json sources - done") - endif () + + message(STATUS "Fetching json sources") # Typically you don't care so much for a third party library's tests to be # run from your own project's code. - set(JSON_BuildTests OFF CACHE INTERNAL "") + option(JSON_BuildTests OFF) - add_subdirectory(${deps-json_SOURCE_DIR} ${deps-json_BINARY_DIR} EXCLUDE_FROM_ALL) + FetchContent_MakeAvailable(deps-json) + message(STATUS "Fetching json sources - done") add_library(deps::json INTERFACE IMPORTED GLOBAL) target_link_libraries(deps::json INTERFACE nlohmann_json::nlohmann_json) diff --git a/python/cmake/deps/pybind11.cmake b/python/cmake/deps/pybind11.cmake index ab0eab7f8..19aab2ec4 100644 --- a/python/cmake/deps/pybind11.cmake +++ b/python/cmake/deps/pybind11.cmake @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2025, NVIDIA CORPORATION. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -14,28 +14,21 @@ # if (NOT TARGET deps::pybind11) + find_package(Git REQUIRED) + FetchContent_Declare( deps-pybind11 GIT_REPOSITORY https://github.com/pybind/pybind11.git GIT_TAG v2.11.1 GIT_SHALLOW TRUE - PATCH_COMMAND git apply "${CMAKE_CURRENT_LIST_DIR}/pybind11_pr4857_4877.patch" || true + PATCH_COMMAND ${GIT_EXECUTABLE} apply "${CMAKE_CURRENT_LIST_DIR}/pybind11_pr4857_4877.patch" + EXCLUDE_FROM_ALL ) - FetchContent_GetProperties(deps-pybind11) - if (NOT deps-pybind11_POPULATED) - message(STATUS "Fetching pybind11 sources") - FetchContent_Populate(deps-pybind11) - message(STATUS "Fetching pybind11 sources - done") - endif () + message(STATUS "Fetching pybind11 sources") + FetchContent_MakeAvailable(deps-pybind11) + message(STATUS "Fetching pybind11 sources - done") # https://pybind11.readthedocs.io/en/stable/compiling.html#configuration-variables - # set(PYBIND11_PYTHON_VERSION 3.6) # It doesn't find python in manylinux2014 image - if (NOT PYTHON_EXECUTABLE) - set(PYTHON_EXECUTABLE /usr/bin/python3) - endif () - - add_subdirectory(${deps-pybind11_SOURCE_DIR} ${deps-pybind11_BINARY_DIR} EXCLUDE_FROM_ALL) - add_library(deps::pybind11 INTERFACE IMPORTED GLOBAL) target_link_libraries(deps::pybind11 INTERFACE pybind11::module) set(deps-pybind11_SOURCE_DIR ${deps-pybind11_SOURCE_DIR} CACHE INTERNAL "" FORCE) diff --git a/python/cmake/deps/pybind11_json.cmake b/python/cmake/deps/pybind11_json.cmake index 9313bb0f0..c7f16d5fa 100644 --- a/python/cmake/deps/pybind11_json.cmake +++ b/python/cmake/deps/pybind11_json.cmake @@ -1,5 +1,5 @@ # -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2025, NVIDIA CORPORATION. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -19,15 +19,12 @@ if (NOT TARGET deps::pybind11_json) GIT_REPOSITORY https://github.com/pybind/pybind11_json.git GIT_TAG 0.2.9 GIT_SHALLOW TRUE + EXCLUDE_FROM_ALL ) - FetchContent_GetProperties(deps-pybind11_json) - if (NOT deps-pybind11_json_POPULATED) - message(STATUS "Fetching pybind11_json sources") - FetchContent_Populate(deps-pybind11_json) - message(STATUS "Fetching pybind11_json sources - done") - endif () - add_subdirectory(${deps-pybind11_json_SOURCE_DIR} ${deps-pybind11_json_BINARY_DIR} EXCLUDE_FROM_ALL) + message(STATUS "Fetching pybind11_json sources") + FetchContent_MakeAvailable(deps-pybind11_json) + message(STATUS "Fetching pybind11_json sources - done") add_library(deps::pybind11_json INTERFACE IMPORTED GLOBAL) target_link_libraries(deps::pybind11_json INTERFACE pybind11_json) From e4c919914ee68d9cf232ae07575f062580a204c6 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 25 Feb 2025 15:06:32 -0600 Subject: [PATCH 4/5] Use conda-build instead of conda-mambabuild (#841) This changes from `conda mambabuild` to `conda build`. Conda now uses the mamba solver so no performance regressions are expected. This is a temporary change as we plan to migrate to `rattler-build` in the near future. However, this is needed sooner to drop `boa` and unblock Python 3.13 migrations. xref: https://github.com/rapidsai/build-planning/issues/149 Authors: - Bradley Dice (https://github.com/bdice) Approvers: - James Lamb (https://github.com/jameslamb) URL: https://github.com/rapidsai/cucim/pull/841 --- ci/build_cpp.sh | 2 +- ci/build_python.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/build_cpp.sh b/ci/build_cpp.sh index 7ecb59306..57e4c6c46 100755 --- a/ci/build_cpp.sh +++ b/ci/build_cpp.sh @@ -21,7 +21,7 @@ conda config --set path_conflict warn sccache --zero-stats -RAPIDS_PACKAGE_VERSION=$(rapids-generate-version) rapids-conda-retry mambabuild conda/recipes/libcucim +RAPIDS_PACKAGE_VERSION=$(rapids-generate-version) rapids-conda-retry build conda/recipes/libcucim sccache --show-adv-stats diff --git a/ci/build_python.sh b/ci/build_python.sh index 13f9d8ed0..20929a5e2 100755 --- a/ci/build_python.sh +++ b/ci/build_python.sh @@ -27,7 +27,7 @@ sccache --zero-stats # TODO: Remove `--no-test` flag once importing on a CPU # node works correctly -RAPIDS_PACKAGE_VERSION=$(head -1 ./VERSION) rapids-conda-retry mambabuild \ +RAPIDS_PACKAGE_VERSION=$(head -1 ./VERSION) rapids-conda-retry build \ --no-test \ --channel "${CPP_CHANNEL}" \ conda/recipes/cucim From 0717baf1b05e88bf69038b1d9cc4bd0123f78bbe Mon Sep 17 00:00:00 2001 From: Gregory Lee Date: Wed, 26 Feb 2025 09:56:01 -0500 Subject: [PATCH 5/5] vendor CUDA-accelerated `find objects` (#837) Include a copy of `cupyx.scipy.ndimage.find_objects` that was contributed upstream. A couple of cuCIM functions that used `find_objects` are also updated to use this implementation instead of copying to host to call the SciPy version. See: https://github.com/cupy/cupy/pull/8916 The version vendored here is modified to exclude the Cython-based slice list comparison as we don't support using Cython code from cuCIM. This version will still provide good acceleration and we preferentially import the version from CuPy instead if it is available. Authors: - Gregory Lee (https://github.com/grlee77) Approvers: - Gigon Bae (https://github.com/gigony) URL: https://github.com/rapidsai/cucim/pull/837 --- .../_vendored/_ndimage_measurements.py | 216 ++++++++++++++++++ .../src/cucim/skimage/_vendored/ndimage.py | 11 +- .../cucim/src/cucim/skimage/feature/peak.py | 8 +- .../src/cucim/skimage/measure/_regionprops.py | 5 +- 4 files changed, 228 insertions(+), 12 deletions(-) create mode 100644 python/cucim/src/cucim/skimage/_vendored/_ndimage_measurements.py diff --git a/python/cucim/src/cucim/skimage/_vendored/_ndimage_measurements.py b/python/cucim/src/cucim/skimage/_vendored/_ndimage_measurements.py new file mode 100644 index 000000000..304500a57 --- /dev/null +++ b/python/cucim/src/cucim/skimage/_vendored/_ndimage_measurements.py @@ -0,0 +1,216 @@ +import math + +import cupy + + +def _unravel_loop_index_declarations(var_name, ndim, uint_t="unsigned int"): + """Declare variables needed for unraveling the index to nd coordinates""" + if ndim == 1: + code = f""" + {uint_t} in_coord[1];""" + return code + + code = f""" + // variables for unraveling a linear index to a coordinate array + {uint_t} in_coord[{ndim}]; + {uint_t} temp_floor;""" + for d in range(ndim): + code += f""" + {uint_t} dim{d}_size = {var_name}.shape()[{d}];""" + return code + + +def _unravel_loop_index( + var_name, + ndim, + uint_t="unsigned int", + raveled_index="i", + omit_declarations=False, +): + """ + declare a multi-index array in_coord and unravel the 1D index, i into it. + This code assumes that the array is a C-ordered array. + """ + code = ( + "" + if omit_declarations + else _unravel_loop_index_declarations(var_name, ndim, uint_t) + ) + if ndim == 1: + code = f""" + in_coord[0] = {raveled_index};\n""" + return code + + code += f"{uint_t} temp_idx = {raveled_index};" + for d in range(ndim - 1, 0, -1): + code += f""" + temp_floor = temp_idx / dim{d}_size; + in_coord[{d}] = temp_idx - temp_floor * dim{d}_size; + temp_idx = temp_floor;""" + code += """ + in_coord[0] = temp_idx;""" + return code + + +@cupy.memoize(for_each_device=True) +def get_bbox_coords_kernel(coord_dtype, ndim, pixels_per_thread=32): + coord_dtype = cupy.dtype(coord_dtype) + + # maximum number of unique labels this thread might encounter + # (could use a smaller value for most datasets, but for safety assume + # every pixel in the window could have a separate label.) + max_unique = pixels_per_thread + + uint_t = ( + "unsigned int" if coord_dtype.itemsize <= 4 else "unsigned long long" + ) + + # declare storage for local min/max of each label within the pixel window + source = f""" + {uint_t} start_index = {pixels_per_thread}*i; + // bounding box variables + {uint_t} bbox_min[{ndim * max_unique}]; + {uint_t} bbox_max[{ndim * max_unique}] = {{0}}; + // initialize minimum coordinate to array size + for (unsigned int ii = 0; ii < {ndim * max_unique}; ii++) {{ + bbox_min[ii] = image_size; + }}\n""" + source += _unravel_loop_index_declarations("image", ndim, uint_t=uint_t) + + # declare inner loop operation + inner_op = _unravel_loop_index( + "image", + ndim=ndim, + uint_t=uint_t, + raveled_index="ii", + omit_declarations=True, + ) + for d in range(ndim): + inner_op += f""" + bbox_min[{ndim}*offset + {d}] = min( + in_coord[{d}], bbox_min[{ndim}*offset + {d}]); + bbox_max[{ndim}*offset + {d}] = max( + in_coord[{d}] + 1, bbox_max[{ndim}*offset + {d}]);""" + + # Find min and max coordinates among the next pixels_per_thread pixels + source += f""" + X encountered_labels[{max_unique}] = {{0}}; + X current_label; + X prev_label = image[start_index]; + int offset = 0; + encountered_labels[0] = prev_label; + {uint_t} ii_max = min(start_index + {pixels_per_thread}, image_size); + for ({uint_t} ii = start_index; ii < ii_max; ii++) {{ + current_label = image[ii]; + if (current_label <= 0) {{ continue; }} + if (current_label != prev_label) {{ + offset += 1; + prev_label = current_label; + encountered_labels[offset] = current_label; + }} + // inner loop operation for boundary box min/max + {inner_op} + }}\n""" + + # Update the global min/max values with the min/max from the pixel group + source += """ + for (unsigned int ii = 0; ii <= offset; ii++) { + X lab = encountered_labels[ii]; + if (lab > 0) {""" + for d in range(ndim): + source += f""" + atomicMin(&bbox[(lab - 1)*{2*ndim} + {2*d}], + bbox_min[{ndim}*ii + {d}]); + atomicMax(&bbox[(lab - 1)*{2*ndim} + {2*d + 1}], + bbox_max[{ndim}*ii + {d}]);""" + source += """ + } + }\n""" + + inputs = f"raw X image, raw {coord_dtype.name} image_size" + outputs = f"raw {coord_dtype.name} bbox" + name = f"cucim_bbox_{ndim}d_{coord_dtype.char}" + name += f"_batch{pixels_per_thread}" + return cupy.ElementwiseKernel(inputs, outputs, source, name=name) + + +def find_objects(input, max_label=0): + """ + Find objects in a labeled array. + + Parameters + ---------- + input : ndarray of ints + Array containing objects defined by different labels. Labels with + value 0 are ignored. + max_label : int, optional + Maximum label to be searched for in `input`. If max_label is not + given, the positions of all objects are returned. + + Returns + ------- + object_slices : list of tuples + A list of tuples, with each tuple containing N slices (with N the + dimension of the input array). Slices correspond to the minimal + parallelepiped that contains the object. If a number is missing, + None is returned instead of a slice. The label ``l`` corresponds to + the index ``l-1`` in the returned list. + + See Also + -------- + label, center_of_mass + + .. warning:: + + This function will synchronize the device. + """ + + image = input + if image.dtype.kind not in "bui": + raise TypeError( + f"Input dtype {image.dtype.name} cannot be interpreted as an " + "integer" + ) + if max_label < 1: + max_label = int(image.max()) # synchronize + + # choose 32 or 64-bit coordinate type for atomicMin and atomicMax + coord_dtype = cupy.uint32 if image.size < 2**32 else cupy.uint64 + + # Could potentially expose pixels per thread as a tuning parameter instead + # of using a fixed value here. + pixels_per_thread = 32 + bbox_coords_kernel = get_bbox_coords_kernel( + coord_dtype, image.ndim, pixels_per_thread + ) + + ndim = image.ndim + # 0 is the correct initial value for coordinate maxima + bbox_coords = cupy.zeros((max_label, 2 * ndim), dtype=coord_dtype) + + # Initialize value for coordinate minima. Note that the order of + # coordinates on axis 1 is min_0, max_0, min_1, max_1 ... min_n, max_n. + int_max = cupy.iinfo(coord_dtype).max + bbox_coords[:, ::2] = int_max + + # make a copy if the inputs are not already C-contiguous + if not image.flags.c_contiguous: + image = cupy.ascontiguousarray(image) + + size = math.ceil(image.size / pixels_per_thread) + bbox_coords_kernel(image, image.size, bbox_coords, size=size) + + # Copy bounding box coordinates to the CPU to create Python slice objects + bbox_coords_cpu = cupy.asnumpy(bbox_coords[:max_label, :]) # synchronize + + # Since cuCIM does not use Cython, we use a pure Python conversion to slice + # objects instead. + bbox_slices = [ + None + if box[0] == int_max + else tuple( + slice(int(box[2 * d]), int(box[2 * d + 1])) for d in range(ndim) + ) + for box in bbox_coords_cpu + ] + return bbox_slices diff --git a/python/cucim/src/cucim/skimage/_vendored/ndimage.py b/python/cucim/src/cucim/skimage/_vendored/ndimage.py index 60c42b58c..ae6e9c2fa 100644 --- a/python/cucim/src/cucim/skimage/_vendored/ndimage.py +++ b/python/cucim/src/cucim/skimage/_vendored/ndimage.py @@ -1,7 +1,5 @@ # locally defined filters that are more efficient than in CuPy -# measurements -# fourier filters -# additional filters + from cupyx.scipy.ndimage import distance_transform_edt # NOQA from cupyx.scipy.ndimage import fourier_ellipsoid # NOQA from cupyx.scipy.ndimage import fourier_gaussian # NOQA @@ -95,3 +93,10 @@ from cupyx.scipy.ndimage import minimum_position # NOQA from cupyx.scipy.ndimage import standard_deviation # NOQA from cupyx.scipy.ndimage import variance # NOQA + +try: + # only available in CuPy >=13.4 + from cupyx.scipy.ndimage import find_objects +except ImportError: + # vendored implementation (without internal Cython helper function) + from cucim.skimage._vendored._ndimage_measurements import find_objects diff --git a/python/cucim/src/cucim/skimage/feature/peak.py b/python/cucim/src/cucim/skimage/feature/peak.py index 16c9ea0aa..38bd8b638 100644 --- a/python/cucim/src/cucim/skimage/feature/peak.py +++ b/python/cucim/src/cucim/skimage/feature/peak.py @@ -2,12 +2,12 @@ import cupy as cp import numpy as np -from scipy.ndimage import find_objects as cpu_find_objects import cucim.skimage._vendored.ndimage as ndi # from ..filters import rank_order from cucim.skimage import measure +from cucim.skimage._vendored.ndimage import find_objects from .._shared.coord import ensure_spacing @@ -287,11 +287,7 @@ def peak_local_max( # For each label, extract a smaller image enclosing the object of # interest, identify num_peaks_per_label peaks and mark them in # variable out. - try: - objects = ndi.find_objects(_labels) - except AttributeError: - # CuPy Backend: fallback to CPU implementation until implemented - objects = cpu_find_objects(cp.asnumpy(_labels)) + objects = find_objects(_labels) for label_idx, roi in enumerate(objects): if roi is None: diff --git a/python/cucim/src/cucim/skimage/measure/_regionprops.py b/python/cucim/src/cucim/skimage/measure/_regionprops.py index 8274b2c33..d6550f05a 100644 --- a/python/cucim/src/cucim/skimage/measure/_regionprops.py +++ b/python/cucim/src/cucim/skimage/measure/_regionprops.py @@ -8,9 +8,9 @@ import cupy as cp import numpy as np from cupyx.scipy import ndimage as ndi -from scipy.ndimage import find_objects as cpu_find_objects from cucim.skimage._vendored import pad +from cucim.skimage._vendored.ndimage import find_objects from . import _moments from ._regionprops_utils import euler_number, perimeter, perimeter_crofton @@ -1434,8 +1434,7 @@ def regionprops( regions = [] - # CuPy Backend: ndimage.find_objects not implemented - objects = cpu_find_objects(cp.asnumpy(label_image)) # synchronize! + objects = find_objects(label_image) # synchronize! for i, sl in enumerate(objects): if sl is None: continue