Skip to content

Commit

Permalink
fix: parse CMake version strings containing '-' (#508)
Browse files Browse the repository at this point in the history
Uses a simple `str.split('-msvc')` to extract the version number.
`'-msvc'` in particular was chosen to allow for forwards-compatibility
with future builds of MSVC CMake. I did not check for older versions as
I do not expect they will be any less compatible and this is still an
improvement on the current situation of no compatibility at all.

In my opinion, splitting on `-` should be sufficient and provide
compatibility with any other builds of CMake with custom version
strings. However, I did not do this as I'm not familiar with all of the
possible builds of CMake out there and wanted to ensure functionality.

---
Update: Now parses using `str.split('-')` for extended compatibility.
Thanks @henryiii

---
Resolves: #500

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
  • Loading branch information
3 people authored Sep 20, 2023
1 parent 9466c8b commit 2ea7392
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/scikit_build_core/program_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def get_cmake_programs(*, module: bool = True) -> Generator[Program, None, None]
continue

try:
version = Version(result.stdout.splitlines()[0].split()[-1])
version = Version(result.stdout.splitlines()[0].split()[-1].split("-")[0])
except (IndexError, InvalidVersion):
logger.warning(f"Could not determine CMake version, got {result.stdout!r}")
yield Program(cmake_path, None)
Expand Down

0 comments on commit 2ea7392

Please sign in to comment.