Fix CMakePackage.define for libs/headers (#28838)

The 'libs' property returned by a spec is not a list nor tuple.

Closes #28836.
This commit is contained in:
Seth R. Johnson 2022-02-10 08:43:22 -05:00 committed by GitHub
parent fa38af285c
commit 92b26257f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -10,6 +10,9 @@
import re
from typing import List # novm
import six
from llnl.util.compat import Sequence
from llnl.util.filesystem import working_dir
import spack.build_environment
@ -222,7 +225,7 @@ def define(cmake_var, value):
value = "ON" if value else "OFF"
else:
kind = 'STRING'
if isinstance(value, (list, tuple)):
if isinstance(value, Sequence) and not isinstance(value, six.string_types):
value = ";".join(str(v) for v in value)
else:
value = str(value)

View File

@ -313,6 +313,9 @@ def test_define(self):
arg = pkg.define('MULTI', cls(['right', 'up']))
assert arg == '-DMULTI:STRING=right;up'
arg = pkg.define('MULTI', fs.FileList(['/foo', '/bar']))
assert arg == '-DMULTI:STRING=/foo;/bar'
arg = pkg.define('ENABLE_TRUTH', False)
assert arg == '-DENABLE_TRUTH:BOOL=OFF'
arg = pkg.define('ENABLE_TRUTH', True)