ENH: Consume ANTs via find_package(ANTS) instead of manual source-tree paths#598
Open
hjmjohnson wants to merge 1 commit into
Open
ENH: Consume ANTs via find_package(ANTS) instead of manual source-tree paths#598hjmjohnson wants to merge 1 commit into
hjmjohnson wants to merge 1 commit into
Conversation
…e paths Switches the in-SuperBuild ANTs build to ANTsX/ANTs#1973's antsconfig-cmake-modernize branch (which adds ANTSConfig.cmake to ANTs's install tree) and collapses BRAINSTools.cmake's 20-line manual include_directories + link_directories + ANTS_LIBS block into a single find_package(ANTS CONFIG REQUIRED). External_ANTs.cmake: * Repo: ANTsX/ANTs -> hjmjohnson/ANTs (temporarily; will revert to ANTsX/ANTs once #1973 merges and a tagged ANTs release ships with find_package() support). * GIT_TAG: 1766655c (2026-03-25 master) -> 31faec49 (antsconfig-cmake-modernize HEAD). * Export ANTS_DIR = ${CMAKE_INSTALL_PREFIX}/lib/cmake/ANTS via mark_as_superbuild so the inner BRAINSTools build's find_package(ANTS) can locate the just-installed ANTSConfig.cmake. BRAINSTools.cmake: * Replace the manual EXISTS-checks + 5x include_directories + link_directories(${ANTs_LIBRARY_DIR}) + set(ANTS_LIBS antsUtilities) block with: find_package(ANTS CONFIG REQUIRED) set(ANTS_LIBS ANTS::antsUtilities) ANTs's installed antsUtilities target carries the 6 public-API include directories (Examples/, Utilities/, ImageRegistration/, ImageSegmentation/, Tensor/, Temporary/) plus ITK transitive includes via INTERFACE_INCLUDE_DIRECTORIES, so the manual paths are no longer needed. Existing call sites that use ${ANTS_LIBS} in target_link_libraries (BRAINSCommonLib, BRAINSFit) work unchanged because the imported target ANTS::antsUtilities is a drop-in for the bare antsUtilities library name. Diff: 23 -> 9 lines (-14 net). No call-site changes outside the two edited files. Net: BRAINSTools no longer needs the ANTs source tree on disk after the SuperBuild ANTs install completes; consumes only the install tree like any other CMake-found dependency. Verification: ANTSConfig.cmake + the 6 INSTALL_INTERFACE include directories + ANTS_LIBRARIES were exercised end-to-end against an independent consumer at https://github.com/hjmjohnson/ANTsDependantCMakeSmokeTest (built ANTs from #1973, installed, ran a downstream find_package(ANTS) consumer that includes the same headers BRAINSFitSyN.h uses).
dzenanz
approved these changes
May 12, 2026
hjmjohnson
added a commit
that referenced
this pull request
May 15, 2026
On macOS SDK 26.5's <__math/abs.h>, the std::abs overload set includes
both the templated floating-point form and integer-typed candidates,
making the explicit form `std::abs<double>(...)` ambiguous:
error: call to 'abs' is ambiguous
37 | return std::abs<double>(input - desired)
| ^~~~~~~~~~~~~~~~
The explicit template argument was never load-bearing here --- inputs
are `double`, so the non-templated `std::abs(double)` overload from
<cmath> resolves unambiguously. Dropping `<double>` fixes the build
on current Apple toolchains without changing behavior on earlier
SDKs or other platforms.
Surfaced while validating #598 (find_package(ANTS)
migration) on AppleClang 21 / macOS SDK 26.5.
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
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.
Draft — depends on ANTsX/ANTs#1973. Do not merge until that PR lands and an ANTs revision containing it is pinned upstream.
Collapses the 20-line manual
include_directories/link_directories/ANTS_LIBSANTs detection block inBRAINSTools.cmakeintofind_package(ANTS CONFIG REQUIRED), using ANTs's new package-config layer from ANTsX/ANTs#1973. Net-14lines, no call-site changes outside the two edited files.What changes
The 6 public-API include directories (
Examples/,Utilities/,ImageRegistration/,ImageSegmentation/,Tensor/,Temporary/) plus all transitive ITK includes now flow throughANTS::antsUtilities'sINTERFACE_INCLUDE_DIRECTORIESautomatically. Existingtarget_link_libraries(... ${ANTS_LIBS} ...)call sites (BRAINSCommonLib,BRAINSFit) are unchanged because the namespaced imported target is a drop-in for the bare library name.SuperBuild plumbing (External_ANTs.cmake)
set(${proj}_LIBRARY_DIR ${CMAKE_INSTALL_PREFIX}/lib) +set(ANTS_DIR ${CMAKE_INSTALL_PREFIX}/lib/cmake/ANTS) mark_as_superbuild( VARS ${proj}_SOURCE_DIR:PATH ${proj}_LIBRARY_DIR:PATH + ANTS_DIR:PATH LABELS "FIND_PACKAGE" )The
ANTS_DIRpropagation is what lets the inner BRAINSTools build'sfind_package(ANTS CONFIG REQUIRED)locate the just-installedANTSConfig.cmakewithout needingCMAKE_PREFIX_PATHtweaks.Release coordination — what has to happen before this can merge
ANTSConfig.cmake,ANTSTargets.cmake,ANTS::antsUtilities, public-header install, andANTS_INCLUDE_DIRS/ANTS_LIBRARIESlegacy-list vars)External_ANTs.cmake${proj}_REPOSITORYback tohttps://github.com/ANTsX/ANTs.gitandGIT_TAGto the release SHAUntil step 3, the temporary repo pointer at
hjmjohnson/ANTskeeps the SuperBuild building from the PR branch directly so the BRAINSTools side can be exercised in CI / dev environments without waiting for an ANTs release.Verification
ANTs PR #1973's package-config was exercised end-to-end with an independent downstream consumer that mirrors
BRAINSCommonLib/BRAINSFitSyN.h's exact ANTs includes:#include "antsUtilities.h","itkantsRegistrationHelper.h","ReadWriteData.h","itkANTSAffine3DTransform.h","ANTsVersionConfig.h"; callsConvertToLowerCase(real symbol inlibantsUtilities), instantiatesitk::ANTSAffine3DTransform<double>, anditk::Image<float,3>.ANTS::antsUtilitiesafterfind_package(ANTS), and the link interface resolves.Same machinery is also being exercised independently in InsightSoftwareConsortium/ITKANTsWasm#41.
Full BRAINSTools SuperBuild verification will run once CI starts on this PR; given the inner-build changes are mechanical (just swapping the same set of include directories for the same target's interface, and the same library name for the namespaced imported target), the risk is low.