From 0e976223b08b56fac1013075ebd499047ef624f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Widera?= Date: Fri, 6 Aug 2021 10:24:03 +0200 Subject: [PATCH] cmake: use property list for GPU_TARGETS This PR deprecates the variable `AMDGPU_TARGETS`. To choose architectures it is required to set `GPU_TARGETS`. Before this PR `GPU_TARGETS` was set to `AMDGPU_TARGETS`. Calling `cmake` again with a new value for `AMDGPU_TARGETS` is not propagated to `GPU_TARGETS` therefore the user is building against the initially selected architecture which is not obvious. This PR - If the user is setting `AMD_GPU_TARGETS` in the **initial cmake call** e.g. `cmake -DAMDGPU_TARGETS=gfx908` a deprecation warning is thrown and the value of `AMDGPU_TARGETS` is assigned to `GPU_TARGETS` - `GPU_TARGETS` can be any time overwritten by a user-defined value which allows an expert user to select architecture features too, e.g. `cmake -DGPU_TARGETS=gfx908:xnack+` Co-authored-by: Paul Fultz II --- hip-config.cmake.in | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hip-config.cmake.in b/hip-config.cmake.in index 2edce6cd..48d0bb68 100755 --- a/hip-config.cmake.in +++ b/hip-config.cmake.in @@ -159,8 +159,14 @@ if(HIP_COMPILER STREQUAL "clang") if(NOT WIN32) find_dependency(AMDDeviceLibs) endif() - set(AMDGPU_TARGETS "gfx900;gfx906;gfx908;gfx90a;gfx1030" CACHE STRING "AMD GPU targets to compile for") - set(GPU_TARGETS "${AMDGPU_TARGETS}" CACHE STRING "GPU targets to compile for") + set(GPU_DEFAULT_TARGETS "gfx900;gfx906;gfx908;gfx90a;gfx1030") + + if(NOT DEFINED AMDGPU_TARGETS) + set(GPU_TARGETS "${GPU_DEFAULT_TARGETS}" CACHE STRING "GPU targets to compile for. Adding features is supported e.g. gfx908:xnack+") + else() + message(WARNING "Variable AMDGPU_TARGETS is deprecated! Please use GPU_TARGETS to choose architectures.") + set(GPU_TARGETS "${AMDGPU_TARGETS}" CACHE STRING "GPU targets to compile for. Adding features is supported e.g. gfx908:xnack+") + endif() endif() if(NOT WIN32)