Skip to content

Add -G command line option to specify generator #64

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 9 commits into from
Nov 15, 2016
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions bin/cmake-js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ var yargs = require("yargs")
describe: "use GNU compiler instead of default CMake compiler, if available (Posix)",
type: "boolean"
},
G: {
alias: "generator",
demand: false,
describe: "use specified generator",
type: "string"
},
C: {
alias: "prefer-clang",
demand: false,
Expand Down Expand Up @@ -157,6 +163,7 @@ var options = {
directory: argv.directory || null,
debug: argv.debug,
cmakePath: argv.c || null,
generator: argv.G,
preferMake: argv.m,
preferXcode: argv.x,
preferGnu: argv.g,
Expand Down
17 changes: 15 additions & 2 deletions lib/es5/toolset.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 16 additions & 4 deletions lib/es6/toolset.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let CMLog = require("./cmLog");
function Toolset(options) {
this.options = options || {};
this.targetOptions = new TargetOptions(this.options);
this.generator = null;
this.generator = options.generator;
this.cCompilerPath = null;
this.cppCompilerPath = null;
this.compilerFlags = [];
Expand Down Expand Up @@ -59,9 +59,14 @@ Toolset.prototype.initializePosix = function (install) {
this.cppCompilerPath = "g++";
this.cCompilerPath = "gcc";
}

// if it's already set because of options...
if (this.generator) {
if (install) {
this.log.info("TOOL", "Using " + this.options.generator + " generator, as specified from commandline.");
}
}
// 2: Generator
if (environment.isOSX) {
else if (environment.isOSX) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't put generator override code at this point. Let toolset find its defaults and then, after initialize() around line 34, we should override the default value by logging out the exact information about which default generator got changed into which one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured it was pretty silly to do any sort of work to determine a default if it was already specified externally.

if (this.options.preferXcode) {
if (install) {
this.log.info("TOOL", "Using Xcode generator, because preferXcode option is set.");
Expand Down Expand Up @@ -144,6 +149,13 @@ Toolset.prototype._setupGNUStd = function (install) {

Toolset.prototype.initializeWin = async(function*(install) {
// Visual Studio:
// if it's already set because of options...
if (this.generator) {
if (install) {
this.log.info("TOOL", "Using " + this.options.generator + " generator, as specified from commandline.");
}
return;
}
let topVS = yield this._getTopSupportedVisualStudioGenerator();
//if (!this.options.noMSVC) {
if (topVS) {
Expand Down Expand Up @@ -184,4 +196,4 @@ Toolset.prototype._getTopSupportedVisualStudioGenerator = async(function*() {
return result;
});

module.exports = Toolset;
module.exports = Toolset;