Repository navigation
fix(cmake): add a dummy source to libraries without sources - #362
Merged
Merged
Conversation
Only executable targets without sources got an empty generated dummy.c. A static_library, shared_library or loadable_module without sources was written as e.g. `add_library(v8 STATIC)`, which CMake rejects at generate time with "No SOURCES given to target". Such libraries are used to aggregate dependencies, e.g. the `v8` target in Node.js's v8.gyp, and the make generator builds an empty library for them. Give every target except `none` the dummy source when it has none. Assisted-by: Claude Code Signed-off-by: gengjiawen <technicalcute@gmail.com>
gengjiawen
force-pushed
the
cmake-empty-library-sources
branch
from
September 29, 2026 04:16
d3359e9 to
6241c36
Compare
gengjiawen
requested review from
addaleax and
legendecas
and removed request for
addaleax
September 29, 2026 04:22
legendecas
approved these changes
Sep 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The CMake generator only gives an
executablewithout sources a generated, emptydummy.c. Astatic_library,shared_libraryorloadable_modulewithout sources is written as e.g.add_library(v8 STATIC), which CMake rejects at generate time:Libraries without sources are used to aggregate dependencies. Node.js's
v8target intools/v8_gypfiles/v8.gypis one: in non-shared builds it is astatic_librarywith no sources that only pulls inv8_snapshotfor its dependents. The make generator builds an empty library for such targets; this makes the CMake generator do the same by giving every target exceptnonethe dummy source when it has none.Tested by generating Node.js with
tools/gyp_node.py -f cmakeand configuring with CMake 4.4: configuring failed with the error above before this change and succeeds after it with no errors or warnings, andninja v8 libuvbuilds (libv8.ais empty, as with the make generator).Added unit tests in
pylib/gyp/generator/cmake_test.py.