Sitelet https://github.com/stepcode/stepcode/pull/482
Skip to content

Fix the static library build: a generator expression leaks into the link line - #482

Merged
starseeker merged 1 commit into
stepcode:developfrom
attixray:sc-fix-static-lib-link-interface
Aug 21, 2026
Merged

Fix the static library build: a generator expression leaks into the link line#482
starseeker merged 1 commit into
stepcode:developfrom
attixray:sc-fix-static-lib-link-interface

Conversation

@attixray

Copy link
Copy Markdown

With BUILD_STATIC_LIBS=ON, develop does not build. src/cldai/CMakeLists.txt composes its static dependency name with a generator expression:

SC_ADDLIB(stepdai-static STATIC SOURCES ${DAI_SRCS} LINK_LIBRARIES $<JOIN:${_libdeps},-static >-static)

_libdeps holds one entry, steputils, so this is an elaborate way of writing steputils-static. While the dependency was linked privately it expanded once, on the link line of stepdai-static, and was correct. Since 0b950dd (cmake: declare target link interfaces explicitly) SC_ADDLIB publishes LINK_LIBRARIES as PUBLIC, so it lands in INTERFACE_LINK_LIBRARIES and is re-evaluated in every consumer — where the nested $<JOIN:...> comes back out mangled and reaches the build tool verbatim.

Reproduced on 8a228eb with no schemas configured at all:

$ cmake -S . -B build -G Ninja -DBUILD_STATIC_LIBS=ON -DBUILD_SHARED_LIBS=OFF -DSC_BUILD_SCHEMAS=
$ cmake --build build
ninja: error: build.ninja:3546: bad $-escape (literal $ must be written as $$)

and the offending line ends in:

LINK_LIBRARIES = ... lib\stepdai-static.lib  $<JOIN:steputils

With the Visual Studio generator the same thing surfaces later, at link time, once a schema executable is the first consumer to pick up the interface:

LINK : fatal error LNK1104: cannot open file $<JOIN:steputils,-static.obj

Building the list with a foreach costs nothing, reads the same, and keeps working if _libdeps ever grows. The shared branch is untouched — this is inside if(BUILD_STATIC_LIBS). It is the only $<JOIN: in the tree.

After the change the same configuration builds all 204 targets.

"cmake: declare target link interfaces explicitly" (0b950dd) made SC_ADDLIB
publish its LINK_LIBRARIES as PUBLIC. That is the right change, but it is not
compatible with the way src/cldai/CMakeLists.txt names its static dependency:

    SC_ADDLIB(stepdai-static STATIC SOURCES ${DAI_SRCS}
              LINK_LIBRARIES $<JOIN:${_libdeps},-static >-static)

_libdeps holds one entry, steputils, so the generator expression is an elaborate
way of writing steputils-static. While the dependency was linked privately it
expanded once, on the link line of stepdai-static, and was correct. Published as
PUBLIC it lands in INTERFACE_LINK_LIBRARIES and is evaluated again in every
consumer, where it comes back out mangled and reaches the linker verbatim:

    LINK : fatal error LNK1104: cannot open file $<JOIN:steputils,-static.obj

p21read_sdai_<schema> is the first consumer to hit it, so with BUILD_STATIC_LIBS=ON
no schema executable links. Reproduced on develop tip - nothing after 0b950dd
touches either file, so the static build is broken there too.

Building the list with a foreach costs nothing, reads the same, and keeps working
if _libdeps ever grows. The shared branch is untouched; this is inside
if(BUILD_STATIC_LIBS).
@starseeker

Copy link
Copy Markdown
Member

BRL-CAD failures are on the brlcad side.

@starseeker
starseeker merged commit 9baa5da into stepcode:develop Aug 21, 2026
4 of 6 checks passed
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.

2 participants