Fix superbuild flag propagation and support StealthLink on Linux - #98
Open
mkomaiha wants to merge 4 commits into
Open
Fix superbuild flag propagation and support StealthLink on Linux#98mkomaiha wants to merge 4 commits into
mkomaiha wants to merge 4 commits into
Conversation
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.
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.
@lassoan @Sunderlandkyl
Fixes #957 (together with PlusToolkit/PlusLib#1292).
Four superbuild fixes found while building with
PLUS_USE_STEALTHLINK=ONon 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 VTKCMake 4 removed compatibility with
cmake_minimum_requiredbelow 3.5. VTK 9.1 vendors a KWSys whose minimum predates that, so VTK cannot configure at all under CMake 4:Adds
-DCMAKE_POLICY_VERSION_MINIMUM=3.5, the same treatment already applied to tesseract (26567be) and aruco (509f6bb).2.
BUG:ForwardCMAKE_<LANG>_FLAGSto the external projectsep_common_c_flags/ep_common_cxx_flagswere built fromCMAKE_<LANG>_FLAGS_INIT, which holds only the toolchain defaults. Flags passed on the command line land inCMAKE_<LANG>_FLAGSand were silently dropped, so every external project was built in a different configuration than the superbuild was asked for — with no diagnostic.External_ITK.cmakehad the same defect from the other side:itk_common_cxx_flagswas assigned fromep_common_cxx_flagsonly underUNIX AND NOT APPLE, so macOS passed ITK no CXX flags at all, and theMSVCbranch appended/MPto 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=0never reached VTK, ITK, IGSIO or OpenIGTLink, so they were built with a differentstd::stringthan the SDK.3.
BUG:Resolve the ITK version beforeep_common_argsis builtep_common_argscapturesCMAKE_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 handedCMAKE_CXX_STANDARD=14and rejects it: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_STEALTHLINKandMSVC, both known well beforeep_common_args, so it simply moves up.4.
ENH:Support building StealthLink on LinuxDepends on #3 (it edits the block that commit moves).
std::stringwith 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=0is now set once, beforeep_common_cxx_flagsis built; the warning is removed.#error "Dunno about this gcc"on anything newer.STEALTHLINK_STEALTHLINK_SHARED_LIBRARYon every platform, since PlusLib links it on Linux (Fix two Linux build failures: shared StealthLink library and unused vtkImageViewer2 include PlusLib#1292).FindSTEALTHLINKpreviously 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:
and the built libraries carry the old ABI, e.g.
vtksys::SystemTools::FileIsFullPathmangles as...ERKSs(const std::string&) rather than...ERKNSt7__cxx11..., with zero__cxx11symbols inlibvtksys.The build then completes and the device is available at runtime:
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.