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

Support for Ninja+MSVC in Windows #113

Open
hokiedsp opened this issue Mar 13, 2018 · 5 comments
Open

Support for Ninja+MSVC in Windows #113

hokiedsp opened this issue Mar 13, 2018 · 5 comments

Comments

@hokiedsp
Copy link

Great package! CMake-JS is lowering my entry into NodeJS from the native side.

Now, a feature request.

Right now, if you specify non MSVC generator in windows, the option is ignored (correct me if I'm wrong). Could it be possible to set up the MSVC path then use the user-specified generator?

This is specifically useful for those of us using Ninja compiler with MSVC.

Thanks and keep up with the great work!!

@d3x0r
Copy link
Contributor

d3x0r commented Apr 27, 2018

hmm... basically the -G option is just kept and passed through (unless it ended up bypassed because it's generally not that useful)

MSVC itself is really fast in building projects; not sure ninja would be that much better...
it's if( generator ) { use generator } else if{} {/mac/} else if() { /other/ }

@jalfd
Copy link
Collaborator

jalfd commented Oct 30, 2019

MSVC itself is really fast in building projects; not sure ninja would be that much better...

fwiw, in our testing we've found Ninja to be a good 30% faster than MSVC's MSBuild

@LuminescentMoon
Copy link

@d3x0r For consistency reasons, I prefer to use Ninja+MSVC. But for some reason, I can't get a successful configure with cmake-js. The CMake tools extension for VSCode configures and builds flawlessly with the exact same project using Ninja+MSVC.

Is there a way to let VSCode CMake Tools handle choosing the generator, build type, toolchain, etc while using cmake-js?

Or maybe cmake-js should configure the same way VSCode CMake Tools does.

@LuminescentMoon
Copy link

So I've finally got Ninja+MSVC running smoothly. 2 things to note:

  • Not sure if this also happens on NPM, but with Yarn, Ninja keeps trying to use node_modules/.bin/rc as the resource compiler. Setting the RC environment variable to the proper MSVC resource compiler before invoking CMake solves this issue.
  • Builds generated with Ninja will not be able to figure out that extern symbol __delayLoadHelper2 in node.lib is found in delayimp.lib in the VC runtime libraries folder. Adding delayimp as a link library in CMakeLists.txt solves this but cmake-js should be the one adding this instead.

cmake-js really should have an option to disable adding its own win_delay_load_hook.cc file.

@rconde01
Copy link

rconde01 commented Jan 31, 2021

re: rc...the issue here is that cmake searches the path for the resource compiler 'rc':

https://github.com/Kitware/CMake/blob/63aa279343df34d34e0a0fd0c92a444e2528bb8a/Modules/CMakeDetermineRCCompiler.cmake

cmake-js depends on the rc library. npm prepends the path with node_modules/.bin, so searching the path finds that version of rc.

As stated above, you can define RC to fix that:

where rc > "%TEMP%\cmake-js-rc-fix" && set /p RC= < "%TEMP%\cmake-js-rc-fix"

It would be nice to fix that within cmake-js, but I can't think of a way atm. Even if you get rid of rc, another library could pull it in.

Here's a janky solution:

"cross-env RC=\"$WindowsSdkVerBinPath$Platform\\rc.exe\" cmake-js -G Ninja compile"

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

No branches or pull requests

5 participants