Files
TheRock/rocm-libraries/CMakeLists.txt
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

338 lines
10 KiB
CMake

# Copyright Advanced Micro Devices, Inc., or its affiliates.
# SPDX-License-Identifier: MIT
cmake_minimum_required(VERSION 3.25.2)
project(rocm-libraries LANGUAGES C CXX ASM)
include(CheckLanguage)
check_language(Fortran)
if(CMAKE_Fortran_COMPILER)
enable_language(Fortran)
set(ROCM_LIBS_HAVE_FORTRAN TRUE)
else()
set(ROCM_LIBS_HAVE_FORTRAN FALSE)
message(STATUS "Fortran compiler not found - Fortran support disabled")
endif()
if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW) # FetchContent timestamp handling
endif()
if(POLICY CMP0077)
cmake_policy(SET CMP0077 NEW) # option() honors normal variables
endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
include(CMakeDependentOption)
include(GNUInstallDirs)
include(add_subdirectory_with_message)
include(fetch_rocm_cmake)
include(shared_third_party)
# --- Options and cache variables ---
option(ROCM_LIBS_SUPERBUILD "Enable superbuild mode" ON)
set(ROCM_LIBS_ENABLE_COMPONENTS "all"
CACHE STRING "Semicolon-separated list of components to build (default: 'all')"
)
set(DEFAULT_COMPONENTS
# shared
mxdatagenerator
rocroller
origami
# projects
hipblas-common
hipblaslt
rocprim
rocrand
)
set(AVAILABLE_COMPONENTS
${DEFAULT_COMPONENTS}
# dnn
hipdnn
hipdnn-integration-tests
miopen
miopen-provider
hipblaslt-provider
hip-kernel-provider
hipdnn-samples
)
set(UNSUPPORTED_COMPONENTS
# shared
tensile
# projects
composablekernel
hipblas
hipcub
hipfft
hiprand
hipsolver
hipsparse
hipsparselt
rocblas
rocfft
rocsolver
rocsparse
rocthrust
hipthreads
)
# NOTE: This is a temp option to reduce warnings generated by rocm-cmake. However, these warnings
# are reasonable and should be addressed.
option(ROCM_WARN_TOOLCHAIN_VAR "Warn if the toolchain version is not supported" OFF)
option(CMAKE_MESSAGE_CONTEXT_SHOW "Show the context of the message" ON)
# --- Validate options ---
if(NOT ROCM_LIBS_ENABLE_COMPONENTS)
message(FATAL_ERROR "ROCM_LIBS_ENABLE_COMPONENTS is empty, use 'all' to enable all components")
endif()
if("all" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
set(ROCM_LIBS_ENABLE_COMPONENTS ${DEFAULT_COMPONENTS})
endif()
message(STATUS "Enabling components:")
foreach(component ${ROCM_LIBS_ENABLE_COMPONENTS})
if(component IN_LIST AVAILABLE_COMPONENTS)
message(STATUS " ${component} (supported)")
elseif(component IN_LIST UNSUPPORTED_COMPONENTS)
message(STATUS " ${component} (unsupported)")
else()
message(FATAL_ERROR "Unknown component: ${component}.")
endif()
endforeach()
# Determine if CTest should be enabled at the root superbuild project level.
# If enabled, this must be done BEFORE any add_subdirectory() calls so that tests
# registered in subprojects are visible to root-level ctest.
# Note: The environment variable is checked for only the FIRST configure; the cache
# value is used exclusively after that.
set(_root_ctest_env_default "$ENV{ROCM_LIBS_ENABLE_ROOT_CTEST}")
option(ROCM_LIBS_ENABLE_ROOT_CTEST "Enable CTest at the root superbuild level" "${_root_ctest_env_default}")
if(ROCM_LIBS_ENABLE_ROOT_CTEST)
message(STATUS "CTest test aggregation is enabled at the root superbuild level")
enable_testing()
include(CTest)
endif()
if(ROCM_LIBS_ENABLE_ROOT_CTEST AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/shared/ctest/tests/CMakeLists.txt")
add_subdirectory(shared/ctest/tests)
endif()
# --- Shared third-party dependencies ---
# Declare libraries that more than one subproject would otherwise fetch
# independently (e.g. nlohmann_json used by both hipdnn and miopen).
# Must run BEFORE any add_subdirectory() call so that subproject
# find_package() resolutions are intercepted via OVERRIDE_FIND_PACKAGE.
set(_rocm_libs_needs_shared_json FALSE)
foreach(_c hipdnn miopen miopen-provider)
if("${_c}" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
set(_rocm_libs_needs_shared_json TRUE)
endif()
endforeach()
if(_rocm_libs_needs_shared_json)
rocm_libs_declare_shared_deps()
endif()
unset(_rocm_libs_needs_shared_json)
# --- Add subdirectories ---
if("mxdatagenerator" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
add_subdirectory_with_message(
COMPONENT mxdatagenerator
PREFIX_PATH shared
EXPECT_TARGET roc::mxDataGenerator
)
endif()
if("hipblas-common" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
add_subdirectory_with_message(
COMPONENT hipblas-common
PREFIX_PATH projects
EXPECT_TARGET roc::hipblas-common
)
endif()
if("rocroller" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
# pip packages:
# pip install pytest-cmake
set(ROCROLLER_ENABLE_FETCH ON)
add_subdirectory_with_message(
COMPONENT rocroller
PREFIX_PATH shared
EXPECT_TARGET roc::rocroller
)
endif()
if("origami" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
add_subdirectory_with_message(
COMPONENT origami
PREFIX_PATH shared
EXPECT_TARGET roc::origami
)
endif()
if("hipblaslt" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
set(HIPBLASLT_ENABLE_BLIS OFF)
add_subdirectory_with_message(
COMPONENT hipblaslt
PREFIX_PATH projects
EXPECT_TARGET roc::hipblaslt
)
endif()
if("rocprim" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
add_subdirectory_with_message(
COMPONENT rocprim
PREFIX_PATH projects
EXPECT_TARGET rocprim
)
endif()
if("rocrand" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
add_subdirectory_with_message(
COMPONENT rocrand
PREFIX_PATH projects
EXPECT_TARGET rocrand
)
endif()
# --- DNN components (opt-in, not part of default 'all' build) ---
if("hipdnn" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
add_subdirectory_with_message(
COMPONENT hipdnn
PREFIX_PATH projects
EXPECT_TARGET hipdnn_backend
)
endif()
if("hipdnn-integration-tests" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
add_subdirectory_with_message(
COMPONENT integration-tests
PREFIX_PATH dnn-providers
EXPECT_TARGET hipdnn_integration_tests
)
endif()
if("miopen" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
set(MIOPEN_STANDALONE_BUILD ON CACHE BOOL "")
add_subdirectory_with_message(
COMPONENT miopen
PREFIX_PATH projects
EXPECT_TARGET MIOpen
)
endif()
if("miopen-provider" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
add_subdirectory_with_message(
COMPONENT miopen-provider
PREFIX_PATH dnn-providers
EXPECT_TARGET miopen_plugin
)
endif()
if("hipblaslt-provider" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
add_subdirectory_with_message(
COMPONENT hipblaslt-provider
PREFIX_PATH dnn-providers
EXPECT_TARGET hipblaslt_plugin
)
endif()
if("hip-kernel-provider" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
add_subdirectory_with_message(
COMPONENT hip-kernel-provider
PREFIX_PATH dnn-providers
EXPECT_TARGET hip_kernel_provider
)
endif()
if("hipdnn-samples" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
add_subdirectory_with_message(
COMPONENT samples
PREFIX_PATH projects/hipdnn
EXPECT_TARGET hipdnn_samples
)
# Ensure the supported provider plugins are built before samples (needed at test runtime)
foreach(_provider_target miopen_plugin hipblaslt_plugin hip_kernel_provider)
if(TARGET ${_provider_target})
add_dependencies(hipdnn_samples ${_provider_target})
endif()
endforeach()
endif()
# --- Projects not yet configured for superbuild ---
if("tensile" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
message(FATAL_ERROR "tensile is not yet supported in the superbuild")
endif()
if("rocsparse" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
message(FATAL_ERROR "rocsparse is not yet supported in the superbuild")
endif()
if("rocfft" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
message(FATAL_ERROR "rocfft is not yet supported in the superbuild")
endif()
if("hipfft" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
message(FATAL_ERROR "hipfft is not yet supported in the superbuild")
endif()
if("hipsparse" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
message(FATAL_ERROR "hipsparse is not yet supported in the superbuild")
endif()
if("composablekernel" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
message(FATAL_ERROR "composablekernel is not yet supported in the superbuild")
endif()
if("hipcub" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
message(FATAL_ERROR "hipcub is not yet supported in the superbuild")
# NOTE: Currently, hipcub tries to expose the rocm::rocprim target if it isn't already found.
# This action should be removed so that rocprim is made an explicit dependency where required.
endif()
if("hiprand" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
message(FATAL_ERROR "hiprand is not yet supported in the superbuild")
endif()
if("hipblas" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
message(FATAL_ERROR "hipblas is not yet supported in the superbuild")
endif()
if("hipsolver" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
message(FATAL_ERROR "hipsolver is not yet supported in the superbuild")
endif()
if("hipsparselt" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
message(FATAL_ERROR "hipsparselt is not yet supported in the superbuild")
endif()
if("rocblas" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
message(FATAL_ERROR "rocblas is not yet supported in the superbuild")
endif()
if("rocsolver" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
message(FATAL_ERROR "rocsolver is not yet supported in the superbuild")
endif()
if("rocthrust" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
message(FATAL_ERROR "rocthrust is not yet supported in the superbuild")
endif()
# hipthreads depends on libhipcxx, which is external to rocm-libraries and
# resolved from the prefix path (like hip), not a component. Registering the
# name here (in UNSUPPORTED_COMPONENTS) keeps it a recognized component without
# building it: hipthreads' own CMake still uses CMAKE_SOURCE_DIR for include/
# install paths, which resolves to the rocm-libraries root when added as a
# subdirectory. Once that is made subproject-safe (CMAKE_CURRENT_SOURCE_DIR +
# a top-level guard), this can move to AVAILABLE_COMPONENTS with a real
# add_subdirectory_with_message().
if("hipthreads" IN_LIST ROCM_LIBS_ENABLE_COMPONENTS)
message(FATAL_ERROR "hipthreads is not yet supported in the superbuild")
endif()