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
81 lines
3.4 KiB
CMake
81 lines
3.4 KiB
CMake
# Copyright © Advanced Micro Devices, Inc., or its affiliates.
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
# Shared spdlog/fmt configuration for hipDNN components
|
|
# This module provides a unified function to enable spdlog support for any target.
|
|
|
|
# Function to enable spdlog support for a target
|
|
# This handles both system-installed spdlog and locally fetched spdlog,
|
|
# and properly configures fmt (bundled or external).
|
|
#
|
|
# Usage: hipdnn_enable_spdlog(TARGET_NAME)
|
|
#
|
|
# This function:
|
|
# - Finds spdlog if not already available
|
|
# - Adds spdlog include directories (header-only, no linking to avoid compile option inheritance)
|
|
# - Configures fmt (external or bundled)
|
|
# - Adds required compile definitions (FMT_HEADER_ONLY, etc.)
|
|
#
|
|
# Note: We use hipdnn_add_dependency_includes() instead of target_link_libraries() to avoid
|
|
# inheriting compile options like /Zc:__cplusplus from spdlog which are incompatible with
|
|
# clang++ on Windows.
|
|
#
|
|
function(hipdnn_enable_spdlog TARGET_NAME)
|
|
# Try to find spdlog if not already available
|
|
if(NOT TARGET spdlog::spdlog_header_only AND NOT TARGET spdlog_header_only)
|
|
find_package(spdlog QUIET)
|
|
endif()
|
|
|
|
# Handle locally fetched spdlog (creates alias if needed)
|
|
if(TARGET spdlog_header_only AND NOT TARGET spdlog::spdlog_header_only)
|
|
add_library(spdlog::spdlog_header_only ALIAS spdlog_header_only)
|
|
endif()
|
|
|
|
# Determine which spdlog target to use
|
|
if(TARGET spdlog::spdlog_header_only)
|
|
set(_spdlog_target spdlog::spdlog_header_only)
|
|
elseif(TARGET spdlog_header_only)
|
|
set(_spdlog_target spdlog_header_only)
|
|
else()
|
|
message(FATAL_ERROR "hipdnn_enable_spdlog: spdlog not found. "
|
|
"Ensure spdlog is installed or available via CMAKE_PREFIX_PATH.")
|
|
endif()
|
|
|
|
# Check if spdlog was built with external fmt by inspecting its compile definitions
|
|
get_target_property(_spdlog_defs ${_spdlog_target} INTERFACE_COMPILE_DEFINITIONS)
|
|
set(_spdlog_uses_external_fmt FALSE)
|
|
if(_spdlog_defs)
|
|
if("SPDLOG_FMT_EXTERNAL" IN_LIST _spdlog_defs)
|
|
set(_spdlog_uses_external_fmt TRUE)
|
|
endif()
|
|
endif()
|
|
|
|
# Use include-only approach to avoid inheriting compile options (e.g., /Zc:__cplusplus)
|
|
# that are incompatible with clang++ on Windows
|
|
hipdnn_add_dependency_includes(${TARGET_NAME} ${_spdlog_target}
|
|
COMPILE_DEFINITIONS FMT_HEADER_ONLY)
|
|
|
|
# Handle external fmt configuration
|
|
# Only add SPDLOG_FMT_EXTERNAL if spdlog was actually built with it.
|
|
if(_spdlog_uses_external_fmt)
|
|
find_package(fmt QUIET)
|
|
if(NOT fmt_FOUND)
|
|
message(FATAL_ERROR "hipdnn_enable_spdlog: spdlog requires external fmt but fmt was not found. "
|
|
"Ensure fmt is installed or available via CMAKE_PREFIX_PATH.")
|
|
endif()
|
|
if(TARGET fmt::fmt-header-only)
|
|
hipdnn_add_dependency_includes(${TARGET_NAME} fmt::fmt-header-only
|
|
COMPILE_DEFINITIONS SPDLOG_FMT_EXTERNAL)
|
|
elseif(TARGET fmt::fmt)
|
|
hipdnn_add_dependency_includes(${TARGET_NAME} fmt::fmt
|
|
COMPILE_DEFINITIONS SPDLOG_FMT_EXTERNAL)
|
|
target_link_libraries(${TARGET_NAME} PUBLIC fmt::fmt)
|
|
else()
|
|
message(FATAL_ERROR "hipdnn_enable_spdlog: fmt package found but no usable target. "
|
|
"Expected fmt::fmt-header-only or fmt::fmt.")
|
|
endif()
|
|
endif()
|
|
|
|
message(STATUS "hipdnn_enable_spdlog: Enabled spdlog for target ${TARGET_NAME}")
|
|
endfunction()
|