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

[FIX] Add treelite include paths to treelite targets #4023

Merged
10 changes: 4 additions & 6 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -321,13 +321,11 @@ if(BUILD_CUML_CPP_LIBRARY)
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:$<$<BOOL:${ENABLE_CUMLPRIMS_MG}>:${cumlprims_mg_INCLUDE_DIRS}>>
$<BUILD_INTERFACE:$<$<BOOL:Treelite_ADDED>:${Treelite_BINARY_DIR}/include>>
$<$<BOOL:Treelite_ADDED>:${Treelite_SOURCE_DIR}/include>
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src_prims>
$<$<OR:$<BOOL:BUILD_CUML_STD_COMMS>,$<BOOL:BUILD_CUML_MPI_COMMS>>:${NCCL_INCLUDE_DIRS}>
$<$<BOOL:BUILD_CUML_MPI_COMMS>:${MPI_CXX_INCLUDE_PATH}>
$<$<OR:$<BOOL:${BUILD_CUML_STD_COMMS}>,$<BOOL:${BUILD_CUML_MPI_COMMS}>>:${NCCL_INCLUDE_DIRS}>
$<$<BOOL:${BUILD_CUML_MPI_COMMS}>:${MPI_CXX_INCLUDE_PATH}>
INTERFACE
$<INSTALL_INTERFACE:include>
)
Expand All @@ -344,11 +342,11 @@ if(BUILD_CUML_CPP_LIBRARY)
CUDA::cusolver
CUDA::cudart
CUDA::cusparse
$<$<BOOL:NVTX>:CUDA::nvToolsExt>
$<$<BOOL:${NVTX}>:CUDA::nvToolsExt>
FAISS::FAISS
$<IF:$<BOOL:${Treelite_ADDED}>,treelite::treelite_static,treelite::treelite>
$<IF:$<BOOL:${Treelite_ADDED}>,treelite::treelite_runtime_static,treelite::treelite_runtime>
$<$<BOOL:OpenMP_FOUND>:OpenMP::OpenMP_CXX>
$<$<BOOL:${OpenMP_FOUND}>:OpenMP::OpenMP_CXX>
$<$<OR:$<BOOL:${BUILD_CUML_STD_COMMS}>,$<BOOL:${BUILD_CUML_MPI_COMMS}>>:NCCL::NCCL>
$<$<BOOL:${BUILD_CUML_MPI_COMMS}>:${MPI_CXX_LIBRARIES}>
$<$<BOOL:${ENABLE_CUMLPRIMS_MG}>:cumlprims_mg::cumlprims_mg>
Expand Down
4 changes: 4 additions & 0 deletions cpp/bench/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ if(BUILD_CUML_BENCH)
cuml
benchmark::benchmark
raft::raft
$<IF:$<BOOL:${Treelite_ADDED}>,treelite::treelite_static,treelite::treelite>
$<IF:$<BOOL:${Treelite_ADDED}>,treelite::treelite_runtime_static,treelite::treelite_runtime>
)

target_include_directories(${CUML_CPP_BENCH_TARGET}
Expand Down Expand Up @@ -85,6 +87,8 @@ if(BUILD_CUML_PRIMS_BENCH)
CUDA::cublas
benchmark::benchmark
raft::raft
$<IF:$<BOOL:${Treelite_ADDED}>,treelite::treelite_static,treelite::treelite>
$<IF:$<BOOL:${Treelite_ADDED}>,treelite::treelite_runtime_static,treelite::treelite_runtime>
)

target_include_directories(${PRIMS_BENCH_TARGET}
Expand Down
22 changes: 18 additions & 4 deletions cpp/cmake/thirdparty/get_treelite.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,25 @@ function(find_and_configure_treelite)
)

set(Treelite_ADDED ${Treelite_ADDED} PARENT_SCOPE)
set(Treelite_SOURCE_DIR ${Treelite_SOURCE_DIR} PARENT_SCOPE)

if(Treelite_ADDED AND NOT TARGET treelite::treelite_static)
add_library(treelite::treelite_static ALIAS treelite_static)
add_library(treelite::treelite_runtime_static ALIAS treelite_runtime_static)
if(Treelite_ADDED)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be made not conditional on treelite as we were talking about offline?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out Treelite_SOURCE_DIR and Treelite_BINARY_DIR aren't populated if Treelite_ADDED is false.

target_include_directories(treelite
PUBLIC $<BUILD_INTERFACE:${Treelite_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${Treelite_BINARY_DIR}/include>)
target_include_directories(treelite_static
PUBLIC $<BUILD_INTERFACE:${Treelite_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${Treelite_BINARY_DIR}/include>)
target_include_directories(treelite_runtime
PUBLIC $<BUILD_INTERFACE:${Treelite_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${Treelite_BINARY_DIR}/include>)
target_include_directories(treelite_runtime_static
PUBLIC $<BUILD_INTERFACE:${Treelite_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${Treelite_BINARY_DIR}/include>)

if(NOT TARGET treelite::treelite_static)
add_library(treelite::treelite_static ALIAS treelite_static)
add_library(treelite::treelite_runtime_static ALIAS treelite_runtime_static)
endif()
endif()

endfunction()
Expand Down