Skip to content

Commit

Permalink
Stop CMake from marking cudf's libcudacxx and thrust includes as syst…
Browse files Browse the repository at this point in the history
…em (#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
  • Loading branch information
robertmaynard authored Sep 29, 2021
1 parent 52e53f0 commit b450ec0
Showing 1 changed file with 38 additions and 11 deletions.
49 changes: 38 additions & 11 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,7 @@ target_include_directories(cudf
"$<BUILD_INTERFACE:${CUDF_GENERATED_INCLUDE_DIR}/include>"
PRIVATE "$<BUILD_INTERFACE:${CUDF_SOURCE_DIR}/src>"
INTERFACE "$<INSTALL_INTERFACE:include>"
"$<INSTALL_INTERFACE:include/libcudf/libcudacxx>"
"$<INSTALL_INTERFACE:include/libcudf/Thrust>")
"$<INSTALL_INTERFACE:include/libcudf/libcudacxx>")

target_compile_definitions(cudf
PUBLIC "$<$<COMPILE_LANGUAGE:CXX>:${CUDF_CXX_DEFINITIONS}>"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}")
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit b450ec0

Please sign in to comment.