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

cudf_kafka now uses cuDF CMake export targets (CPM) #7674

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 13 additions & 14 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -134,18 +134,20 @@ if hasArg clean; then
done
fi

if (( ${BUILD_ALL_GPU_ARCH} == 0 )); then
CUDF_CMAKE_CUDA_ARCHITECTURES="-DCMAKE_CUDA_ARCHITECTURES="
echo "Building for the architecture of the GPU in the system..."
else
CUDF_CMAKE_CUDA_ARCHITECTURES=""
echo "Building for *ALL* supported GPU architectures..."
fi

################################################################################
# Configure, build, and install libcudf

if buildAll || hasArg libcudf; then

if (( ${BUILD_ALL_GPU_ARCH} == 0 )); then
CUDF_CMAKE_CUDA_ARCHITECTURES="-DCMAKE_CUDA_ARCHITECTURES="
echo "Building for the architecture of the GPU in the system..."
else
CUDF_CMAKE_CUDA_ARCHITECTURES=""
echo "Building for *ALL* supported GPU architectures..."
fi

cmake -S $REPODIR/cpp -B ${LIB_BUILD_DIR} \
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
${CUDF_CMAKE_CUDA_ARCHITECTURES} \
Expand Down Expand Up @@ -192,19 +194,16 @@ fi
# Build libcudf_kafka library
if hasArg libcudf_kafka; then
cmake -S $REPODIR/cpp/libcudf_kafka -B ${KAFKA_LIB_BUILD_DIR} \
${CUDF_CMAKE_CUDA_ARCHITECTURES} \
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
-DBUILD_TESTS=${BUILD_TESTS} \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE}


cd ${KAFKA_LIB_BUILD_DIR}
cmake --build . -j${PARALLEL_LEVEL} ${VERBOSE_FLAG}

if [[ ${INSTALL_TARGET} != "" ]]; then
cmake --build . -j${PARALLEL_LEVEL} --target install ${VERBOSE_FLAG}
else
cmake --build . -j${PARALLEL_LEVEL} --target libcudf_kafka ${VERBOSE_FLAG}
fi

if [[ ${BUILD_TESTS} == "ON" ]]; then
cmake --build . -j${PARALLEL_LEVEL} --target build_tests_libcudf_kafka ${VERBOSE_FLAG}
fi
fi

