Skip to content

Always use Ninja generator when building cmake projects form source#1736

Open
sbc100 wants to merge 1 commit into
mainfrom
ninja_windows
Open

Always use Ninja generator when building cmake projects form source#1736
sbc100 wants to merge 1 commit into
mainfrom
ninja_windows

Conversation

@sbc100

@sbc100 sbc100 commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

When building tools from source, unconditionally use the Ninja
generator.

Since #1105 landed ninja is also always available via emsdk.

This massively simplifies the Windows build process allowing for the
removal of --vs2019, --vs2022, --mingw and --generator flags
along with vswhere detection, Visual Studio multi-config output paths,
and the mingw SDK package.

This also allows us to completely remove all the NUM_CORES handling
since ninja is really good and using all the cores automatically (no need to
pass -j at all). If folks really want to control the parallelism they can still
do so using the CMAKE_BUILD_PARALLEL_LEVEL environment variable (https://cmake.org/cmake/help/latest/envvar/CMAKE_BUILD_PARALLEL_LEVEL.html)

Instead, we now rely on MSCV being configured in the environment prior
to running emsdk. i.e. We expect windows users to run in a Visual Studio
command prompt (or with vcvarsall.bat having been already run). This
seems like a more sensible soltution that trying to build visual studio selection
into emsdk itself. i.e. we can just expect users to have already selected their
prefered visual studio version.

See: #1734

@sbc100 sbc100 changed the title [windows] Always use Ninja generator on Windows [windows] Always use Ninja for building from source on Windows Jul 15, 2026
@sbc100 sbc100 changed the title [windows] Always use Ninja for building from source on Windows [windows] Always use Ninja when building from source on Windows Jul 15, 2026
@sbc100
sbc100 marked this pull request as draft July 15, 2026 23:15
@sbc100 sbc100 changed the title [windows] Always use Ninja when building from source on Windows [windows] Always use Ninja generator when build cmake projects form source Jul 15, 2026
@sbc100
sbc100 force-pushed the ninja_windows branch 2 times, most recently from 3268f42 to d2395b3 Compare July 16, 2026 01:32
@sbc100

sbc100 commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator Author

I'm adding ninja to the manifest so it should be super easy to install too #1105

sbc100 added a commit that referenced this pull request Jul 21, 2026
We may start using it internally in emscripten. See
emscripten-core/emscripten#17809

Its also useful to be able to install it when building other
things from source (See #1736)
@sbc100

sbc100 commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator Author

@juj, what do you think about this? Can we just standardize of the Ninja generator?

@sbc100
sbc100 force-pushed the ninja_windows branch 3 times, most recently from f36efbb to 13d6498 Compare July 21, 2026 17:54
@sbc100
sbc100 marked this pull request as ready for review July 21, 2026 17:56
@sbc100

sbc100 commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator Author

In the emscripten-releases repo we already are ninja-only: https://chromium.googlesource.com/emscripten-releases/+/refs/heads/main/src/build.py

@sbc100 sbc100 changed the title [windows] Always use Ninja generator when build cmake projects form source Always use Ninja generator when building cmake projects form source Jul 21, 2026
…ource

When building tools from source, unconditionally use the Ninja
generator.

This massively simplifies the Windows build process allowing for the
removal of `--vs2019`, `--vs2022`, `--mingw` and `--generator` flags
along with `vswhere` detection, Visual Studio multi-config output paths,
and the `mingw` SDK package.

Instead can now rely on MSCV being configured in the environment prior
to running emsdk, and since #1105 landed ninja is also always available
via emsdk.

See: #1734
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.

1 participant