Skip to content

Commit

Permalink
Use final_code_string in both BUILD and INSTALL, add conditional guar…
Browse files Browse the repository at this point in the history
…d at DIRECTORY scope.
  • Loading branch information
bdice committed Feb 13, 2024
1 parent 17c3af0 commit 4cb4cfb
Showing 1 changed file with 44 additions and 40 deletions.
84 changes: 44 additions & 40 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,60 +127,64 @@ Provide targets for KvikIO: C++ bindings for cuFile.
]=]
)

rapids_export(
INSTALL kvikio
EXPORT_SET kvikio-exports
GLOBAL_TARGETS kvikio
NAMESPACE kvikio::
DOCUMENTATION doc_string
)

set(build_code_string
set(final_code_string
[=[

# Find cuFile and determine which features are supported
find_package(cuFile)
if(NOT cuFile_FOUND)
message(WARNING "KvikIO: Building KvikIO without cuFile")
else()
file(READ "${cuFile_INCLUDE_DIRS}/cufile.h" CUFILE_H_STR)
string(FIND "${CUFILE_H_STR}" "cuFileBatchIOSetUp" cuFileBatchIOSetUp_location)
if(cuFileBatchIOSetUp_location EQUAL "-1")
set(cuFile_BATCH_API_FOUND FALSE)
get_property(already_set_kvikio DIRECTORY PROPERTY kvikio_already_set_defines SET)
if(NOT already_set_kvikio)
set_property(DIRECTORY PROPERTY kvikio_already_set_defines "ON")

# Find cuFile and determine which features are supported
find_package(cuFile)
if(NOT cuFile_FOUND)
message(WARNING "KvikIO: Building KvikIO without cuFile")
else()
set(cuFile_BATCH_API_FOUND TRUE)
file(READ "${cuFile_INCLUDE_DIRS}/cufile.h" CUFILE_H_STR)
string(FIND "${CUFILE_H_STR}" "cuFileBatchIOSetUp" cuFileBatchIOSetUp_location)
if(cuFileBatchIOSetUp_location EQUAL "-1")
set(cuFile_BATCH_API_FOUND FALSE)
else()
set(cuFile_BATCH_API_FOUND TRUE)
endif()
message(STATUS "KvikIO: Found cuFile's Batch API: ${cuFile_BATCH_API_FOUND}")
string(FIND "${CUFILE_H_STR}" "cuFileReadAsync" cuFileReadAsync_location)
if(cuFileReadAsync_location EQUAL "-1")
set(cuFile_STREAM_API_FOUND FALSE)
else()
set(cuFile_STREAM_API_FOUND TRUE)
endif()
message(STATUS "KvikIO: Found cuFile's Stream API: ${cuFile_STREAM_API_FOUND}")
endif()
message(STATUS "KvikIO: Found cuFile's Batch API: ${cuFile_BATCH_API_FOUND}")
string(FIND "${CUFILE_H_STR}" "cuFileReadAsync" cuFileReadAsync_location)
if(cuFileReadAsync_location EQUAL "-1")
set(cuFile_STREAM_API_FOUND FALSE)
else()
set(cuFile_STREAM_API_FOUND TRUE)
endif()
message(STATUS "KvikIO: Found cuFile's Stream API: ${cuFile_STREAM_API_FOUND}")
endif()

# Enable supported cuFile features in KvikIO
if(cuFile_FOUND)
target_link_libraries(kvikio::kvikio INTERFACE cufile::cuFile_interface)
target_compile_definitions(kvikio::kvikio INTERFACE KVIKIO_CUFILE_FOUND)
if(cuFile_BATCH_API_FOUND)
target_compile_definitions(kvikio::kvikio INTERFACE KVIKIO_CUFILE_BATCH_API_FOUND)
endif()
if(cuFile_STREAM_API_FOUND)
target_compile_definitions(kvikio::kvikio INTERFACE KVIKIO_CUFILE_STREAM_API_FOUND)
# Enable supported cuFile features in KvikIO
if(cuFile_FOUND)
target_link_libraries(kvikio::kvikio INTERFACE cufile::cuFile_interface)
target_compile_definitions(kvikio::kvikio INTERFACE KVIKIO_CUFILE_FOUND)
if(cuFile_BATCH_API_FOUND)
target_compile_definitions(kvikio::kvikio INTERFACE KVIKIO_CUFILE_BATCH_API_FOUND)
endif()
if(cuFile_STREAM_API_FOUND)
target_compile_definitions(kvikio::kvikio INTERFACE KVIKIO_CUFILE_STREAM_API_FOUND)
endif()
endif()
endif()

]=]
)

rapids_export(
INSTALL kvikio
EXPORT_SET kvikio-exports
GLOBAL_TARGETS kvikio
NAMESPACE kvikio::
DOCUMENTATION doc_string
FINAL_CODE_BLOCK final_code_string
)

# build export targets
rapids_export(
BUILD kvikio
EXPORT_SET kvikio-exports
GLOBAL_TARGETS kvikio
NAMESPACE kvikio::
DOCUMENTATION doc_string
FINAL_CODE_BLOCK build_code_string
FINAL_CODE_BLOCK final_code_string
)

0 comments on commit 4cb4cfb

Please sign in to comment.