From 814b1c81cfee97bcc6a93f276bab092a843e2468 Mon Sep 17 00:00:00 2001 From: "Godavarthy Surya, Anusha" Date: Thu, 5 Jun 2025 15:30:33 +0530 Subject: [PATCH] SWDEV-530015 - Override ROCM_PATH with env if it is set (#171) --- samples/0_Intro/bit_extract/CMakeLists.txt | 7 +++++-- samples/0_Intro/generic_target/CMakeLists.txt | 6 +++++- samples/0_Intro/module_api/CMakeLists.txt | 6 +++++- samples/0_Intro/module_api_global/CMakeLists.txt | 6 +++++- samples/0_Intro/square/CMakeLists.txt | 6 +++++- samples/1_Utils/hipDispatchLatency/CMakeLists.txt | 6 +++++- samples/1_Utils/hipInfo/CMakeLists.txt | 6 +++++- samples/2_Cookbook/0_MatrixTranspose/CMakeLists.txt | 6 +++++- samples/2_Cookbook/10_inline_asm/CMakeLists.txt | 6 +++++- samples/2_Cookbook/11_texture_driver/CMakeLists.txt | 6 +++++- .../2_Cookbook/12_cmake_hip_add_executable/CMakeLists.txt | 6 +++++- samples/2_Cookbook/13_occupancy/CMakeLists.txt | 6 +++++- samples/2_Cookbook/14_gpu_arch/CMakeLists.txt | 6 +++++- .../15_static_library/device_functions/CMakeLists.txt | 6 +++++- .../15_static_library/host_functions/CMakeLists.txt | 6 +++++- .../2_Cookbook/16_assembly_to_executable/CMakeLists.txt | 6 +++++- samples/2_Cookbook/17_llvm_ir_to_executable/CMakeLists.txt | 6 +++++- samples/2_Cookbook/18_cmake_hip_device/CMakeLists.txt | 6 +++++- samples/2_Cookbook/19_cmake_lang/CMakeLists.txt | 6 +++++- samples/2_Cookbook/1_hipEvent/CMakeLists.txt | 6 +++++- samples/2_Cookbook/21_cmake_hip_cxx_clang/CMakeLists.txt | 6 +++++- samples/2_Cookbook/23_cmake_hiprtc/CMakeLists.txt | 6 +++++- samples/2_Cookbook/3_shared_memory/CMakeLists.txt | 6 +++++- samples/2_Cookbook/4_shfl/CMakeLists.txt | 6 +++++- samples/2_Cookbook/5_2dshfl/CMakeLists.txt | 6 +++++- samples/2_Cookbook/6_dynamic_shared/CMakeLists.txt | 6 +++++- samples/2_Cookbook/7_streams/CMakeLists.txt | 6 +++++- samples/2_Cookbook/8_peer2peer/CMakeLists.txt | 6 +++++- samples/2_Cookbook/9_unroll/CMakeLists.txt | 6 +++++- 29 files changed, 145 insertions(+), 30 deletions(-) diff --git a/samples/0_Intro/bit_extract/CMakeLists.txt b/samples/0_Intro/bit_extract/CMakeLists.txt index 602b43297d..99813f0b7f 100644 --- a/samples/0_Intro/bit_extract/CMakeLists.txt +++ b/samples/0_Intro/bit_extract/CMakeLists.txt @@ -32,12 +32,15 @@ endif() if(UNIX) if(NOT DEFINED ROCM_PATH) - set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + if(DEFINED ENV{ROCM_PATH}) + set(ROCM_PATH $ENV{ROCM_PATH} CACHE STRING "ROCM Path") + else() + set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + endif() endif() # Search for rocm in common locations list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}) endif() - # Find hip find_package(hip) diff --git a/samples/0_Intro/generic_target/CMakeLists.txt b/samples/0_Intro/generic_target/CMakeLists.txt index 9c94f8d72b..5a6c02af2f 100644 --- a/samples/0_Intro/generic_target/CMakeLists.txt +++ b/samples/0_Intro/generic_target/CMakeLists.txt @@ -24,7 +24,11 @@ project(generic_target) if(UNIX) if(NOT DEFINED ROCM_PATH) - set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + if(DEFINED ENV{ROCM_PATH}) + set(ROCM_PATH $ENV{ROCM_PATH} CACHE STRING "ROCM Path") + else() + set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + endif() endif() # Search for rocm in common locations list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}) diff --git a/samples/0_Intro/module_api/CMakeLists.txt b/samples/0_Intro/module_api/CMakeLists.txt index be1855f521..9200a309c2 100644 --- a/samples/0_Intro/module_api/CMakeLists.txt +++ b/samples/0_Intro/module_api/CMakeLists.txt @@ -26,7 +26,11 @@ include_directories(../../common) if(UNIX) if(NOT DEFINED ROCM_PATH) - set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + if(DEFINED ENV{ROCM_PATH}) + set(ROCM_PATH $ENV{ROCM_PATH} CACHE STRING "ROCM Path") + else() + set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + endif() endif() # Search for rocm in common locations list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}) diff --git a/samples/0_Intro/module_api_global/CMakeLists.txt b/samples/0_Intro/module_api_global/CMakeLists.txt index 4f9cc60b8d..be0d8960a9 100644 --- a/samples/0_Intro/module_api_global/CMakeLists.txt +++ b/samples/0_Intro/module_api_global/CMakeLists.txt @@ -24,7 +24,11 @@ cmake_minimum_required(VERSION 3.10) if(UNIX) if(NOT DEFINED ROCM_PATH) - set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + if(DEFINED ENV{ROCM_PATH}) + set(ROCM_PATH $ENV{ROCM_PATH} CACHE STRING "ROCM Path") + else() + set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + endif() endif() # Search for rocm in common locations list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}) diff --git a/samples/0_Intro/square/CMakeLists.txt b/samples/0_Intro/square/CMakeLists.txt index 9695401f2b..ef707bbaaf 100644 --- a/samples/0_Intro/square/CMakeLists.txt +++ b/samples/0_Intro/square/CMakeLists.txt @@ -26,7 +26,11 @@ cmake_minimum_required(VERSION 3.10) if(UNIX) if(NOT DEFINED ROCM_PATH) - set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + if(DEFINED ENV{ROCM_PATH}) + set(ROCM_PATH $ENV{ROCM_PATH} CACHE STRING "ROCM Path") + else() + set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + endif() endif() # Search for rocm in common locations list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}) diff --git a/samples/1_Utils/hipDispatchLatency/CMakeLists.txt b/samples/1_Utils/hipDispatchLatency/CMakeLists.txt index 2019ceeac6..1b39747e90 100644 --- a/samples/1_Utils/hipDispatchLatency/CMakeLists.txt +++ b/samples/1_Utils/hipDispatchLatency/CMakeLists.txt @@ -26,7 +26,11 @@ include_directories(../../common) if(UNIX) if(NOT DEFINED ROCM_PATH) - set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + if(DEFINED ENV{ROCM_PATH}) + set(ROCM_PATH $ENV{ROCM_PATH} CACHE STRING "ROCM Path") + else() + set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + endif() endif() # Search for rocm in common locations list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}) diff --git a/samples/1_Utils/hipInfo/CMakeLists.txt b/samples/1_Utils/hipInfo/CMakeLists.txt index f17d4e4bcd..1ae1a40c88 100644 --- a/samples/1_Utils/hipInfo/CMakeLists.txt +++ b/samples/1_Utils/hipInfo/CMakeLists.txt @@ -28,7 +28,11 @@ project(hipInfo) cmake_minimum_required(VERSION 3.10) if(UNIX) if(NOT DEFINED ROCM_PATH) - set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + if(DEFINED ENV{ROCM_PATH}) + set(ROCM_PATH $ENV{ROCM_PATH} CACHE STRING "ROCM Path") + else() + set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + endif() endif() # Search for rocm in common locations list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}) diff --git a/samples/2_Cookbook/0_MatrixTranspose/CMakeLists.txt b/samples/2_Cookbook/0_MatrixTranspose/CMakeLists.txt index 6b5e4a24bd..13403584b5 100644 --- a/samples/2_Cookbook/0_MatrixTranspose/CMakeLists.txt +++ b/samples/2_Cookbook/0_MatrixTranspose/CMakeLists.txt @@ -24,7 +24,11 @@ cmake_minimum_required(VERSION 3.10) if(UNIX) if(NOT DEFINED ROCM_PATH) - set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + if(DEFINED ENV{ROCM_PATH}) + set(ROCM_PATH $ENV{ROCM_PATH} CACHE STRING "ROCM Path") + else() + set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + endif() endif() # Search for rocm in common locations list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}) diff --git a/samples/2_Cookbook/10_inline_asm/CMakeLists.txt b/samples/2_Cookbook/10_inline_asm/CMakeLists.txt index 0736bacf0d..3cef44e5d4 100644 --- a/samples/2_Cookbook/10_inline_asm/CMakeLists.txt +++ b/samples/2_Cookbook/10_inline_asm/CMakeLists.txt @@ -24,7 +24,11 @@ cmake_minimum_required(VERSION 3.10) if(UNIX) if(NOT DEFINED ROCM_PATH) - set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + if(DEFINED ENV{ROCM_PATH}) + set(ROCM_PATH $ENV{ROCM_PATH} CACHE STRING "ROCM Path") + else() + set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + endif() endif() # Search for rocm in common locations list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}) diff --git a/samples/2_Cookbook/11_texture_driver/CMakeLists.txt b/samples/2_Cookbook/11_texture_driver/CMakeLists.txt index 83d87a184f..8e78b3ebb3 100644 --- a/samples/2_Cookbook/11_texture_driver/CMakeLists.txt +++ b/samples/2_Cookbook/11_texture_driver/CMakeLists.txt @@ -24,7 +24,11 @@ cmake_minimum_required(VERSION 3.10) if(UNIX) if(NOT DEFINED ROCM_PATH) - set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + if(DEFINED ENV{ROCM_PATH}) + set(ROCM_PATH $ENV{ROCM_PATH} CACHE STRING "ROCM Path") + else() + set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + endif() endif() # Search for rocm in common locations list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}) diff --git a/samples/2_Cookbook/12_cmake_hip_add_executable/CMakeLists.txt b/samples/2_Cookbook/12_cmake_hip_add_executable/CMakeLists.txt index b7114d5853..1a8a744c7a 100644 --- a/samples/2_Cookbook/12_cmake_hip_add_executable/CMakeLists.txt +++ b/samples/2_Cookbook/12_cmake_hip_add_executable/CMakeLists.txt @@ -21,7 +21,11 @@ cmake_minimum_required(VERSION 3.10) if(UNIX) if(NOT DEFINED ROCM_PATH) - set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + if(DEFINED ENV{ROCM_PATH}) + set(ROCM_PATH $ENV{ROCM_PATH} CACHE STRING "ROCM Path") + else() + set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + endif() endif() endif() diff --git a/samples/2_Cookbook/13_occupancy/CMakeLists.txt b/samples/2_Cookbook/13_occupancy/CMakeLists.txt index 041f4e2663..134dc62e51 100644 --- a/samples/2_Cookbook/13_occupancy/CMakeLists.txt +++ b/samples/2_Cookbook/13_occupancy/CMakeLists.txt @@ -24,7 +24,11 @@ cmake_minimum_required(VERSION 3.10) if(UNIX) if(NOT DEFINED ROCM_PATH) - set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + if(DEFINED ENV{ROCM_PATH}) + set(ROCM_PATH $ENV{ROCM_PATH} CACHE STRING "ROCM Path") + else() + set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + endif() endif() # Search for rocm in common locations list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}) diff --git a/samples/2_Cookbook/14_gpu_arch/CMakeLists.txt b/samples/2_Cookbook/14_gpu_arch/CMakeLists.txt index c22bd63e37..908cc9f254 100644 --- a/samples/2_Cookbook/14_gpu_arch/CMakeLists.txt +++ b/samples/2_Cookbook/14_gpu_arch/CMakeLists.txt @@ -24,7 +24,11 @@ cmake_minimum_required(VERSION 3.10) if(UNIX) if(NOT DEFINED ROCM_PATH) - set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + if(DEFINED ENV{ROCM_PATH}) + set(ROCM_PATH $ENV{ROCM_PATH} CACHE STRING "ROCM Path") + else() + set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + endif() endif() # Search for rocm in common locations list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}) diff --git a/samples/2_Cookbook/15_static_library/device_functions/CMakeLists.txt b/samples/2_Cookbook/15_static_library/device_functions/CMakeLists.txt index f4e66ca80c..f4b7305bb1 100644 --- a/samples/2_Cookbook/15_static_library/device_functions/CMakeLists.txt +++ b/samples/2_Cookbook/15_static_library/device_functions/CMakeLists.txt @@ -4,7 +4,11 @@ cmake_minimum_required(VERSION 3.10) if(UNIX) if(NOT DEFINED ROCM_PATH) - set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + if(DEFINED ENV{ROCM_PATH}) + set(ROCM_PATH $ENV{ROCM_PATH} CACHE STRING "ROCM Path") + else() + set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + endif() endif() # Search for rocm in common locations list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}) diff --git a/samples/2_Cookbook/15_static_library/host_functions/CMakeLists.txt b/samples/2_Cookbook/15_static_library/host_functions/CMakeLists.txt index 23501f6ddf..28e4bf9695 100644 --- a/samples/2_Cookbook/15_static_library/host_functions/CMakeLists.txt +++ b/samples/2_Cookbook/15_static_library/host_functions/CMakeLists.txt @@ -4,7 +4,11 @@ cmake_minimum_required(VERSION 3.10) if(UNIX) if(NOT DEFINED ROCM_PATH) - set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + if(DEFINED ENV{ROCM_PATH}) + set(ROCM_PATH $ENV{ROCM_PATH} CACHE STRING "ROCM Path") + else() + set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + endif() endif() # Search for rocm in common locations list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}) diff --git a/samples/2_Cookbook/16_assembly_to_executable/CMakeLists.txt b/samples/2_Cookbook/16_assembly_to_executable/CMakeLists.txt index de70fc1209..d72ed65b85 100644 --- a/samples/2_Cookbook/16_assembly_to_executable/CMakeLists.txt +++ b/samples/2_Cookbook/16_assembly_to_executable/CMakeLists.txt @@ -4,7 +4,11 @@ cmake_minimum_required(VERSION 3.10) if(UNIX) if(NOT DEFINED ROCM_PATH) - set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + if(DEFINED ENV{ROCM_PATH}) + set(ROCM_PATH $ENV{ROCM_PATH} CACHE STRING "ROCM Path") + else() + set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + endif() endif() if(NOT DEFINED HIP_PATH) if(NOT DEFINED ENV{HIP_PATH}) diff --git a/samples/2_Cookbook/17_llvm_ir_to_executable/CMakeLists.txt b/samples/2_Cookbook/17_llvm_ir_to_executable/CMakeLists.txt index f2142559ad..4909e07a61 100644 --- a/samples/2_Cookbook/17_llvm_ir_to_executable/CMakeLists.txt +++ b/samples/2_Cookbook/17_llvm_ir_to_executable/CMakeLists.txt @@ -4,7 +4,11 @@ cmake_minimum_required(VERSION 3.10) if(UNIX) if(NOT DEFINED ROCM_PATH) - set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + if(DEFINED ENV{ROCM_PATH}) + set(ROCM_PATH $ENV{ROCM_PATH} CACHE STRING "ROCM Path") + else() + set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + endif() endif() if(NOT DEFINED HIP_PATH) if(NOT DEFINED ENV{HIP_PATH}) diff --git a/samples/2_Cookbook/18_cmake_hip_device/CMakeLists.txt b/samples/2_Cookbook/18_cmake_hip_device/CMakeLists.txt index 2bf28bef37..3cbebb2426 100644 --- a/samples/2_Cookbook/18_cmake_hip_device/CMakeLists.txt +++ b/samples/2_Cookbook/18_cmake_hip_device/CMakeLists.txt @@ -26,7 +26,11 @@ include_directories(../../common) if(UNIX) if(NOT DEFINED ROCM_PATH) - set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + if(DEFINED ENV{ROCM_PATH}) + set(ROCM_PATH $ENV{ROCM_PATH} CACHE STRING "ROCM Path") + else() + set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + endif() endif() # Search for rocm in common locations list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}) diff --git a/samples/2_Cookbook/19_cmake_lang/CMakeLists.txt b/samples/2_Cookbook/19_cmake_lang/CMakeLists.txt index b8dc368666..08f79e90f5 100644 --- a/samples/2_Cookbook/19_cmake_lang/CMakeLists.txt +++ b/samples/2_Cookbook/19_cmake_lang/CMakeLists.txt @@ -9,7 +9,11 @@ project(cmake_lang_test CXX Fortran) if(UNIX) if(NOT DEFINED ROCM_PATH) - set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + if(DEFINED ENV{ROCM_PATH}) + set(ROCM_PATH $ENV{ROCM_PATH} CACHE STRING "ROCM Path") + else() + set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + endif() endif() # Search for rocm in common locations list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}) diff --git a/samples/2_Cookbook/1_hipEvent/CMakeLists.txt b/samples/2_Cookbook/1_hipEvent/CMakeLists.txt index 71837e05df..0ccb18973f 100644 --- a/samples/2_Cookbook/1_hipEvent/CMakeLists.txt +++ b/samples/2_Cookbook/1_hipEvent/CMakeLists.txt @@ -24,7 +24,11 @@ cmake_minimum_required(VERSION 3.10) if(UNIX) if(NOT DEFINED ROCM_PATH) - set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + if(DEFINED ENV{ROCM_PATH}) + set(ROCM_PATH $ENV{ROCM_PATH} CACHE STRING "ROCM Path") + else() + set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + endif() endif() # Search for rocm in common locations list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}) diff --git a/samples/2_Cookbook/21_cmake_hip_cxx_clang/CMakeLists.txt b/samples/2_Cookbook/21_cmake_hip_cxx_clang/CMakeLists.txt index 79a8154c02..923683d979 100644 --- a/samples/2_Cookbook/21_cmake_hip_cxx_clang/CMakeLists.txt +++ b/samples/2_Cookbook/21_cmake_hip_cxx_clang/CMakeLists.txt @@ -26,7 +26,11 @@ project(cmake_cxx_amdclang++_test if(UNIX) if(NOT DEFINED ROCM_PATH) - set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + if(DEFINED ENV{ROCM_PATH}) + set(ROCM_PATH $ENV{ROCM_PATH} CACHE STRING "ROCM Path") + else() + set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + endif() endif() # Search for rocm in common locations list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}) diff --git a/samples/2_Cookbook/23_cmake_hiprtc/CMakeLists.txt b/samples/2_Cookbook/23_cmake_hiprtc/CMakeLists.txt index 882303e867..48bd7eaf0a 100644 --- a/samples/2_Cookbook/23_cmake_hiprtc/CMakeLists.txt +++ b/samples/2_Cookbook/23_cmake_hiprtc/CMakeLists.txt @@ -24,7 +24,11 @@ cmake_minimum_required(VERSION 3.10.2) if(UNIX) if(NOT DEFINED ROCM_PATH) - set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + if(DEFINED ENV{ROCM_PATH}) + set(ROCM_PATH $ENV{ROCM_PATH} CACHE STRING "ROCM Path") + else() + set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + endif() endif() # Search for rocm in common locations list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}) diff --git a/samples/2_Cookbook/3_shared_memory/CMakeLists.txt b/samples/2_Cookbook/3_shared_memory/CMakeLists.txt index f0edececb0..0296e97a36 100644 --- a/samples/2_Cookbook/3_shared_memory/CMakeLists.txt +++ b/samples/2_Cookbook/3_shared_memory/CMakeLists.txt @@ -24,7 +24,11 @@ cmake_minimum_required(VERSION 3.10) if(UNIX) if(NOT DEFINED ROCM_PATH) - set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + if(DEFINED ENV{ROCM_PATH}) + set(ROCM_PATH $ENV{ROCM_PATH} CACHE STRING "ROCM Path") + else() + set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + endif() endif() # Search for rocm in common locations list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}) diff --git a/samples/2_Cookbook/4_shfl/CMakeLists.txt b/samples/2_Cookbook/4_shfl/CMakeLists.txt index 39688104f2..a7eb19cb8d 100644 --- a/samples/2_Cookbook/4_shfl/CMakeLists.txt +++ b/samples/2_Cookbook/4_shfl/CMakeLists.txt @@ -24,7 +24,11 @@ cmake_minimum_required(VERSION 3.10) if(UNIX) if(NOT DEFINED ROCM_PATH) - set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + if(DEFINED ENV{ROCM_PATH}) + set(ROCM_PATH $ENV{ROCM_PATH} CACHE STRING "ROCM Path") + else() + set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + endif() endif() # Search for rocm in common locations list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}) diff --git a/samples/2_Cookbook/5_2dshfl/CMakeLists.txt b/samples/2_Cookbook/5_2dshfl/CMakeLists.txt index 5a2be43d0e..41efb39446 100644 --- a/samples/2_Cookbook/5_2dshfl/CMakeLists.txt +++ b/samples/2_Cookbook/5_2dshfl/CMakeLists.txt @@ -24,7 +24,11 @@ cmake_minimum_required(VERSION 3.10) if(UNIX) if(NOT DEFINED ROCM_PATH) - set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + if(DEFINED ENV{ROCM_PATH}) + set(ROCM_PATH $ENV{ROCM_PATH} CACHE STRING "ROCM Path") + else() + set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + endif() endif() # Search for rocm in common locations list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}) diff --git a/samples/2_Cookbook/6_dynamic_shared/CMakeLists.txt b/samples/2_Cookbook/6_dynamic_shared/CMakeLists.txt index 0431adacef..4038c03fd7 100644 --- a/samples/2_Cookbook/6_dynamic_shared/CMakeLists.txt +++ b/samples/2_Cookbook/6_dynamic_shared/CMakeLists.txt @@ -26,7 +26,11 @@ include_directories(../../common) if(UNIX) if(NOT DEFINED ROCM_PATH) - set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + if(DEFINED ENV{ROCM_PATH}) + set(ROCM_PATH $ENV{ROCM_PATH} CACHE STRING "ROCM Path") + else() + set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + endif() endif() # Search for rocm in common locations list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}) diff --git a/samples/2_Cookbook/7_streams/CMakeLists.txt b/samples/2_Cookbook/7_streams/CMakeLists.txt index 9525fecf93..ddee48de81 100644 --- a/samples/2_Cookbook/7_streams/CMakeLists.txt +++ b/samples/2_Cookbook/7_streams/CMakeLists.txt @@ -24,7 +24,11 @@ cmake_minimum_required(VERSION 3.10) if(UNIX) if(NOT DEFINED ROCM_PATH) - set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + if(DEFINED ENV{ROCM_PATH}) + set(ROCM_PATH $ENV{ROCM_PATH} CACHE STRING "ROCM Path") + else() + set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + endif() endif() # Search for rocm in common locations list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}) diff --git a/samples/2_Cookbook/8_peer2peer/CMakeLists.txt b/samples/2_Cookbook/8_peer2peer/CMakeLists.txt index 9f4e4225f0..edad1f4998 100644 --- a/samples/2_Cookbook/8_peer2peer/CMakeLists.txt +++ b/samples/2_Cookbook/8_peer2peer/CMakeLists.txt @@ -24,7 +24,11 @@ cmake_minimum_required(VERSION 3.10) if(UNIX) if(NOT DEFINED ROCM_PATH) - set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + if(DEFINED ENV{ROCM_PATH}) + set(ROCM_PATH $ENV{ROCM_PATH} CACHE STRING "ROCM Path") + else() + set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + endif() endif() # Search for rocm in common locations list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}) diff --git a/samples/2_Cookbook/9_unroll/CMakeLists.txt b/samples/2_Cookbook/9_unroll/CMakeLists.txt index be6b1e5644..0e6eeb8203 100644 --- a/samples/2_Cookbook/9_unroll/CMakeLists.txt +++ b/samples/2_Cookbook/9_unroll/CMakeLists.txt @@ -24,7 +24,11 @@ cmake_minimum_required(VERSION 3.10) if(UNIX) if(NOT DEFINED ROCM_PATH) - set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + if(DEFINED ENV{ROCM_PATH}) + set(ROCM_PATH $ENV{ROCM_PATH} CACHE STRING "ROCM Path") + else() + set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + endif() endif() # Search for rocm in common locations list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH})