Skip to content

Query CMake capabilities for generator detection (#158) #159

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

Merged
merged 1 commit into from
Feb 14, 2019
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
10 changes: 10 additions & 0 deletions lib/es6/cMake.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ CMake.getGenerators = async(function* (options) {
options = options || {};
let gens = [];
if (CMake.isAvailable(options)) {
// try parsing machine-readable capabilities (available since CMake 3.7)
try {
let stdout = yield processHelpers.exec((options.cmakePath || "cmake") + " -E capabilities");
let capabilities = JSON.parse(stdout);
return capabilities.generators.map(x => x.name);
} catch (error) {
this.log.verbose("TOOL", "Failed to query CMake capabilities (CMake is probably older than 3.7)");
}

// fall back to parsing help text
let stdout = yield processHelpers.exec((options.cmakePath || "cmake") + " --help");
let hasCr = stdout.includes("\r\n");
let output = hasCr ? stdout.split("\r\n") : stdout.split("\n");
Expand Down