Skip to content

Commit eb92145

Browse files
cudf_kafka now uses cuDF CMake export targets (CPM) (#7674)
This integrates the changes from #7484 plus others required to get `cudf_kafka` to build cleanly after the CMake refactoring of `cudf` Authors: - Robert Maynard (@robertmaynard) - Jeremy Dyer (@jdye64) Approvers: - Mike Wendt (@mike-wendt) - Keith Kraus (@kkraus14) URL: #7674
1 parent f1f1d0f commit eb92145

File tree

9 files changed

+132
-268
lines changed

9 files changed

+132
-268
lines changed

build.sh

+13-14
Original file line numberDiff line numberDiff line change
@@ -134,18 +134,20 @@ if hasArg clean; then
134134
done
135135
fi
136136

137-
if (( ${BUILD_ALL_GPU_ARCH} == 0 )); then
138-
CUDF_CMAKE_CUDA_ARCHITECTURES="-DCMAKE_CUDA_ARCHITECTURES="
139-
echo "Building for the architecture of the GPU in the system..."
140-
else
141-
CUDF_CMAKE_CUDA_ARCHITECTURES=""
142-
echo "Building for *ALL* supported GPU architectures..."
143-
fi
144137

145138
################################################################################
146139
# Configure, build, and install libcudf
147140

148141
if buildAll || hasArg libcudf; then
142+
143+
if (( ${BUILD_ALL_GPU_ARCH} == 0 )); then
144+
CUDF_CMAKE_CUDA_ARCHITECTURES="-DCMAKE_CUDA_ARCHITECTURES="
145+
echo "Building for the architecture of the GPU in the system..."
146+
else
147+
CUDF_CMAKE_CUDA_ARCHITECTURES=""
148+
echo "Building for *ALL* supported GPU architectures..."
149+
fi
150+
149151
cmake -S $REPODIR/cpp -B ${LIB_BUILD_DIR} \
150152
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
151153
${CUDF_CMAKE_CUDA_ARCHITECTURES} \
@@ -192,19 +194,16 @@ fi
192194
# Build libcudf_kafka library
193195
if hasArg libcudf_kafka; then
194196
cmake -S $REPODIR/cpp/libcudf_kafka -B ${KAFKA_LIB_BUILD_DIR} \
195-
${CUDF_CMAKE_CUDA_ARCHITECTURES} \
196197
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
198+
-DBUILD_TESTS=${BUILD_TESTS} \
197199
-DCMAKE_BUILD_TYPE=${BUILD_TYPE}
198200

201+
199202
cd ${KAFKA_LIB_BUILD_DIR}
203+
cmake --build . -j${PARALLEL_LEVEL} ${VERBOSE_FLAG}
204+
200205
if [[ ${INSTALL_TARGET} != "" ]]; then
201206
cmake --build . -j${PARALLEL_LEVEL} --target install ${VERBOSE_FLAG}
202-
else
203-
cmake --build . -j${PARALLEL_LEVEL} --target libcudf_kafka ${VERBOSE_FLAG}
204-
fi
205-
206-
if [[ ${BUILD_TESTS} == "ON" ]]; then
207-
cmake --build . -j${PARALLEL_LEVEL} --target build_tests_libcudf_kafka ${VERBOSE_FLAG}
208207
fi
209208
fi
210209

ci/release/update-version.sh

+3
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ function sed_runner() {
4949
# cpp update
5050
sed_runner 's/'"CUDA_DATAFRAME VERSION .* LANGUAGES"'/'"CUDA_DATAFRAME VERSION ${NEXT_FULL_TAG} LANGUAGES"'/g' cpp/CMakeLists.txt
5151

52+
# cpp libcudf_kafka update
53+
sed_runner 's/'"CUDA_KAFKA VERSION .* LANGUAGES"'/'"CUDA_KAFKA VERSION ${NEXT_FULL_TAG} LANGUAGES"'/g' cpp/libcudf_kafka/CMakeLists.txt
54+
5255
# doxyfile update
5356
sed_runner 's/PROJECT_NUMBER = .*/PROJECT_NUMBER = '${NEXT_FULL_TAG}'/g' cpp/doxygen/Doxyfile
5457

cpp/cmake/cudf-config.cmake.in

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ targets:
2323
cudf::cudf - The main cudf library.
2424
2525
This module offers an optional testing component which defines the
26-
following IMPORTED GLOBAL targets:
26+
following IMPORTED GLOBAL targets:
2727
2828
cudf::cudftestutil - The main cudf testing library
2929
cudf::gmock
@@ -37,7 +37,7 @@ Result Variables
3737
3838
This module will set the following variables in your project::
3939
40-
CUDF_FOUND
40+
cudf_FOUND
4141
CUDF_VERSION
4242
CUDF_VERSION_MAJOR
4343
CUDF_VERSION_MINOR

cpp/libcudf_kafka/CMakeLists.txt

+21-107
Original file line numberDiff line numberDiff line change
@@ -13,112 +13,51 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#=============================================================================
16-
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
16+
cmake_minimum_required(VERSION 3.18 FATAL_ERROR)
1717

18-
project(CUDA_KAFKA VERSION 0.15.0 LANGUAGES C CXX CUDA)
19-
20-
# TODO: Since we have no actual CUDA code in cudf_kafka this should be removed in the future
21-
# in favor of using FindCUDAToolkit to get the needed CUDA include headers
22-
if(NOT CMAKE_CUDA_COMPILER)
23-
message(SEND_ERROR "CMake cannot locate a CUDA compiler")
24-
endif(NOT CMAKE_CUDA_COMPILER)
25-
26-
###################################################################################################
27-
# - build type ------------------------------------------------------------------------------------
28-
29-
# Set a default build type if none was specified
30-
set(DEFAULT_BUILD_TYPE "Release")
31-
32-
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
33-
message(STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' since none specified.")
34-
set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE
35-
STRING "Choose the type of build." FORCE)
36-
# Set the possible values of build type for cmake-gui
37-
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
38-
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
39-
endif(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
18+
project(CUDA_KAFKA VERSION 0.19.0 LANGUAGES CXX)
4019

4120
###################################################################################################
42-
# - compiler options ------------------------------------------------------------------------------
43-
44-
set(CMAKE_CXX_STANDARD 14)
45-
set(CMAKE_CXX_STANDARD_REQUIRED ON)
21+
# - Build options
22+
option(BUILD_TESTS "Build tests for libcudf_kafka" ON)
4623

47-
# To apply RUNPATH to transitive dependencies (this is a temporary solution)
48-
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--disable-new-dtags")
49-
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--disable-new-dtags")
50-
51-
# Build options
52-
option(BUILD_TESTS "Configure CMake to build tests" ON)
24+
message(VERBOSE "CUDF_KAFKA: Build gtests: ${BUILD_TESTS}")
5325

5426
###################################################################################################
55-
# - cmake modules ---------------------------------------------------------------------------------
56-
57-
message(VERBOSE "CMAKE_CURRENT_SOURCE_DIR: ${CMAKE_CURRENT_SOURCE_DIR}")
58-
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/" ${CMAKE_MODULE_PATH})
27+
# - Dependencies
5928

60-
include(FeatureSummary)
61-
include(CheckIncludeFiles)
62-
include(CheckLibraryExists)
29+
# CPM
30+
include(../cmake/thirdparty/CUDF_GetCPM.cmake)
6331

64-
###################################################################################################
65-
# - conda environment -----------------------------------------------------------------------------
32+
# libcudf
33+
include(cmake/thirdparty/CUDF_KAFKA_GetCUDF.cmake)
6634

67-
if("$ENV{CONDA_BUILD}" STREQUAL "1")
68-
set(CMAKE_SYSTEM_PREFIX_PATH "$ENV{BUILD_PREFIX};$ENV{PREFIX};${CMAKE_SYSTEM_PREFIX_PATH}")
69-
set(CONDA_INCLUDE_DIRS "$ENV{BUILD_PREFIX}/include" "$ENV{PREFIX}/include")
70-
set(CONDA_LINK_DIRS "$ENV{BUILD_PREFIX}/lib" "$ENV{PREFIX}/lib")
71-
message(VERBOSE "Conda build detected, CMAKE_SYSTEM_PREFIX_PATH set to: ${CMAKE_SYSTEM_PREFIX_PATH}")
72-
endif()
35+
# librdkafka
36+
include(cmake/thirdparty/CUDF_KAFKA_GetRDKafka.cmake)
7337

74-
###################################################################################################
75-
# - add gtest -------------------------------------------------------------------------------------
38+
# # GTests if enabled
39+
if (BUILD_TESTS)
40+
# GoogleTest
41+
include(../cmake/thirdparty/CUDF_GetGTest.cmake)
7642

77-
# TODO: This is currently using a nearly duplicate Google Test Module due to CMake source limitations.
78-
# this should be standardized in the future to use the same Google Test Module as cudf
79-
if(BUILD_TESTS)
43+
# include CTest module -- automatically calls enable_testing()
8044
include(CTest)
81-
include(ConfigureGoogleTest)
82-
83-
if(GTEST_FOUND)
84-
message(VERBOSE "Google C++ Testing Framework (Google Test) found in ${GTEST_ROOT}")
85-
include_directories(${GTEST_INCLUDE_DIR})
86-
add_subdirectory(${CMAKE_SOURCE_DIR}/tests)
87-
else()
88-
message(AUTHOR_WARNING "Google C++ Testing Framework (Google Test) not found: automated tests are disabled.")
89-
endif(GTEST_FOUND)
90-
endif(BUILD_TESTS)
91-
92-
message(VERBOSE "CUDF_KAFKA_TEST_LIST set to: ${CUDF_KAFKA_TEST_LIST}")
45+
add_subdirectory(tests)
46+
endif()
9347

9448
###################################################################################################
9549
# - include paths ---------------------------------------------------------------------------------
9650

97-
if(CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES)
98-
include_directories("${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}")
99-
endif(CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES)
100-
10151
include_directories("${CMAKE_BINARY_DIR}/include"
102-
"${CMAKE_BINARY_DIR}/include/jit"
10352
"${CMAKE_SOURCE_DIR}/include"
10453
"${CMAKE_SOURCE_DIR}/src")
10554

106-
if(CONDA_INCLUDE_DIRS)
107-
include_directories("${CONDA_INCLUDE_DIRS}")
108-
endif(CONDA_INCLUDE_DIRS)
109-
11055
###################################################################################################
11156
# - library paths ---------------------------------------------------------------------------------
11257

11358
link_directories("${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}" # CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES is an undocumented/unsupported variable containing the link directories for nvcc
11459
"${CMAKE_BINARY_DIR}/lib"
115-
"${CMAKE_BINARY_DIR}"
116-
"${GTEST_LIBRARY_DIR}"
117-
"${RMM_LIBRARY}")
118-
119-
if(CONDA_LINK_DIRS)
120-
link_directories("${CONDA_LINK_DIRS}")
121-
endif(CONDA_LINK_DIRS)
60+
"${CMAKE_BINARY_DIR}")
12261

12362
###################################################################################################
12463
# - library target --------------------------------------------------------------------------------
@@ -127,37 +66,12 @@ add_library(cudf_kafka SHARED
12766
src/kafka_consumer.cpp
12867
)
12968

130-
set_target_properties(cudf_kafka PROPERTIES BUILD_RPATH "\$ORIGIN")
131-
132-
# Include paths
133-
include_directories("${CMAKE_SOURCE_DIR}/include"
134-
"${CMAKE_CURRENT_SOURCE_DIR}/include/cudf")
135-
136-
###################################################################################################
137-
# cudf_kafka - librdkafka -------------------------------------------------------------------------
138-
139-
find_path(RDKAFKA_INCLUDE "librdkafka" HINTS "$ENV{RDKAFKA_ROOT}/include")
140-
find_library(RDKAFKA++_LIBRARY "rdkafka++" HINTS "$ENV{RDKAFKA_ROOT}/lib" "$ENV{RDKAFKA_ROOT}/build")
141-
142-
message(VERBOSE "RDKAFKA: RDKAFKA++_LIBRARY set to ${RDKAFKA++_LIBRARY}")
143-
message(VERBOSE "RDKAFKA: RDKAFKA_INCLUDE set to ${RDKAFKA_INCLUDE}")
144-
145-
target_link_libraries(cudf_kafka ${RDKAFKA++_LIBRARY})
146-
include_directories("${RDKAFKA_INCLUDE}")
147-
14869
###################################################################################################
14970
# - cudf_kafka Install ----------------------------------------------------------------------------
150-
target_link_libraries(cudf_kafka cudf)
71+
target_link_libraries(cudf_kafka cudf::cudf RDKAFKA::RDKAFKA)
15172

15273
install(TARGETS cudf_kafka
15374
DESTINATION lib)
15475

15576
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include
15677
DESTINATION include)
157-
158-
add_custom_target(build_tests_libcudf_kafka
159-
DEPENDS ${CUDF_KAFKA_TEST_LIST})
160-
161-
add_custom_target(test_libcudf_kafka
162-
COMMAND ctest
163-
DEPENDS build_tests_libcudf_kafka)

cpp/libcudf_kafka/cmake/Modules/ConfigureGoogleTest.cmake

-46
This file was deleted.

cpp/libcudf_kafka/cmake/Templates/GoogleTest.CMakeLists.txt.cmake

-12
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#=============================================================================
2+
# Copyright (c) 2021, NVIDIA CORPORATION.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#=============================================================================
16+
17+
function(cudfkafka_save_if_enabled var)
18+
if(CUDF_KAFKA_${var})
19+
unset(${var} PARENT_SCOPE)
20+
unset(${var} CACHE)
21+
endif()
22+
endfunction()
23+
24+
function(cudfkafka_restore_if_enabled var)
25+
if(CUDF_KAFKA_${var})
26+
set(${var} ON CACHE INTERNAL "" FORCE)
27+
endif()
28+
endfunction()
29+
30+
function(find_and_configure_cudf VERSION)
31+
cudfkafka_save_if_enabled(BUILD_TESTS)
32+
cudfkafka_save_if_enabled(BUILD_BENCHMARKS)
33+
CPMFindPackage(NAME cudf
34+
VERSION ${VERSION}
35+
GIT_REPOSITORY https://github.com/rapidsai/cudf.git
36+
GIT_TAG branch-${VERSION}
37+
GIT_SHALLOW TRUE
38+
SOURCE_SUBDIR cpp
39+
OPTIONS "BUILD_TESTS OFF"
40+
"BUILD_BENCHMARKS OFF")
41+
cudfkafka_restore_if_enabled(BUILD_TESTS)
42+
cudfkafka_restore_if_enabled(BUILD_BENCHMARKS)
43+
44+
if(NOT cudf_BINARY_DIR IN_LIST CMAKE_PREFIX_PATH)
45+
list(APPEND CMAKE_PREFIX_PATH "${cudf_BINARY_DIR}")
46+
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} PARENT_SCOPE)
47+
endif()
48+
49+
endfunction()
50+
51+
set(CUDF_KAFKA_MIN_VERSION_cudf 0.19)
52+
find_and_configure_cudf(${CUDF_KAFKA_MIN_VERSION_cudf})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#=============================================================================
2+
# Copyright (c) 2021, NVIDIA CORPORATION.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#=============================================================================
16+
17+
find_path(RDKAFKA_INCLUDE "librdkafka" HINTS "$ENV{RDKAFKA_ROOT}/include")
18+
find_library(RDKAFKA++_LIBRARY "rdkafka++" HINTS "$ENV{RDKAFKA_ROOT}/lib" "$ENV{RDKAFKA_ROOT}/build")
19+
20+
if(RDKAFKA_INCLUDE AND RDKAFKA++_LIBRARY)
21+
add_library(rdkafka INTERFACE)
22+
target_link_libraries(rdkafka INTERFACE "${RDKAFKA++_LIBRARY}")
23+
target_include_directories(rdkafka INTERFACE "${RDKAFKA_INCLUDE}")
24+
add_library(RDKAFKA::RDKAFKA ALIAS rdkafka)
25+
endif()

0 commit comments

Comments
 (0)