Expand Down
3 changes: 3 additions & 0 deletions ci/release/update-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ function sed_runner() {
# cpp update
sed_runner 's/'"CUDA_DATAFRAME VERSION .* LANGUAGES"'/'"CUDA_DATAFRAME VERSION ${NEXT_FULL_TAG} LANGUAGES"'/g' cpp/CMakeLists.txt

# cpp libcudf_kafka update
sed_runner 's/'"CUDA_KAFKA VERSION .* LANGUAGES"'/'"CUDA_KAFKA VERSION ${NEXT_FULL_TAG} LANGUAGES"'/g' cpp/libcudf_kafka/CMakeLists.txt

# doxyfile update
sed_runner 's/PROJECT_NUMBER = .*/PROJECT_NUMBER = '${NEXT_FULL_TAG}'/g' cpp/doxygen/Doxyfile

Expand Down
4 changes: 2 additions & 2 deletions cpp/cmake/cudf-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ targets:
cudf::cudf - The main cudf library.

This module offers an optional testing component which defines the
following IMPORTED GLOBAL targets:
following IMPORTED GLOBAL targets:

cudf::cudftestutil - The main cudf testing library
cudf::gmock
Expand All @@ -37,7 +37,7 @@ Result Variables

This module will set the following variables in your project::

CUDF_FOUND
cudf_FOUND
CUDF_VERSION
CUDF_VERSION_MAJOR
CUDF_VERSION_MINOR
Expand Down
128 changes: 21 additions & 107 deletions cpp/libcudf_kafka/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,112 +13,51 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#=============================================================================
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_minimum_required(VERSION 3.18 FATAL_ERROR)

project(CUDA_KAFKA VERSION 0.15.0 LANGUAGES C CXX CUDA)

# TODO: Since we have no actual CUDA code in cudf_kafka this should be removed in the future
# in favor of using FindCUDAToolkit to get the needed CUDA include headers
if(NOT CMAKE_CUDA_COMPILER)
message(SEND_ERROR "CMake cannot locate a CUDA compiler")
endif(NOT CMAKE_CUDA_COMPILER)

###################################################################################################
# - build type ------------------------------------------------------------------------------------

# Set a default build type if none was specified
set(DEFAULT_BUILD_TYPE "Release")

if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' since none specified.")
set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE
STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
project(CUDA_KAFKA VERSION 0.19.0 LANGUAGES CXX)

###################################################################################################
# - compiler options ------------------------------------------------------------------------------

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# - Build options
option(BUILD_TESTS "Build tests for libcudf_kafka" ON)

# To apply RUNPATH to transitive dependencies (this is a temporary solution)
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--disable-new-dtags")
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--disable-new-dtags")

# Build options
option(BUILD_TESTS "Configure CMake to build tests" ON)
message(VERBOSE "CUDF_KAFKA: Build gtests: ${BUILD_TESTS}")

###################################################################################################
# - cmake modules ---------------------------------------------------------------------------------

message(VERBOSE "CMAKE_CURRENT_SOURCE_DIR: ${CMAKE_CURRENT_SOURCE_DIR}")
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/" ${CMAKE_MODULE_PATH})
# - Dependencies

include(FeatureSummary)
include(CheckIncludeFiles)
include(CheckLibraryExists)
# CPM
include(../cmake/thirdparty/CUDF_GetCPM.cmake)

###################################################################################################
# - conda environment -----------------------------------------------------------------------------
# libcudf
include(cmake/thirdparty/CUDF_KAFKA_GetCUDF.cmake)

if("$ENV{CONDA_BUILD}" STREQUAL "1")
set(CMAKE_SYSTEM_PREFIX_PATH "$ENV{BUILD_PREFIX};$ENV{PREFIX};${CMAKE_SYSTEM_PREFIX_PATH}")
set(CONDA_INCLUDE_DIRS "$ENV{BUILD_PREFIX}/include" "$ENV{PREFIX}/include")
set(CONDA_LINK_DIRS "$ENV{BUILD_PREFIX}/lib" "$ENV{PREFIX}/lib")
message(VERBOSE "Conda build detected, CMAKE_SYSTEM_PREFIX_PATH set to: ${CMAKE_SYSTEM_PREFIX_PATH}")
endif()
# librdkafka
include(cmake/thirdparty/CUDF_KAFKA_GetRDKafka.cmake)

###################################################################################################
# - add gtest -------------------------------------------------------------------------------------
# # GTests if enabled
if (BUILD_TESTS)
# GoogleTest
include(../cmake/thirdparty/CUDF_GetGTest.cmake)

# TODO: This is currently using a nearly duplicate Google Test Module due to CMake source limitations.
# this should be standardized in the future to use the same Google Test Module as cudf
if(BUILD_TESTS)
# include CTest module -- automatically calls enable_testing()
include(CTest)
include(ConfigureGoogleTest)

if(GTEST_FOUND)
message(VERBOSE "Google C++ Testing Framework (Google Test) found in ${GTEST_ROOT}")
include_directories(${GTEST_INCLUDE_DIR})
add_subdirectory(${CMAKE_SOURCE_DIR}/tests)
else()
message(AUTHOR_WARNING "Google C++ Testing Framework (Google Test) not found: automated tests are disabled.")
endif(GTEST_FOUND)
endif(BUILD_TESTS)

message(VERBOSE "CUDF_KAFKA_TEST_LIST set to: ${CUDF_KAFKA_TEST_LIST}")
add_subdirectory(tests)
endif()

###################################################################################################
# - include paths ---------------------------------------------------------------------------------

if(CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES)
include_directories("${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}")
endif(CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES)

include_directories("${CMAKE_BINARY_DIR}/include"
"${CMAKE_BINARY_DIR}/include/jit"
"${CMAKE_SOURCE_DIR}/include"
"${CMAKE_SOURCE_DIR}/src")

if(CONDA_INCLUDE_DIRS)
include_directories("${CONDA_INCLUDE_DIRS}")
endif(CONDA_INCLUDE_DIRS)

###################################################################################################
# - library paths ---------------------------------------------------------------------------------

link_directories("${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}" # CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES is an undocumented/unsupported variable containing the link directories for nvcc
"${CMAKE_BINARY_DIR}/lib"
"${CMAKE_BINARY_DIR}"
"${GTEST_LIBRARY_DIR}"
"${RMM_LIBRARY}")

if(CONDA_LINK_DIRS)
link_directories("${CONDA_LINK_DIRS}")
endif(CONDA_LINK_DIRS)
"${CMAKE_BINARY_DIR}")

###################################################################################################
# - library target --------------------------------------------------------------------------------
Expand All @@ -127,37 +66,12 @@ add_library(cudf_kafka SHARED
src/kafka_consumer.cpp
)

