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

Create and promote library aliases in libcudf installations #7734

Merged
merged 12 commits into from
Mar 29, 2021
4 changes: 3 additions & 1 deletion conda/recipes/libcudf/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ build:

requirements:
build:
- cmake >=3.17.0
- cmake >=3.18
- gtest
- gmock
trxcllnt marked this conversation as resolved.
Show resolved Hide resolved
host:
- librmm {{ minor_version }}.*
- cudatoolkit {{ cuda_version }}.*
Expand Down
15 changes: 9 additions & 6 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -554,12 +554,6 @@ if(CUDF_BUILD_BENCHMARKS)
GIT_SHALLOW TRUE
OPTIONS "BENCHMARK_ENABLE_TESTING OFF"
"BENCHMARK_ENABLE_INSTALL OFF")
if(benchmark_ADDED)
install(TARGETS benchmark
benchmark_main
DESTINATION lib
EXPORT cudf-targets)
endif()
add_subdirectory(benchmarks)
endif()

Expand Down Expand Up @@ -636,6 +630,15 @@ elseif(TARGET arrow_static)
endif()
endif()

if(TARGET gtest)
get_target_property(gtest_is_imported gtest IMPORTED)
if(NOT gtest_is_imported)
export(TARGETS gtest gmock gtest_main gmock_main
FILE ${CUDF_BINARY_DIR}/cudf-gtesting-targets.cmake
NAMESPACE GTest::)
endif()
endif()

export(EXPORT cudf-targets
FILE ${CUDF_BINARY_DIR}/cudf-targets.cmake
NAMESPACE cudf::)
Expand Down
46 changes: 39 additions & 7 deletions cpp/cmake/cudf-build-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

cmake_minimum_required(VERSION 3.18)

set(_possible_targets_to_promote
cudf::cudf
cudf::benchmark
cudf::benchmark_main
GTest::gmock
GTest::gmock_main
GTest::gtest
GTest::gtest_main
cudf::cudftestutil
rmm::rmm
arrow_shared
arrow_cuda_shared )
foreach(target IN LISTS _possible_targets_to_promote)
if(NOT TARGET ${target})
list(APPEND _targets_to_promote ${target})
endif()
endforeach()

set(CUDF_VERSION @CUDF_VERSION@)
set(CUDF_VERSION_MAJOR @CUDF_VERSION_MAJOR@)
set(CUDF_VERSION_MINOR @CUDF_VERSION_MINOR@)
Expand Down Expand Up @@ -36,21 +54,29 @@ include(@CUDF_SOURCE_DIR@/cmake/thirdparty/CUDF_GetThrust.cmake)
# find rmm
set(CUDF_MIN_VERSION_rmm "${CUDF_VERSION_MAJOR}.${CUDF_VERSION_MINOR}")
include(@CUDF_SOURCE_DIR@/cmake/thirdparty/CUDF_GetRMM.cmake)
# find gtest
include(@CUDF_SOURCE_DIR@/cmake/thirdparty/CUDF_GetGTest.cmake)

# find arrow
if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/cudf-arrow-targets.cmake")
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/cudf-arrow-targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/cudf-arrow-targets.cmake")
else()
if(NOT DEFINED CUDF_USE_ARROW_STATIC)
set(CUDF_USE_ARROW_STATIC OFF)
endif()
include(@CUDF_SOURCE_DIR@/cmake/thirdparty/CUDF_GetArrow.cmake)
endif()

# find GTest
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/cudf-gtesting-targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/cudf-gtesting-targets.cmake")
else()
# find gtest
include(@CUDF_SOURCE_DIR@/cmake/thirdparty/CUDF_GetGTest.cmake)
endif()

list(POP_FRONT CMAKE_MODULE_PATH)

if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/cudf-arrow-targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/cudf-arrow-targets.cmake")
endif()
include("${CMAKE_CURRENT_LIST_DIR}/cudf-targets.cmake")

include("${CMAKE_CURRENT_LIST_DIR}/cudf-targets.cmake")
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/cudf-testing-targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/cudf-testing-targets.cmake")
endif()
Expand All @@ -59,6 +85,12 @@ include("${CMAKE_CURRENT_LIST_DIR}/cudf-config-version.cmake")

check_required_components(cudf)

foreach(target IN LISTS _targets_to_promote)
if(TARGET ${target})
fix_cmake_global_defaults(${target})
endif()
endforeach()

set(${CMAKE_FIND_PACKAGE_NAME}_CONFIG "${CMAKE_CURRENT_LIST_FILE}")

include(FindPackageHandleStandardArgs)
Expand Down
26 changes: 13 additions & 13 deletions cpp/cmake/cudf-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ This module offers an optional testing component which defines the
following IMPORTED GLOBAL targets:

