Skip to content

Commit

Permalink
Fix a bug in cmake args parsing overrides (See scikit-build#342)
Browse files Browse the repository at this point in the history
  • Loading branch information
yonip committed Jul 26, 2018
1 parent 890d13b commit 464f1ad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion skbuild/cmaker.py
Expand Up @@ -61,7 +61,7 @@ def has_cmake_cache_arg(cmake_args, arg_name, arg_value=None):
"""Return True if ``-D<arg_name>:TYPE=<arg_value>`` is found
in ``cmake_args``. If ``arg_value`` is None, return True only if
``-D<arg_name>:`` is found in the list."""
for arg in cmake_args:
for arg in reverse(cmake_args):
if arg.startswith("-D%s:" % arg_name):
if arg_value is None:
return True
Expand Down
10 changes: 10 additions & 0 deletions tests/test_cmaker.py
Expand Up @@ -47,6 +47,16 @@ def test_has_cmake_cache_arg():
assert has_cmake_cache_arg(cmake_args, "CLIMBING", None)
assert has_cmake_cache_arg(cmake_args, "CLIMBING", "ON")

override = ['-DOTHER:STRING=C','-DOVERRIDE:STRING=A', '-DOVERRIDE:STRING=B']
assert has_cmake_cache_arg(override, 'OVERRIDE')
assert has_cmake_cache_arg(override, 'OVERRIDE', 'B')
assert not has_cmake_cache_arg(override, 'OVERRIDE', 'A')
# ensure overriding doesn't magically have side effects.
assert has_cmake_cache_arg(override, 'OTHER')
assert has_cmake_cache_arg(override, 'OTHER', 'C')
assert not has_cmake_cache_arg(override, 'OTHER', 'A')
assert not has_cmake_cache_arg(override, 'OTHER', 'B')


def test_make_without_build_dir_fails():
src_dir = _tmpdir('test_make_without_build_dir_fails')
Expand Down

0 comments on commit 464f1ad

Please sign in to comment.