Files
TheRock/rocm-systems/projects/clr/opencl/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

163 lines
5.5 KiB
CMake

# Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
#
# SPDX-License-Identifier: MIT
project(opencl)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# Set default libdir to be "lib" for ROCm, distros will override this anyway:
set(CMAKE_INSTALL_LIBDIR "lib" CACHE STRING "Library install directory")
include(GNUInstallDirs)
option(BUILD_TESTS "Enable building OpenCL tests" OFF)
option(BUILD_ICD "Enable building OpenCL ICD Loader" OFF)
option(EMU_ENV "Enable building for emulation environment" OFF)
option(ENABLE_ADDRESS_SANITIZER "Option to enable ASAN build" OFF)
# Address sanitizer options
if(ENABLE_ADDRESS_SANITIZER)
message(STATUS "Building ocltst tests with Address Sanitizer options")
set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -shared-libasan -g -gz")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -shared-libasan -g -gz")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--enable-new-dtags -fuse-ld=lld -fsanitize=address -shared-libasan -g -gz -Wl,--build-id=sha1 -L${ROCM_PATH}/lib/asan")
endif()
if(NOT WIN32)
set(AMDOCL_INSTALL_LIBDIR ${PROJECT_NAME})
endif()
set(OPENCL_ICD_LOADER_HEADERS_DIR "${CMAKE_CURRENT_LIST_DIR}/khronos/headers/opencl2.2" CACHE PATH "")
if(BUILD_ICD)
add_subdirectory(khronos/icd)
endif()
# Resolve OpenCL ICD link library once for tools and tests.
# If OPENCL_ICD_LIB is empty, targets that need the ICD loader are skipped.
if(TARGET OpenCL)
set(OPENCL_ICD_LIB OpenCL)
else()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
find_package(AMD_ICD QUIET)
find_library(OPENCL_ICD_LIB OpenCL HINTS "${AMD_ICD_LIBRARY_DIR}")
if(NOT OPENCL_ICD_LIB)
message(WARNING "OpenCL ICD loader not found. clinfo and ocltst will not be built.")
endif()
endif()
add_subdirectory(amdocl)
add_subdirectory(tools/cltrace)
if(OPENCL_ICD_LIB)
add_subdirectory(tools/clinfo)
if(BUILD_TESTS)
add_subdirectory(tests/ocltst)
endif()
endif()
###--- Packaging ------------------------------------------------------------###
# DEV package
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/khronos/headers/opencl2.2/CL"
DESTINATION include
COMPONENT DEV
PATTERN cl_d3d10.h EXCLUDE
PATTERN cl_d3d11.h EXCLUDE
PATTERN cl_dx9_media_sharing.h EXCLUDE
PATTERN cl_egl.h EXCLUDE
PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
#############################
# Packaging steps
#############################
if(NOT WIN32)
find_package(ROCM QUIET CONFIG PATHS ${ROCM_PATH})
if(ROCM_FOUND)
include(ROCMSetupVersion)
rocm_setup_version( VERSION "2.0.0" )
else()
set(PROJECT_VERSION "2.0.0")
endif()
#set a name for icd file
set(OPENCL_AMD_ICD_FILE "amdocl64.icd")
if (DEFINED ROCM_PATCH_VERSION)
# set unique name for ICD file for each jenkins build
# Use ENV variable CPACK_RPM_PACKAGE_RELEASE, which is having build number
set(PACKAGE_RELEASE_VERSION "")
if(DEFINED ENV{CPACK_RPM_PACKAGE_RELEASE})
set(PACKAGE_RELEASE_VERSION $ENV{CPACK_RPM_PACKAGE_RELEASE})
endif()
if(PACKAGE_RELEASE_VERSION)
# Replace "." to "_" in package version string. So file name will have .icd as extension
string(REPLACE "." "_" PACKAGE_RELEASE_VERSION ${PACKAGE_RELEASE_VERSION})
else()
# set a default value
set(PACKAGE_RELEASE_VERSION "9999")
endif()
set(OPENCL_AMD_ICD_FILE "amdocl64_${ROCM_PATCH_VERSION}_${PACKAGE_RELEASE_VERSION}.icd")
endif()
if(BUILD_ICD)
get_target_property(OPENCL_LIB_VERSION_MAJOR OpenCL SOVERSION)
get_target_property(OPENCL_LIB_VERSION_STRING OpenCL VERSION)
endif()
#Set Package Version
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
if(DEFINED ENV{ROCM_LIBPATCH_VERSION})
set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}.$ENV{ROCM_LIBPATCH_VERSION}")
message("Using CPACK_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION}")
endif()
set(CPACK_PACKAGING_INSTALL_PREFIX "${ROCM_PATH}" CACHE PATH "Package Installation path for OpenCL")
configure_file(
packaging/amdocl64.icd
${CMAKE_BINARY_DIR}/opencl/packages/opencl/${OPENCL_AMD_ICD_FILE}
COPYONLY
)
# support legacy rocm-ci
install(
FILES ${CMAKE_BINARY_DIR}/opencl/packages/opencl/${OPENCL_AMD_ICD_FILE}
DESTINATION /${CMAKE_INSTALL_SYSCONFDIR}/OpenCL/vendors
COMPONENT binary
EXCLUDE_FROM_ALL
)
configure_file(
packaging/rocm-opencl.conf
${CMAKE_BINARY_DIR}/opencl/packages/opencl/10-rocm-opencl.conf
COPYONLY
)
# support legacy rocm-ci
install(
FILES ${CMAKE_BINARY_DIR}/opencl/packages/opencl/10-rocm-opencl.conf
DESTINATION /${CMAKE_INSTALL_SYSCONFDIR}/ld.so.conf.d
COMPONENT binary
EXCLUDE_FROM_ALL
)
#Package: rocm-opencl,rocm-opencl-dev/devel,rocm-ocl-icd
set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/packages/opencl)
configure_file(packaging/rocm-opencl.postinst ${BUILD_DIR}/postinst @ONLY)
configure_file(packaging/rocm-opencl.postrm ${BUILD_DIR}/postrm @ONLY)
configure_file(packaging/rocm-opencl.rpm_post ${BUILD_DIR}/rpm_post @ONLY)
configure_file(packaging/rocm-opencl.rpm_postun ${BUILD_DIR}/rpm_postun @ONLY)
if(BUILD_ICD)
set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/packages/rocm-ocl-icd)
configure_file(packaging/rocm-ocl-icd.postinst ${BUILD_DIR}/postinst @ONLY)
configure_file(packaging/rocm-ocl-icd.postrm ${BUILD_DIR}/postrm @ONLY)
configure_file(packaging/rocm-ocl-icd.rpm_post ${BUILD_DIR}/rpm_post @ONLY)
configure_file(packaging/rocm-ocl-icd.rpm_postun ${BUILD_DIR}/rpm_postun @ONLY)
endif()
add_subdirectory(packaging)
endif()