set_target_properties(cudf_kafka PROPERTIES BUILD_RPATH "\$ORIGIN")

# Include paths
include_directories("${CMAKE_SOURCE_DIR}/include"
"${CMAKE_CURRENT_SOURCE_DIR}/include/cudf")

###################################################################################################
# cudf_kafka - librdkafka -------------------------------------------------------------------------

find_path(RDKAFKA_INCLUDE "librdkafka" HINTS "$ENV{RDKAFKA_ROOT}/include")
find_library(RDKAFKA++_LIBRARY "rdkafka++" HINTS "$ENV{RDKAFKA_ROOT}/lib" "$ENV{RDKAFKA_ROOT}/build")

message(VERBOSE "RDKAFKA: RDKAFKA++_LIBRARY set to ${RDKAFKA++_LIBRARY}")
message(VERBOSE "RDKAFKA: RDKAFKA_INCLUDE set to ${RDKAFKA_INCLUDE}")

target_link_libraries(cudf_kafka ${RDKAFKA++_LIBRARY})
include_directories("${RDKAFKA_INCLUDE}")

###################################################################################################
# - cudf_kafka Install ----------------------------------------------------------------------------
target_link_libraries(cudf_kafka cudf)
target_link_libraries(cudf_kafka cudf::cudf RDKAFKA::RDKAFKA)

install(TARGETS cudf_kafka
DESTINATION lib)

install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include
DESTINATION include)

add_custom_target(build_tests_libcudf_kafka
DEPENDS ${CUDF_KAFKA_TEST_LIST})

add_custom_target(test_libcudf_kafka
COMMAND ctest
DEPENDS build_tests_libcudf_kafka)
46 changes: 0 additions & 46 deletions cpp/libcudf_kafka/cmake/Modules/ConfigureGoogleTest.cmake

This file was deleted.

This file was deleted.

52 changes: 52 additions & 0 deletions cpp/libcudf_kafka/cmake/thirdparty/CUDF_KAFKA_GetCUDF.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#=============================================================================
# Copyright (c) 2021, 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
#
# 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.
#=============================================================================

function(cudfkafka_save_if_enabled var)
if(CUDF_KAFKA_${var})
unset(${var} PARENT_SCOPE)
unset(${var} CACHE)
endif()
endfunction()

function(cudfkafka_restore_if_enabled var)
if(CUDF_KAFKA_${var})
set(${var} ON CACHE INTERNAL "" FORCE)
endif()
endfunction()

function(find_and_configure_cudf VERSION)
cudfkafka_save_if_enabled(BUILD_TESTS)
cudfkafka_save_if_enabled(BUILD_BENCHMARKS)
CPMFindPackage(NAME cudf
VERSION ${VERSION}
GIT_REPOSITORY https://github.com/rapidsai/cudf.git
GIT_TAG branch-${VERSION}
GIT_SHALLOW TRUE
SOURCE_SUBDIR cpp
OPTIONS "BUILD_TESTS OFF"
"BUILD_BENCHMARKS OFF")
cudfkafka_restore_if_enabled(BUILD_TESTS)
cudfkafka_restore_if_enabled(BUILD_BENCHMARKS)

if(NOT cudf_BINARY_DIR IN_LIST CMAKE_PREFIX_PATH)
list(APPEND CMAKE_PREFIX_PATH "${cudf_BINARY_DIR}")
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} PARENT_SCOPE)
endif()

endfunction()

set(CUDF_KAFKA_MIN_VERSION_cudf 0.19)
find_and_configure_cudf(${CUDF_KAFKA_MIN_VERSION_cudf})
25 changes: 25 additions & 0 deletions cpp/libcudf_kafka/cmake/thirdparty/CUDF_KAFKA_GetRDKafka.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#=============================================================================
# Copyright (c) 2021, 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
#
# 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.
#=============================================================================

find_path(RDKAFKA_INCLUDE "librdkafka" HINTS "$ENV{RDKAFKA_ROOT}/include")
find_library(RDKAFKA++_LIBRARY "rdkafka++" HINTS "$ENV{RDKAFKA_ROOT}/lib" "$ENV{RDKAFKA_ROOT}/build")

if(RDKAFKA_INCLUDE AND RDKAFKA++_LIBRARY)
add_library(rdkafka INTERFACE)
target_link_libraries(rdkafka INTERFACE "${RDKAFKA++_LIBRARY}")
target_include_directories(rdkafka INTERFACE "${RDKAFKA_INCLUDE}")
add_library(RDKAFKA::RDKAFKA ALIAS rdkafka)
endif()
Loading