From c2f228bca3b4a2dbd48955cd90aa3e2cf7c81938 Mon Sep 17 00:00:00 2001 From: Nate Brake <33383515+njbrake@users.noreply.github.com> Date: Wed, 11 Aug 2021 03:29:45 -0400 Subject: [PATCH] Add config flag (#251) * add flag 'config' * add config to options object * Update README.md * add paren to fix logic Co-authored-by: Yulong Wang Co-authored-by: Nate Brake --- README.md | 2 ++ bin/cmake-js | 9 ++++++++- lib/cMake.js | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 38f648ca..296d770a 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,8 @@ Options: -d, --directory specify CMake project's directory (where CMakeLists.txt located) [string] -D, --debug build debug configuration [boolean] + -B, --config specify build configuration (Debug, RelWithDebInfo, + Release), will ignore '--debug' if specified [string] -c, --cmake-path path of CMake executable [string] -m, --prefer-make use Unix Makefiles even if Ninja is available (Posix) [boolean] diff --git a/bin/cmake-js b/bin/cmake-js index 8e27ec02..39a4aadd 100755 --- a/bin/cmake-js +++ b/bin/cmake-js @@ -66,6 +66,12 @@ var yargs = require("yargs") describe: "build debug configuration", type: "boolean" }, + B: { + alias: "config", + demand: false, + describe: "specify build configuration (Debug, RelWithDebInfo, Release), will ignore '--debug' if specified", + type: "string" + }, c: { alias: "cmake-path", demand: false, @@ -212,7 +218,8 @@ var options = { arch: argv.a, cMakeOptions: customOptions, silent: argv.i, - out: argv.O + out: argv.O, + config: argv.B }; log.verbose("CON", "options:"); diff --git a/lib/cMake.js b/lib/cMake.js index 319e905b..2f81619f 100644 --- a/lib/cMake.js +++ b/lib/cMake.js @@ -20,7 +20,7 @@ function CMake(options) { this.dist = new Dist(this.options); this.projectRoot = path.resolve(this.options.directory || process.cwd()); this.workDir = path.resolve(this.options.out || path.join(this.projectRoot, "build")); - this.config = this.options.debug ? "Debug" : "Release"; + this.config = this.options.config || (this.options.debug ? "Debug" : "Release"); this.buildDir = path.join(this.workDir, this.config); this._isAvailable = null; this.targetOptions = new TargetOptions(this.options);