Skip to content

COMP: Build elastix_lib and transformix_lib as STATIC libraries - #1506

Merged
N-Dekker merged 1 commit into
SuperElastix:mainfrom
Voggo:CMake-elastix_lib-transformix_lib-STATIC
Dec 3, 2026
Merged

N-Dekker merged 1 commit into
SuperElastix:mainfrom
Voggo:CMake-elastix_lib-transformix_lib-STATIC

Conversation

@Voggo

@Voggo Voggo commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

elastix_lib and transformix_lib are the only library targets of elastix whose type is still determined by BUILD_SHARED_LIBS. elastix rejects BUILD_SHARED_LIBS at the start of its top-level CMakeLists.txt (pull request #184), but the variable can still be set afterwards, by a package that find_package(ITK) finds.

Example: an ITK built with ITK_USE_SYSTEM_VXL against a shared VXL. The VXLConfig.cmake of that VXL has set(BUILD_SHARED_LIBS "ON"). The elastix build then silently produces libelastix-5.3.1.so and libtransformix-5.3.1.so, next to static libraries for everything else.

This pull request adds STATIC to the two add_library calls, as all other elastix libraries have already (elxCore, elxCommon, the components), and removes the comment saying that their type is determined by BUILD_SHARED_LIBS.

Checked on Linux, GCC 13.3, against such an ITK (5.4.3): before, the two .so files; after, libelastix-5.3.1.a and libtransformix-5.3.1.a, and CommonGTest and ElastixLibGTest build and give the same results.

Related: #184, #283.

🤖 Generated with Claude Code

`elastix_lib` and `transformix_lib` were the only library targets of elastix
whose type was still determined by `BUILD_SHARED_LIBS`.
While elastix rejects `BUILD_SHARED_LIBS` at the start of its top-level CMakeLists.txt,
the variable may still be set afterwards, by a package found by `find_package(ITK)`.
For example, when ITK is built with `ITK_USE_SYSTEM_VXL` against a shared VXL,
the VXLConfig.cmake of that VXL has `set(BUILD_SHARED_LIBS "ON")`.
The two libraries were then built as shared libraries, while all other elastix libraries were static.

Follow-up to pull request SuperElastix#184
commit bb902f7
"COMP: Explicitly disable BUILD_SHARED_LIBS"
Comment thread Core/CMakeLists.txt
# The library type (STATIC or SHARED) is determined by the parameter
# BUILD_SHARED_LIBS.
add_library(elastix_lib
add_library(elastix_lib STATIC

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Voggo Thanks Niels! Looks fine to me!

@mstaring @stefanklein This pull request makes it clearer that we only build static elastix libs, no elastix DLL's. I think it's OK to merge, when it has passed the CI.

We can of course reconsider this adjustment if we might ever need to have elastix DLL's anyway.

Kind regards, Niels 2 😃

@N-Dekker
N-Dekker merged commit 7dfc19f into SuperElastix:main Dec 3, 2026
5 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