1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-14 02:08:27 +08:00

ROCMClang: Add the ROCm toolkit derived clang compiler to CMake

This commit is contained in:
Robert Maynard
2020-08-28 15:00:57 -04:00
committed by Zack Galbreath
parent 590553f322
commit bd844387df
12 changed files with 92 additions and 1 deletions

View File

@@ -34,6 +34,7 @@ include:
OpenWatcom = Open Watcom (openwatcom.org)
PGI = The Portland Group (pgroup.com)
PathScale = PathScale (pathscale.com)
ROCMClang = ROCm Toolkit Clang-based Compiler (rocmdocs.amd.com)
SDCC = Small Device C Compiler (sdcc.sourceforge.net)
SunPro = Oracle Solaris Studio (oracle.com)
TI = Texas Instruments (ti.com)

View File

@@ -81,6 +81,11 @@ function(compiler_id_detection outvar lang)
ARMCC
AppleClang
ARMClang
)
if(NOT __skip_rocmclang)
list(APPEND ordered_compilers ROCMClang)
endif()
list(APPEND ordered_compilers
Clang
GNU
MSVC

View File

@@ -150,7 +150,6 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
endif()
endif()
if (COMPILER_QNXNTO AND CMAKE_${lang}_COMPILER_ID STREQUAL "GNU")
execute_process(
COMMAND "${CMAKE_${lang}_COMPILER}"

View File

@@ -0,0 +1,2 @@
include(Compiler/ROCMClang)
__compiler_rocmclang(ASM)

View File

@@ -0,0 +1,7 @@
include(Compiler/ROCMClang)
__compiler_rocmclang(C)
set(_rocm_clang_ver "${CMAKE_C_COMPILER_VERSION_INTERNAL}")
set(CMAKE_C_COMPILER_VERSION "${CMAKE_C_COMPILER_VERSION_INTERNAL}")
include(Compiler/Clang-C)
set(CMAKE_C_COMPILER_VERSION "${_rocm_clang_ver}")

View File

@@ -0,0 +1,7 @@
include(Compiler/ROCMClang)
__compiler_rocmclang(CXX)
set(_rocm_clang_ver "${CMAKE_CXX_COMPILER_VERSION_INTERNAL}")
set(CMAKE_CXX_COMPILER_VERSION "${CMAKE_CXX_COMPILER_VERSION_INTERNAL}")
include(Compiler/Clang-CXX)
set(CMAKE_CXX_COMPILER_VERSION "${_rocm_clang_ver}")

View File

@@ -0,0 +1,19 @@
set(_compiler_id_pp_test "defined(__clang__) && __has_include(<hip/hip_version.h>)")
set(_compiler_id_version_compute "
# if defined(__clang__) && __has_include(<hip/hip_version.h>)
# include <hip/hip_version.h>
# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(HIP_VERSION_MAJOR)
# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(HIP_VERSION_MINOR)
# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(HIP_VERSION_PATCH)
# endif")
set(_compiler_id_simulate "
# if defined(_MSC_VER)
# define @PREFIX@SIMULATE_ID \"MSVC\"
# elif defined(__clang__)
# define @PREFIX@SIMULATE_ID \"Clang\"
# elif defined(__GNUC__)
# define @PREFIX@SIMULATE_ID \"GNU\"
# endif")

View File

@@ -0,0 +1 @@
include(Compiler/Clang-FindBinUtils)

View File

@@ -0,0 +1,7 @@
include(Compiler/ROCMClang)
__compiler_rocmclang(OBJC)
set(_rocm_clang_ver "${CMAKE_OBJC_COMPILER_VERSION_INTERNAL}")
set(CMAKE_OBJC_COMPILER_VERSION "${CMAKE_OBJC_COMPILER_VERSION_INTERNAL}")
include(Compiler/Clang-OBJC)
set(CMAKE_OBJC_COMPILER_VERSION "${_rocm_clang_ver}")

View File

@@ -0,0 +1,7 @@
include(Compiler/ROCMClang)
__compiler_rocmclang(OBJCXX)
set(_rocm_clang_ver "${CMAKE_OBJCXX_COMPILER_VERSION_INTERNAL}")
set(CMAKE_OBJCXX_COMPILER_VERSION "${CMAKE_OBJCXX_COMPILER_VERSION_INTERNAL}")
include(Compiler/Clang-OBJCXX)
set(CMAKE_OBJCXX_COMPILER_VERSION "${_rocm_clang_ver}")

View File

@@ -0,0 +1,35 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
# This module is shared by multiple languages; use include blocker.
include_guard()
include(Compiler/CMakeCommonCompilerMacros)
macro(__compiler_rocmclang lang)
set(CMAKE_${lang}_VERBOSE_FLAG "-v")
if(NOT "x${CMAKE_${lang}_SIMULATE_ID}" STREQUAL "xMSVC")
# Feature flags.
set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC")
set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE")
set(CMAKE_HIP_COMPILE_OPTIONS_VISIBILITY -fvisibility=)
string(APPEND CMAKE_HIP_FLAGS_INIT " ")
string(APPEND CMAKE_HIP_FLAGS_DEBUG_INIT " -g")
string(APPEND CMAKE_HIP_FLAGS_RELEASE_INIT " -O3 -DNDEBUG")
string(APPEND CMAKE_HIP_FLAGS_MINSIZEREL_INIT " -Os -DNDEBUG")
string(APPEND CMAKE_HIP_FLAGS_RELWITHDEBINFO_INIT " -O2 -g -DNDEBUG")
endif()
set(CMAKE_SHARED_LIBRARY_CREATE_HIP_FLAGS -shared)
set(CMAKE_INCLUDE_SYSTEM_FLAG_HIP "-isystem ")
set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_INCLUDES 1)
set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_LIBRARIES 1)
set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS 1)
set(CMAKE_${lang}_RESPONSE_FILE_FLAG "@")
set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "@")
endmacro()

View File

@@ -384,6 +384,7 @@ elseif(_WCDH_policy STREQUAL "")
)
endif()
set(__skip_rocmclang TRUE)
include(${CMAKE_CURRENT_LIST_DIR}/CMakeCompilerIdDetection.cmake)
function(_load_compiler_variables CompilerId lang)