Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

De-vendor CMake dependencies and use shared libraries #753

Draft
wants to merge 25 commits into
base: branch-25.04
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
dcb3050
Support both conda and source installation for boost
gigony Jul 27, 2024
3a8c64e
Remove boost dependency
gigony Jul 29, 2024
dfba773
Support both conda and source installation for fmt
gigony Jul 29, 2024
23a535b
Support both conda and source installation for nlohmann_json
gigony Jul 29, 2024
7aee973
Support both conda and source installation for libabseil
gigony Jul 29, 2024
e3d1925
Support both conda and source installation for nvtx3
gigony Jul 29, 2024
01c12b4
Support both conda and source installation for taskflow
gigony Jul 29, 2024
b7572bf
Support both conda and source installation for pybind11
gigony Jul 30, 2024
988cf45
Support both conda and source installation for pybind11_json
gigony Jul 30, 2024
dda171a
Update libcuckoo to 0.3.1
gigony Jul 30, 2024
7e85e5f
Update catch2 to 3.6.0
gigony Jul 31, 2024
7b853e4
Remove workarounds for nvcc errors with -std=c++17
gigony Jul 31, 2024
df4389a
Do not call catch_discover_tests() in CMakeLists.txt
gigony Jul 31, 2024
850fb2a
Add a comment on pybind11 in run script
gigony Jul 31, 2024
1286fbe
Support both conda and source installation for cli11
gigony Jul 31, 2024
568eb40
Update CONTRIBUTING guide
gigony Jul 31, 2024
dd644c8
Update dependencies
gigony Jul 31, 2024
a2b2a17
Remove rmm.cmake
gigony Jul 31, 2024
55f077f
Update cucim dependencies (python)
gigony Aug 1, 2024
6785f4c
Fix abseil.cmake for building from source code
gigony Aug 1, 2024
e0dad71
Fix boost-header-only.cmake to work with Boost v1.85.0
gigony Aug 1, 2024
4ddd932
Add libabseil dependency to run
gigony Aug 1, 2024
03127d2
Build with CXX11 ABI only
gigony Aug 1, 2024
f5be43c
Reduce the shared memory size in the test case to avoid the error
gigony Aug 1, 2024
20ff997
Test shared memory cache with reduced size
gigony Oct 1, 2024
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
Next Next commit
Support both conda and source installation for boost
Signed-off-by: Gigon Bae <[email protected]>
gigony committed Oct 1, 2024
commit dcb3050ae3368f75ba2e7e6bf28d21cc7e4786d4
144 changes: 102 additions & 42 deletions cpp/cmake/deps/boost-header-only.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2021, NVIDIA CORPORATION.
# Copyright (c) 2021-2024, 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,57 +14,117 @@
#

if (NOT TARGET deps::boost-header-only)
set(Boost_VERSION 1.75.0)
set(Boost_VERSION 1.85.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")
if (DEFINED ENV{CONDA_PREFIX})
# Use boost headers from conda environment
find_path(boost_INCLUDE_DIR
NAMES boost/version.hpp
HINTS $ENV{CONDA_PREFIX}/include
)

if (NOT boost_INCLUDE_DIR)
message(FATAL_ERROR "boost headers not found in conda environment")
endif()

# Apply patch for boost-header-only
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")
# Check if the patch is already applied
file(READ "${boost_INCLUDE_DIR}/boost/interprocess/mem_algo/rbtree_best_fit.hpp" file_content)
if("${file_content}" MATCHES "cuCIM patch")
message(STATUS "Patch for boost-header-only is already applied")
else()
message(STATUS "Applying patch for boost-header-only - failed")
message(FATAL_ERROR "${exec_output}\n${exec_error}")
execute_process(
COMMAND bash -c "${GIT_EXECUTABLE} apply --whitespace=nowarn ${CMAKE_CURRENT_LIST_DIR}/boost-header-only.patch"
WORKING_DIRECTORY "${boost_INCLUDE_DIR}/.." # Assuming the patch is relative to the include directory
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(STATUS "${exec_output}\n${exec_error}")
endif()
endif()
endif()

add_library(deps::boost-header-only INTERFACE IMPORTED GLOBAL)

unset(boost_include_string)
# Create a list of components
foreach(item IN LISTS boost_component_list)
set(boost_include_string "${boost_include_string}" "${boost_INCLUDE_DIR}")
endforeach(item)

set_target_properties(deps::boost-header-only PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES
"${boost_include_string}"
INTERFACE_COMPILE_DEFINITIONS
BOOST_DATE_TIME_NO_LIB=1
)

set(boost_INCLUDE_DIR ${boost_INCLUDE_DIR} CACHE INTERNAL "" FORCE)
mark_as_advanced(boost_INCLUDE_DIR)
else()
# Fallback to fetching Boost sources
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_MakeAvailable(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 ()
endif ()

add_library(deps::boost-header-only INTERFACE IMPORTED GLOBAL)
add_library(deps::boost-header-only INTERFACE IMPORTED GLOBAL)

unset(boost_include_string)
# Create a list of components
foreach(item IN LISTS boost_component_list)
set(boost_include_string "${boost_include_string}" "${deps-boost-header-only_SOURCE_DIR}/libs/${item}/include")
endforeach(item)
# https://www.boost.org/doc/libs/1_75_0/doc/html/interprocess.html#interprocess.intro.introduction_building_interprocess
set_target_properties(deps::boost-header-only PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES
"${boost_include_string}"
INTERFACE_COMPILE_DEFINITIONS
BOOST_DATE_TIME_NO_LIB=1
)
unset(boost_include_string)
# Create a list of components
foreach(item IN LISTS boost_component_list)
set(boost_include_string "${boost_include_string}" "${deps-boost-header-only_SOURCE_DIR}/libs/${item}/include")
endforeach(item)
# https://www.boost.org/doc/libs/1_75_0/doc/html/interprocess.html#interprocess.intro.introduction_building_interprocess
set_target_properties(deps::boost-header-only PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES
"${boost_include_string}"
INTERFACE_COMPILE_DEFINITIONS
BOOST_DATE_TIME_NO_LIB=1
)

set(deps-boost-header-only_SOURCE_DIR ${deps-boost-header-only_SOURCE_DIR} CACHE INTERNAL "" FORCE)
mark_as_advanced(deps-boost-header-only_SOURCE_DIR)
set(boost_INCLUDE_DIR ${deps-boost-header-only_SOURCE_DIR}/include CACHE INTERNAL "" FORCE)
mark_as_advanced(boost_INCLUDE_DIR)
endif()
endif ()