diff options
author | Brad King <brad.king@kitware.com> | 2022-10-11 14:06:07 +0000 |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-10-11 10:06:27 -0400 |
commit | bfe2f1355739e64ab7a3d57f81052fcb0fcccdbc (patch) | |
tree | 9111c5ca41e508c083e94a3642ee675784125c14 | |
parent | c5cb85e42ff2f31ffbe3f2dac1ed8529e1c0a9db (diff) | |
parent | 5b87ae6e2d5154dc0adae15f9da92a6476de9be5 (diff) | |
download | cmake-bfe2f1355739e64ab7a3d57f81052fcb0fcccdbc.tar.gz |
Merge topic 'hip_windows_platform_module'
5b87ae6e2d HIP, Windows: Add Windows-Clang-HIP platform module
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7773
-rw-r--r-- | Modules/Platform/Windows-Clang-HIP.cmake | 19 | ||||
-rw-r--r-- | Modules/Platform/Windows-Clang.cmake | 45 |
2 files changed, 49 insertions, 15 deletions
diff --git a/Modules/Platform/Windows-Clang-HIP.cmake b/Modules/Platform/Windows-Clang-HIP.cmake new file mode 100644 index 0000000000..20879fabee --- /dev/null +++ b/Modules/Platform/Windows-Clang-HIP.cmake @@ -0,0 +1,19 @@ +include(Platform/Windows-Clang) +set(_COMPILE_HIP_MSVC " -TP") +__windows_compiler_clang(HIP) + +if("x${CMAKE_HIP_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC") + if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER) + AND CMAKE_GENERATOR MATCHES "Makefiles|WMake" + AND CMAKE_DEPFILE_FLAGS_HIP) + set(CMAKE_HIP_DEPENDS_USE_COMPILER TRUE) + endif() +elseif("x${CMAKE_HIP_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU") + if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER) + AND CMAKE_GENERATOR MATCHES "Makefiles|WMake" + AND CMAKE_DEPFILE_FLAGS_HIP) + # dependencies are computed by the compiler itself + set(CMAKE_HIP_DEPFILE_FORMAT gcc) + set(CMAKE_HIP_DEPENDS_USE_COMPILER TRUE) + endif() +endif() diff --git a/Modules/Platform/Windows-Clang.cmake b/Modules/Platform/Windows-Clang.cmake index 5edcb616a5..33d271de8e 100644 --- a/Modules/Platform/Windows-Clang.cmake +++ b/Modules/Platform/Windows-Clang.cmake @@ -157,24 +157,36 @@ macro(__enable_llvm_rc_preprocessing clang_option_prefix extra_pp_flags) endif() endmacro() +macro(__verify_same_language_values variable) + foreach(lang "C" "CXX" "HIP") + if(DEFINED CMAKE_${lang}_${variable}) + list(APPEND __LANGUAGE_VALUES_${variable} "${CMAKE_${lang}_${variable}}") + endif() + endforeach() + list(REMOVE_DUPLICATES __LANGUAGE_VALUES_${variable}) + list(LENGTH __LANGUAGE_VALUES_${variable} __NUM_VALUES) + + if(__NUM_VALUES GREATER 1) + message(FATAL_ERROR ${ARGN}) + endif() + unset(__NUM_VALUES) + unset(__LANGUAGE_VALUES_${variable}) +endmacro() if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" - OR "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") + OR "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC" + OR "x${CMAKE_HIP_SIMULATE_ID}" STREQUAL "xMSVC") - if ( DEFINED CMAKE_C_COMPILER_ID AND DEFINED CMAKE_CXX_COMPILER_ID - AND NOT "x${CMAKE_C_COMPILER_ID}" STREQUAL "x${CMAKE_CXX_COMPILER_ID}") - message(FATAL_ERROR "The current configuration mixes Clang and MSVC or " - "some other CL compatible compiler tool. This is not supported. " - "Use either clang or MSVC as both C and C++ compilers.") - endif() + __verify_same_language_values(COMPILER_ID + "The current configuration mixes Clang and MSVC or " + "some other CL compatible compiler tool. This is not supported. " + "Use either clang or MSVC as both C, C++ and/or HIP compilers.") - if ( DEFINED CMAKE_C_COMPILER_FRONTEND_VARIANT AND DEFINED CMAKE_CXX_COMPILER_FRONTEND_VARIANT - AND NOT "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}") - message(FATAL_ERROR "The current configuration uses the Clang compiler " - "tool with mixed frontend variants, both the GNU and in MSVC CL " - "like variants. This is not supported. Use either clang/clang++ " - "or clang-cl as both C and C++ compilers.") - endif() + __verify_same_language_values(COMPILER_FRONTEND_VARIANT + "The current configuration uses the Clang compiler " + "tool with mixed frontend variants, both the GNU and in MSVC CL " + "like variants. This is not supported. Use either clang/clang++ " + "or clang-cl as both C, C++ and/or HIP compilers.") if(NOT CMAKE_RC_COMPILER_INIT) # Check if rc is already in the path @@ -194,7 +206,10 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" unset(__RC_COMPILER_PATH CACHE) endif() - if ( "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC" OR "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC" ) + if ( "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC" + OR "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC" + OR "x${CMAKE_HIP_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC") + include(Platform/Windows-MSVC) # Set the clang option forwarding prefix for clang-cl usage in the llvm-rc processing stage __enable_llvm_rc_preprocessing("-clang:" "") |