Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CMake Compiler Flag Summary: ID Regex Matching #4272

Merged
merged 1 commit into from
Jan 22, 2025
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
6 changes: 3 additions & 3 deletions Tools/CMake/AMReXGenexHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ function ( eval_genex _list _lang _comp )
string(REGEX REPLACE "\\$<PLATFORM_ID:[A-Za-z]*>" "0" _in "${_in}")

# Genex in the form $<*_COMPILER_ID:compiler_ids>
string(REGEX REPLACE "\\$<${_lang}_COMPILER_ID:[^>]*${_comp}[^>]*>" "1" _in "${_in}")
string(REGEX REPLACE "\\$<${_lang}_COMPILER_ID[^>]*[:,]${_comp}[>,]" "1" _in "${_in}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you help me understand what the change in regex does for each part?

  • Does [:,] now match a literal : or ,?
  • Does [>,] now match a literal > or ,?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Does [:,] now match a literal : or ,?
  • Does [>,] now match a literal > or ,?

Yes to both, the idea is that we will now exactly (without prefixes or suffixes) match ${_comp} because it must be surrounded by commas (if it's in the middle of the list) or immediately follow the colon at the beginning of the list or immediately precede the chevron at the end of the list.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would also match $<CXX_COMPILER_ID,someid>, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, but that's illegal CMake syntax and will cause CMake to complain with "Expression did not evaluate to a known generator expression" or "Expression syntax not recognized."

string(REGEX REPLACE "\\$<[A-Za-z]*_COMPILER_ID:[A-Za-z]*>" "0" _in "${_in}")

# Genex in the form $<*_COMPILER_VERSION:version>
Expand All @@ -290,15 +290,15 @@ function ( eval_genex _list _lang _comp )
string(REGEX REPLACE "\\$<[A-Za-z]*_COMPILER_VERSION:[^\$>]*>" "0" _in "${_in}")

# Genex in the form $<COMPILE_LANG_AND_ID:language,compiler_ids>
string(REGEX REPLACE "\\$<COMPILE_LANG_AND_ID:${_lang},[^\$>]*${_comp}[^\$>]*>" "1" _in "${_in}")
string(REGEX REPLACE "\\$<COMPILE_LANG_AND_ID:${_lang}[^\$>]*,${_comp}[>,]" "1" _in "${_in}")
string(REGEX REPLACE "\\$<COMPILE_LANG_AND_ID:[A-Za-z,]*>" "0" _in "${_in}")

# Genex in the form $<COMPILE_LANGUAGE:languages>
string(REGEX REPLACE "\\$<COMPILE_LANGUAGE:[^\$>]*${_lang}[^\$>]*>" "1" _in "${_in}")
string(REGEX REPLACE "\\$<COMPILE_LANGUAGE:[A-Za-z]*>" "0" _in "${_in}")

# Genex in the form $<LINK_LANGUAGE_AND_ID:language,compiler_ids>
string(REGEX REPLACE "\\$<LINK_LANGUAGE_AND_ID:${_lang},[^\$>]*${_comp}[^\$>]*>" "1" _in "${_in}")
string(REGEX REPLACE "\\$<LINK_LANGUAGE_AND_ID:${_lang}[^\$>]*,${_comp}[>,]" "1" _in "${_in}")
string(REGEX REPLACE "\\$<LINK_LANGUAGE_AND_ID:[A-Za-z,]*>" "0" _in "${_in}")

# Genex in the form $<LINK_LANGUAGE:languages>
Expand Down
Loading