Skip to content

Fix superbuild flag propagation and support StealthLink on Linux - #98

Open
mkomaiha wants to merge 4 commits into
PlusToolkit:masterfrom
mkomaiha:linux-stealthlink-superbuild
Open

Fix superbuild flag propagation and support StealthLink on Linux#98
mkomaiha wants to merge 4 commits into
PlusToolkit:masterfrom
mkomaiha:linux-stealthlink-superbuild

Conversation

@mkomaiha

@mkomaiha mkomaiha commented Aug 31, 2026

Copy link
Copy Markdown

@lassoan @Sunderlandkyl
Fixes #957 (together with PlusToolkit/PlusLib#1292).

Four superbuild fixes found while building with PLUS_USE_STEALTHLINK=ON on Linux. The first three are general and independent of StealthLink — each can be cherry-picked on its own. The fourth builds on the third.


1. COMP: Enforce CMake 3.5 min for VTK

CMake 4 removed compatibility with cmake_minimum_required below 3.5. VTK 9.1 vendors a KWSys whose minimum predates that, so VTK cannot configure at all under CMake 4:

CMake Error at Utilities/KWSys/vtksys/CMakeLists.txt:91 (cmake_minimum_required):
  Compatibility with CMake < 3.5 has been removed from CMake.

Adds -DCMAKE_POLICY_VERSION_MINIMUM=3.5, the same treatment already applied to tesseract (26567be) and aruco (509f6bb).

2. BUG: Forward CMAKE_<LANG>_FLAGS to the external projects

ep_common_c_flags / ep_common_cxx_flags were built from CMAKE_<LANG>_FLAGS_INIT, which holds only the toolchain defaults. Flags passed on the command line land in CMAKE_<LANG>_FLAGS and were silently dropped, so every external project was built in a different configuration than the superbuild was asked for — with no diagnostic.

External_ITK.cmake had the same defect from the other side: itk_common_cxx_flags was assigned from ep_common_cxx_flags only under UNIX AND NOT APPLE, so macOS passed ITK no CXX flags at all, and the MSVC branch appended /MP to a variable that had never been set — dropping them there too.

This is the root cause of the ABI errors in #957: -D_GLIBCXX_USE_CXX11_ABI=0 never reached VTK, ITK, IGSIO or OpenIGTLink, so they were built with a different std::string than the SDK.

3. BUG: Resolve the ITK version before ep_common_args is built

ep_common_args captures CMAKE_CXX_STANDARD, but the block raising it to 17 for ITK 5 ran after, so external projects received the pre-bump value. On a clean single-pass configure ITK 5.4 is handed CMAKE_CXX_STANDARD=14 and rejects it:

CMake Error at CMakeLists.txt:39 (message):
  C++98 to C++14 are no longer supported in ITK version 5.4 and greater

Reconfiguring hides this, because the second pass reads the bumped value back from the cache — which is why it survives in-tree. The resolution depends only on PLUS_USE_STEALTHLINK and MSVC, both known well before ep_common_args, so it simply moves up.

4. ENH: Support building StealthLink on Linux

