Skip to content
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

feat: Forward extra arguments to CMake commands #297

Merged
merged 2 commits into from Feb 12, 2023

Conversation

trxcllnt
Copy link
Contributor

@trxcllnt trxcllnt commented Feb 4, 2023

Partial duplicate of #235, except this PR:

  • passes all yargs' unknown args to cmake (the ones after --)
  • forwards args for all the basic commands (clean/configure/build)
    • does not forward args for composite commands (compile/rebuild/reconfigure)

Examples why this is nice:

# Handy to help track down configuration issues
npx cmake-js configure -- --debug-find-pkg=Foo --trace-source=FindFoo.cmake
# yields:
#   cmake {-D args...} --debug-find-pkg=Foo --trace-source=FindFoo.cmake

# For when you just need to rebuild a single target
# Note: needs the double "--" (one for yargs, the other for CMake)
npx cmake-js build -- -- CMakeFiles/my_lib.dir/my_src.cpp.o
#  yields:
#   cmake --build build --config Release -- CMakeFiles/my_lib.dir/my_src.cpp.o

# Remove additional dirs on clean
npx cmake-js clean -- .cache /tmp/jest_rs
# yields:
#   cmake -E remove_directory ./build .cache /tmp/jest_rs

And can be paired with -- in package.json npm scripts to forward args mostly* without extra --:

# package.json
# {
#   "scripts": {
#     "cpp:clean": "cmake-js clean -O build/Release --",
#     "cpp:build": "cmake-js -g build -O build/Release --",
#     "cpp:configure": "cmake-js -g configure -O build/Release --",
#   }
# }

yarn cpp:clean .cache /tmp/jest_rs
npm run cpp:clean -- .cache /tmp/jest_rs

yarn cpp:configure --debug-find-pkg=Foo --trace-source=FindFoo.cmake
npm run cpp:configure -- --debug-find-pkg=Foo --trace-source=FindFoo.cmake

# * yarn classic needs double-double-hyphen because it eats the first one like npm
yarn cpp:build -- -- CMakeFiles/my_lib.dir/my_src.cpp.o
npm run cpp:build -- -- CMakeFiles/my_lib.dir/my_src.cpp.o

@Julusian Julusian changed the title Forward extra arguments to CMake commands feat: Forward extra arguments to CMake commands Feb 12, 2023
@Julusian Julusian merged commit e40d2f3 into cmake-js:master Feb 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants