Skip to content

Commit

Permalink
Clean up headers in CMakeLists.txt. (#1341)
Browse files Browse the repository at this point in the history
This PR adds section headers to the CMakeLists.txt to mirror other RAPIDS packages, which makes it easier to follow the logic and compare across packages. This PR replaces #1292.

Authors:
  - Bradley Dice (https://github.com/bdice)

Approvers:
  - Vyas Ramasubramani (https://github.com/vyasr)
  - Mark Harris (https://github.com/harrism)

URL: #1341
  • Loading branch information
bdice authored Sep 18, 2023
1 parent 2ff1bd0 commit 068f705
Showing 1 changed file with 43 additions and 11 deletions.
54 changes: 43 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,15 @@ project(
# Write the version header
rapids_cmake_write_version_file(include/rmm/version_config.hpp)

# ##################################################################################################
# * build type -------------------------------------------------------------------------------------

# Set a default build type if none was specified
rapids_cmake_build_type(Release)

# build options
# ##################################################################################################
# * build options ----------------------------------------------------------------------------------

option(BUILD_TESTS "Configure CMake to build tests" ON)
option(BUILD_BENCHMARKS "Configure CMake to build (google) benchmarks" OFF)
set(RMM_LOGGING_LEVEL
Expand All @@ -48,17 +53,28 @@ message(STATUS "RMM: RMM_LOGGING_LEVEL = '${RMM_LOGGING_LEVEL}'")
# cudart can be statically linked or dynamically linked the python ecosystem wants dynamic linking
option(CUDA_STATIC_RUNTIME "Statically link the CUDA runtime" OFF)

# ##################################################################################################
# * compiler options -------------------------------------------------------------------------------

# find packages we depend on
rapids_find_package(
CUDAToolkit REQUIRED
BUILD_EXPORT_SET rmm-exports
INSTALL_EXPORT_SET rmm-exports)

# ##################################################################################################
# * dependencies -----------------------------------------------------------------------------------

# add third party dependencies using CPM
rapids_cpm_init()

include(cmake/thirdparty/get_fmt.cmake)
include(cmake/thirdparty/get_spdlog.cmake)
include(cmake/thirdparty/get_thrust.cmake)

# library targets
# ##################################################################################################
# * library targets --------------------------------------------------------------------------------

add_library(rmm INTERFACE)
add_library(rmm::rmm ALIAS rmm)

Expand All @@ -79,6 +95,9 @@ target_link_libraries(rmm INTERFACE spdlog::spdlog_header_only)
target_link_libraries(rmm INTERFACE dl)
target_compile_features(rmm INTERFACE cxx_std_17 $<BUILD_INTERFACE:cuda_std_17>)

# ##################################################################################################
# * tests and benchmarks ---------------------------------------------------------------------------

if((BUILD_TESTS OR BUILD_BENCHMARKS) AND CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
include(rapids-cuda)
rapids_cuda_init_architectures(RMM)
Expand All @@ -90,27 +109,29 @@ if((BUILD_TESTS OR BUILD_BENCHMARKS) AND CMAKE_PROJECT_NAME STREQUAL PROJECT_NAM
message(STATUS "RMM: Building benchmarks with GPU Architectures: ${CMAKE_CUDA_ARCHITECTURES}")
endif()

# optionally build tests
# ##################################################################################################
# * add tests --------------------------------------------------------------------------------------

if(BUILD_TESTS AND CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
include(cmake/thirdparty/get_gtest.cmake)
include(CTest) # calls enable_testing()

add_subdirectory(tests)
endif()

# optionally build benchmarks
# ##################################################################################################
# * add benchmarks ---------------------------------------------------------------------------------

if(BUILD_BENCHMARKS AND CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
include(${rapids-cmake-dir}/cpm/gbench.cmake)
rapids_cpm_gbench()
add_subdirectory(benchmarks)
endif()

include(CPack)
# ##################################################################################################
# * install targets --------------------------------------------------------------------------------

# optionally assemble Thrust pretty-printers
if(Thrust_SOURCE_DIR)
configure_file(scripts/load-pretty-printers.in load-pretty-printers @ONLY)
endif()
include(CPack)

# install export targets
install(TARGETS rmm EXPORT rmm-exports)
Expand Down Expand Up @@ -143,7 +164,9 @@ rapids_export(
DOCUMENTATION doc_string
FINAL_CODE_BLOCK code_string)

# build export targets
# ##################################################################################################
# * build export -----------------------------------------------------------------------------------

rapids_export(
BUILD rmm
EXPORT_SET rmm-exports
Expand All @@ -152,7 +175,8 @@ rapids_export(
DOCUMENTATION doc_string
FINAL_CODE_BLOCK code_string)

# make documentation
# ##################################################################################################
# * make documentation -----------------------------------------------------------------------------

add_custom_command(
OUTPUT RMM_DOXYGEN
Expand All @@ -165,3 +189,11 @@ add_custom_target(
rmm_doc
DEPENDS RMM_DOXYGEN
COMMENT "Target for the custom command to build the RMM doxygen docs")

# ##################################################################################################
# * make gdb helper scripts ------------------------------------------------------------------------

# optionally assemble Thrust pretty-printers
if(Thrust_SOURCE_DIR)
configure_file(scripts/load-pretty-printers.in load-pretty-printers @ONLY)
endif()

0 comments on commit 068f705

Please sign in to comment.