Depends on #3 (it edits the block that commit moves).

  • Set the ABI flag centrally. The Linux SDK is built against the pre-GCC5 libstdc++ ABI, and everything exchanging std::string with it must agree — not just PlusLib but VTK, ITK, IGSIO and OpenIGTLink. This was previously left to the user via a warning. -D_GLIBCXX_USE_CXX11_ABI=0 is now set once, before ep_common_cxx_flags is built; the warning is removed.
  • Pin ITK 4 only under MSVC. That requirement comes from StealthLink being limited to the Visual Studio 2013 runtime. On Linux the constraint is the libstdc++ ABI, now handled above, and forcing ITK 4 is actively harmful: ITK 4.12 vendors a 2017-era VXL whose compiler check stops at GCC 7 and fails with #error "Dunno about this gcc" on anything newer.
  • Forward STEALTHLINK_STEALTHLINK_SHARED_LIBRARY on every platform, since PlusLib links it on Linux (Fix two Linux build failures: shared StealthLink library and unused vtkImageViewer2 include PlusLib#1292).
  • Fail clearly on macOS. The SDK ships only Windows and Linux binaries; FindSTEALTHLINK previously fell through both platform branches and reported the SDK as missing.

Testing

Ubuntu 21.04, GCC 10, CMake 4.4.2, VTK 9.1.0, ITK 5.4.4, StealthLink SDK 2.4.

Each failure above reproduces without its commit. With all four applied, a single-pass configure gives every external project a consistent standard and ABI:

vtk:           CMAKE_CXX_STANDARD=17  -D_GLIBCXX_USE_CXX11_ABI=0
itk:           CMAKE_CXX_STANDARD=17  -D_GLIBCXX_USE_CXX11_ABI=0
IGSIO:         CMAKE_CXX_STANDARD=17  -D_GLIBCXX_USE_CXX11_ABI=0
OpenIGTLink:   CMAKE_CXX_STANDARD=17  -D_GLIBCXX_USE_CXX11_ABI=0
OpenIGTLinkIO: CMAKE_CXX_STANDARD=17  -D_GLIBCXX_USE_CXX11_ABI=0
PlusLib:       CMAKE_CXX_STANDARD=17  -D_GLIBCXX_USE_CXX11_ABI=0

and the built libraries carry the old ABI, e.g. vtksys::SystemTools::FileIsFullPath mangles as ...ERKSs (const std::string&) rather than ...ERKNSt7__cxx11..., with zero __cxx11 symbols in libvtksys.

The build then completes and the device is available at runtime:

$ PlusVersion | grep -i stealth
  - StealthLinkTracker (ver: Plus-2.9.0)

Note that reaching a successful link also requires PlusToolkit/PlusLib#1292 (PlusLib links the static SDK library, which carries none of the SDK's boost dependencies) and IGSIO/IGSIO#62 (vtkAddon was built with the opposite ABI), both of which are separate from this change. IGSIO#62 and IGSIO#63 are merged.

CMake 4 requires cmake_minimum_required to support policies that are 3.5
or newer. VTK 9.1 vendors a KWSys whose minimum predates that, so
configuring VTK with CMake 4 fails:

  CMake Error at Utilities/KWSys/vtksys/CMakeLists.txt:91:
    Compatibility with CMake < 3.5 has been removed from CMake.

Same treatment already applied to tesseract and aruco.
ep_common_c_flags and ep_common_cxx_flags were built from
CMAKE_<LANG>_FLAGS_INIT, which only holds the toolchain defaults. Flags
passed on the command line land in CMAKE_<LANG>_FLAGS and were dropped,
so every external project was built in a different configuration than
the superbuild was asked for, with no diagnostic.

External_ITK.cmake had the same defect from the other direction:
itk_common_cxx_flags was assigned from ep_common_cxx_flags only under
UNIX AND NOT APPLE, so macOS builds passed no CXX flags at all, and the
MSVC branch appended /MP to a variable that was never set. Initialize it
on every platform and append the platform extras.
ep_common_args captures CMAKE_CXX_STANDARD, but the block that raises it
to 17 for ITK 5 ran afterwards, so the external projects were handed the
pre-bump value. On a clean single-pass configure that means ITK 5.4 is
given CMAKE_CXX_STANDARD=14 and rejects it outright:

  CMake Error at CMakeLists.txt:39 (message):
    C++98 to C++14 are no longer supported in ITK version 5.4 and greater

Reconfiguring masked it, since the second pass read the bumped value back
from the cache. Move the ITK version and standard resolution above
ep_common_args; it depends only on PLUS_USE_STEALTHLINK and MSVC, both
known by that point.
The Linux StealthLink SDK is built against the pre-GCC5 libstdc++ ABI, so
everything that exchanges std::string with it has to agree. That is not
just PlusLib but VTK, ITK, IGSIO and OpenIGTLink as well, and getting it
right for each subproject was left to the user via a warning. Set
-D_GLIBCXX_USE_CXX11_ABI=0 once, before ep_common_cxx_flags is built, so
the whole superbuild is consistent, and drop the warning.

Pin ITK 4 only under MSVC. That requirement comes from StealthLink being
limited to the Visual Studio 2013 runtime; on Linux the constraint is the
libstdc++ ABI, now handled above. Forcing ITK 4 there is harmful, since
ITK 4.12 vendors a 2017-era VXL whose compiler check stops at GCC 7:

  vcl_compiler.h:90:4: error: #error "Dunno about this gcc"

Forward STEALTHLINK_STEALTHLINK_SHARED_LIBRARY on every platform, not
only Windows, since PlusLib now links it on Linux.

Fail with a clear message when PLUS_USE_STEALTHLINK is enabled on macOS.
The SDK ships only Windows and Linux binaries, and FindSTEALTHLINK
previously fell through both platform branches and reported the SDK as
missing instead.
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