llnl / llnl/blt

blt_append_custom_compiler_flag macro should support list parameters

Open
#314 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

design flags
Dominant language
C++
Stars
296
Forks
66
Avg merge
1h 3m
Merged PRs (30d)
1

Description

Our flag related macros have recently been unified to operate on lists (#305),
but our macro to generate flags -- ``blt_append_custom_compiler_flag`` -- only operates on strings, and the results are not directly compatible with our flag-related macros.

E.g. I'd expect the following to work:
```cmake
blt_append_custom_compiler_flag(FLAGS_VAR _flags
DEFAULT " "
GNU "string-flag1 string-flag2" # space-delimited
CLANG list-flag1 list-flag2 # list
MSVC single )
blt_add_target_compile_flags(TO SCOPE FLAGS ${_flags})
```
But, since the arguments to ``blt_append_custom_compiler_flag`` are strings rather than list (i.e. ``singleValuedArgs`` in our macro, rather than ``multiValuedArgs``), only the first flag is used.

Note: I was able to get my example working (after some effort), but it is not as simple or obvious as it can be:

```cmake
# Current workaround
blt_append_custom_compiler_flag(FLAGS_VAR _flags
DEFAULT " "
GNU "string-flag1 string-flag2"
CLANG "string-flag3 string-flag4"
MSVC single )
string (REPLACE " " ";" _flags "${_flags}")
blt_add_target_compile_flags(TO SCOPE FLAGS ${_flags})
```
Note: This only works for space-delimited strings and requires a manual conversion from strings to lists.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the blt_append_custom_compiler_flag macro and the flag-related macro tests or examples. Start by tracing how GNU, CLANG, MSVC, and DEFAULT arguments are parsed, then verify that space-delimited strings and list-valued arguments produce flags usable by blt_add_target_compile_flags; done means the manual string-to-list conversion is no longer required.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake
Domain
build-system
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.