cudf::cudftestutil - The main cudf testing library
cudf::gmock
cudf::gmock_main
cudf::gtest
cudf::gtest_main


Result Variables
^^^^^^^^^^^^^^^^
Expand All @@ -51,11 +46,11 @@ set(_possible_targets_to_promote
cudf::cudf
cudf::benchmark
cudf::benchmark_main
trxcllnt marked this conversation as resolved.
Show resolved Hide resolved
cudf::gmock
cudf::gtest
cudf::gmock_main
cudf::gtest_main
cudf::cudftestutil
GTest::gmock
GTest::gmock_main
GTest::gtest
GTest::gtest_main
rmm::rmm
arrow_shared
arrow_cuda_shared )
Expand Down Expand Up @@ -101,17 +96,22 @@ include("${CMAKE_CURRENT_LIST_DIR}/cudf-targets.cmake")
if(testing IN_LIST cudf_FIND_COMPONENTS)
enable_language(CUDA)

find_dependency(GTest @CUDF_MIN_VERSION_GTest@)
find_dependency(GTest @CUDF_MIN_VERSION_GTest@ CONFIG)

include("${CMAKE_CURRENT_LIST_DIR}/cudf-testing-targets.cmake")

endif()

include("${CMAKE_CURRENT_LIST_DIR}/cudf-config-version.cmake")

check_required_components(cudf)

foreach(t IN LISTS _targets_to_promote)
if(TARGET ${t})
set_target_properties(${t} PROPERTIES IMPORTED_GLOBAL TRUE)
foreach(target IN LISTS _targets_to_promote)
if(TARGET ${target})
get_target_property(_already_global ${target} IMPORTED_GLOBAL)
if(NOT _already_global)
set_target_properties(${target} PROPERTIES IMPORTED_GLOBAL TRUE)
endif()
endif()
endforeach()
set(${CMAKE_FIND_PACKAGE_NAME}_CONFIG "${CMAKE_CURRENT_LIST_FILE}")
Expand Down
10 changes: 1 addition & 9 deletions cpp/cmake/thirdparty/CUDF_GetGTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function(find_and_configure_gtest VERSION)
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-${VERSION}
GIT_SHALLOW TRUE
OPTIONS "INSTALL_GTEST OFF"
OPTIONS "INSTALL_GTEST ON"
# googletest >= 1.10.0 provides a cmake config file -- use it if it exists
FIND_PACKAGE_ARGUMENTS "CONFIG")
# Add GTest aliases if they don't already exist.
Expand All @@ -43,14 +43,6 @@ function(find_and_configure_gtest VERSION)
fix_cmake_global_defaults(GTest::gmock)
fix_cmake_global_defaults(GTest::gtest_main)
fix_cmake_global_defaults(GTest::gmock_main)
if(GTest_ADDED)
install(TARGETS gmock
gtest
gmock_main
gtest_main
DESTINATION lib
EXPORT cudf-testing-targets)
endif()
endfunction()

set(CUDF_MIN_VERSION_GTest 1.10.0)
Expand Down
5 changes: 0 additions & 5 deletions cpp/cmake/thirdparty/CUDF_GetRMM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ function(find_and_configure_rmm VERSION)

# Make sure consumers of cudf can also see rmm::rmm
fix_cmake_global_defaults(rmm::rmm)

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

set(CUDF_MIN_VERSION_rmm "${CUDF_VERSION_MAJOR}.${CUDF_VERSION_MINOR}")
Expand Down
6 changes: 0 additions & 6 deletions cpp/libcudf_kafka/cmake/thirdparty/CUDF_KAFKA_GetCUDF.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ function(find_and_configure_cudf VERSION)
"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)
Expand Down
5 changes: 1 addition & 4 deletions cpp/libcudf_kafka/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ function(ConfigureTest CMAKE_TEST_NAME )
add_executable(${CMAKE_TEST_NAME} ${ARGN})
set_target_properties(${CMAKE_TEST_NAME}
PROPERTIES RUNTIME_OUTPUT_DIRECTORY "$<BUILD_INTERFACE:${CUDA_KAFKA_BINARY_DIR}/gtests>")
if(TARGET cudf::gmock_main)
target_link_libraries(${CMAKE_TEST_NAME} PRIVATE cudf::gmock_main cudf::gtest_main cudf_kafka)
else()
target_link_libraries(${CMAKE_TEST_NAME} PRIVATE GTest::gmock_main GTest::gtest_main cudf_kafka)
target_link_libraries(${CMAKE_TEST_NAME} PRIVATE GTest::gmock_main GTest::gtest_main cudf_kafka)
endif()
trxcllnt marked this conversation as resolved.
Show resolved Hide resolved
target_include_directories(${CMAKE_TEST_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../include)
add_test(NAME ${CMAKE_TEST_NAME} COMMAND ${CMAKE_TEST_NAME})
Expand Down