11# MIT License
22#
3- # Copyright (c) 2017-2026 Advanced Micro Devices, Inc. All rights reserved.
3+ # Copyright (c) 2017-2025 Advanced Micro Devices, Inc. All rights reserved.
44#
55# Permission is hereby granted, free of charge, to any person obtaining a copy
66# of this software and associated documentation files (the "Software"), to deal
@@ -44,16 +44,14 @@ if(DEFINED BUILD_SHARED_LIBS)
4444endif ()
4545set (USER_ROCM_WARN_TOOLCHAIN_VAR ${ROCM_WARN_TOOLCHAIN_VAR} )
4646
47- # Suppress ROCmChecks warnings for local toolchain modifications.
48- set (ROCM_WARN_TOOLCHAIN_VAR OFF )
49-
50- # Force older versions of option() in googletest to respect the local variable setting.
51- set (CMAKE_POLICY_DEFAULT_CMP0077 NEW)
52-
53- # Resolve Ninja generator errors regarding RPATH relinking during the install phase for merged subprojects.
54- set (CMAKE_BUILD_WITH_INSTALL_RPATH ON )
55-
5647set (ROCM_WARN_TOOLCHAIN_VAR OFF CACHE BOOL "" )
48+ # Suppress ROCMChecks WARNING on third-party dependencies
49+ set (_HIPCUB_DISABLE_ROCM_CHECKS FALSE )
50+ macro (rocm_check_toolchain_var var access value list_file )
51+ if (NOT _HIPCUB_DISABLE_ROCM_CHECKS)
52+ _rocm_check_toolchain_var ("${var} " "${access} " "${value} " "${list_file} " )
53+ endif ()
54+ endmacro ()
5755# Turn off warnings and errors for all warnings in dependencies
5856separate_arguments (CXX_FLAGS_LIST NATIVE_COMMAND ${CMAKE_CXX_FLAGS } )
5957list (REMOVE_ITEM CXX_FLAGS_LIST /WX -Werror -Werror=pendantic -pedantic-errors)
@@ -73,6 +71,8 @@ foreach(SHARED_OPTION BUILD_TEST BUILD_BENCHMARK BUILD_EXAMPLE)
7371 set (${SHARED_OPTION} OFF )
7472endforeach ()
7573
74+ include (FetchContent )
75+
7676# This function checks to see if the download branch given by "branch" exists in the repository.
7777# It does so using the git ls-remote command.
7878# If the branch cannot be found, the variable described by "branch" is changed to "develop" in the host scope.
@@ -293,8 +293,6 @@ function(fetch_dep method repo_name repo_path download_branch)
293293 endif ()
294294endfunction ()
295295
296- include (cmake/FetchContentIsolated.cmake )
297-
298296# Test dependencies
299297if (USER_BUILD_TEST)
300298 # NOTE1: Google Test has created a mess with legacy FindGTest.cmake and newer GTestConfig.cmake
@@ -320,19 +318,21 @@ if(USER_BUILD_TEST)
320318 option (BUILD_GMOCK "Builds the googlemock subproject" OFF )
321319 option (INSTALL_GTEST "Enable installation of googletest." OFF )
322320 if (EXISTS /usr/src/googletest AND NOT EXTERNAL_DEPS_FORCE_DOWNLOAD)
323- set (GTEST_FETCH_ARGS SOURCE_DIR /usr/src/googletest)
321+ FetchContent_Declare (
322+ googletest
323+ SOURCE_DIR /usr/src/googletest
324+ )
324325 else ()
325326 message (STATUS "Google Test not found. Fetching..." )
326- set (GTEST_FETCH_ARGS
327- GIT_REPOSITORY https://github.com/google/googletest.git
328- GIT_TAG release-1.11.0
327+ FetchContent_Declare (
328+ googletest
329+ GIT_REPOSITORY https://github.com/google/googletest.git
330+ GIT_TAG release-1.11.0
329331 )
330332 endif ()
331- fetch_content_isolated (
332- googletest
333- ${GTEST_FETCH_ARGS}
334- CMAKE_ARGS -DBUILD_GTEST=ON -DBUILD_GMOCK=OFF -DINSTALL_GTEST=OFF
335- )
333+ set (_HIPCUB_DISABLE_ROCM_CHECKS TRUE )
334+ FetchContent_MakeAvailable (googletest)
335+ set (_HIPCUB_DISABLE_ROCM_CHECKS FALSE )
336336 add_library (GTest::GTest ALIAS gtest )
337337 add_library (GTest::Main ALIAS gtest_main )
338338 else ()
@@ -351,15 +351,18 @@ if(USER_BUILD_BENCHMARK)
351351 endif ()
352352 if (NOT TARGET benchmark::benchmark)
353353 message (STATUS "Google Benchmark not found. Fetching..." )
354- fetch_content_isolated (
354+ option (BENCHMARK_ENABLE_TESTING "Enable testing of the benchmark library." OFF )
355+ option (BENCHMARK_ENABLE_INSTALL "Enable installation of benchmark." OFF )
356+ FetchContent_Declare (
355357 googlebench
356358 GIT_REPOSITORY https://github.com/google/benchmark.git
357359 GIT_TAG v${BENCHMARK_VERSION}
358- CMAKE_ARGS -DBENCHMARK_ENABLE_TESTING=OFF
359- -DBENCHMARK_ENABLE_INSTALL=OFF
360- -DHAVE_STD_REGEX=ON
361- -DRUN_HAVE_STD_REGEX=1
362360 )
361+ set (HAVE_STD_REGEX ON )
362+ set (RUN_HAVE_STD_REGEX 1)
363+ set (_HIPCUB_DISABLE_ROCM_CHECKS TRUE )
364+ FetchContent_MakeAvailable (googlebench)
365+ set (_HIPCUB_DISABLE_ROCM_CHECKS FALSE )
363366 if (NOT TARGET benchmark::benchmark)
364367 add_library (benchmark::benchmark ALIAS benchmark )
365368 endif ()
@@ -410,11 +413,16 @@ else()
410413 if (${ROCPRIM_FETCH_METHOD} STREQUAL "DOWNLOAD" OR ${ROCPRIM_FETCH_METHOD} STREQUAL "MONOREPO" )
411414 # The fetch_dep call above should have downloaded/located the source. We just need to make it available.
412415 message (STATUS "Configuring rocPRIM" )
413- fetch_content_isolated (
416+ FetchContent_Declare (
414417 prim
415418 SOURCE_DIR ${ROCPRIM_PATH}
416- CMAKE_ARGS -DBUILD_TEST=OFF -DCMAKE_PREFIX_PATH=/opt/rocm
419+ INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR } /deps/rocprim
420+ CMAKE_ARGS -DBUILD_TEST=OFF -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR > -DCMAKE_PREFIX_PATH=/opt/rocm
421+ LOG_CONFIGURE TRUE
422+ LOG_BUILD TRUE
423+ LOG_INSTALL TRUE
417424 )
425+ FetchContent_MakeAvailable (prim)
418426 if (NOT TARGET roc::rocprim)
419427 add_library (roc::rocprim ALIAS rocprim )
420428 endif ()
0 commit comments