From b450ec0adb81f12c07f7c495cf3935b418b373fe Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Wed, 29 Sep 2021 16:32:10 -0400 Subject: [PATCH] Stop CMake from marking cudf's libcudacxx and thrust includes as system (#9277) * Stop CMake from marking cudf's libcudacxx and thrust includes as system nvcc automatically adds the CUDA Toolkit system include paths before any system include paths that CMake adds. CMake implicitly treats all includes on import targets as 'SYSTEM' includes. To get the cudacxx shipped with cudf to be picked up by consumers instead of the version shipped with the CUDA Toolkit we need to make sure it is a non-SYSTEM include on the CMake side. * Clarify comment --- cpp/CMakeLists.txt | 49 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 00af1973cfe..1dd3348a9c9 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -473,8 +473,7 @@ target_include_directories(cudf "$" PRIVATE "$" INTERFACE "$" - "$" - "$") + "$") target_compile_definitions(cudf PUBLIC "$<$:${CUDF_CXX_DEFINITIONS}>" @@ -511,7 +510,7 @@ target_link_libraries(cudf cudf::Thrust rmm::rmm PRIVATE cuco::cuco - ZLIB::ZLIB + ZLIB::ZLIB nvcomp::nvcomp) # Add Conda library, and include paths if specified @@ -692,6 +691,40 @@ following IMPORTED GLOBAL targets: ]=]) +set(common_code_string + [=[ +if(NOT TARGET cudf::Thrust) + thrust_create_target(cudf::Thrust FROM_OPTIONS) +endif() + +# nvcc automatically adds the CUDA Toolkit system include paths before any +# system include paths that CMake adds. +# +# CMake implicitly treats all includes on import targets as 'SYSTEM' includes. +# +# To get the cudacxx shipped with cudf to be picked up by consumers instead of the +# version shipped with the CUDA Toolkit we need to make sure it is a non-SYSTEM +# include on the CMake side. +# +# To do this currently, we move the includes from the cudf::cudf target to a +# non-import target to ensure they are `-I` instead of `-isystem` + +add_library(cudf_non_system_includes INTERFACE) +target_link_libraries(cudf::cudf INTERFACE cudf_non_system_includes) + +get_target_property(all_includes cudf::cudf INTERFACE_INCLUDE_DIRECTORIES) +set(system_includes ) +set(normal_includes ) +foreach(include IN LISTS all_includes) + if(include MATCHES "/include/libcudf/") + list(APPEND normal_includes "${include}") + else() + list(APPEND system_includes "${include}") + endif() +endforeach() +set_target_properties(cudf::cudf PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${system_includes}") +set_target_properties(cudf_non_system_includes PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${normal_includes}") +]=]) set(install_code_string [=[ set(ArrowCUDA_DIR "${Arrow_DIR}") @@ -705,11 +738,8 @@ if(testing IN_LIST cudf_FIND_COMPONENTS) include("${CMAKE_CURRENT_LIST_DIR}/cudf-testing-targets.cmake") endif() endif() - -if(NOT TARGET cudf::Thrust) - thrust_create_target(cudf::Thrust FROM_OPTIONS) -endif() ]=]) +string(APPEND install_code_string "${common_code_string}") rapids_export(INSTALL cudf EXPORT_SET cudf-exports @@ -728,11 +758,8 @@ endif() if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/cudf-testing-targets.cmake") include("${CMAKE_CURRENT_LIST_DIR}/cudf-testing-targets.cmake") endif() - -if(NOT TARGET cudf::Thrust) - thrust_create_target(cudf::Thrust FROM_OPTIONS) -endif() ]=]) +string(APPEND build_code_string "${common_code_string}") rapids_export(BUILD cudf EXPORT_SET cudf-exports