Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions share/rocmcmakebuildtools/cmake/ROCMCheckTargetIds.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,26 @@ function(_rocm_sanitize_target_id TARGET_ID VARIABLE)
# CMake defines a preprocessor macro with this value, so it must be a valid C identifier
# Handle + and - for xnack and sramecc so that e.g. xnack+ and xnack- doesn't get folded to
# the same string by MAKE_C_IDENTIFIER
string(REPLACE "_" "__" TARGET_ID "${TARGET_ID}")
string(REPLACE "+" "_on" TARGET_ID "${TARGET_ID}")
string(REPLACE "-" "_off" TARGET_ID "${TARGET_ID}")

# Target ID syntax:
# <target-id> ::== <processor> ( ":" <target-feature> ( "+" | "-" ) )*

# split target id by colon into a list of components
string(REPLACE ":" ";" _components "${TARGET_ID}")
list(GET _components 0 _processor)
list(REMOVE_AT _components 0)
# remove '-' from processor name
string(REPLACE "-" "_" _processor "${_processor}")
if(_components)
# remove '+' or '-' from target features
string(REPLACE "+" "_on" _components "${_components}")
string(REPLACE "-" "_off" _components "${_components}")
# join components with a colon
string(REPLACE ";" ":" TARGET_ID "${_processor}:${_components}")
else()
set(TARGET_ID "${_processor}")
endif()

string(MAKE_C_IDENTIFIER "${TARGET_ID}" TARGET_ID)
set(${VARIABLE} "${TARGET_ID}" PARENT_SCOPE)
endfunction()
Loading