Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix install step for SYSTEM/ITK/VTK, fix corner case in cmake config. #867

Merged
merged 1 commit into from
Oct 14, 2019

Conversation

gdevenyi
Copy link
Contributor

@gdevenyi gdevenyi commented Oct 8, 2019

Addresses #857 (comment)

@TheChymera
Copy link
Contributor

Would you like me to test this?

I have noticed that with commits after yesterday (554b696) I get the following error during make: build.log.

The error is not at the very end, but a bit further up, look for this bit:

/var/tmp/portage/sci-biology/ants-9999/work/ants-9999/Examples/N4BiasFieldCorrection.cxx:474:33: error: 'itk::N4BiasFieldCorrectionImageFilter<TInputImage, TMaskImage, TOutputImage>::RealImagePointer itk::N4BiasFieldCorrectionImageFilter<TInputImage, TMaskImage, TOutputImage>::ReconstructBiasField(itk::N4BiasFieldCorrectionImageFilter<TInputImage, TMaskImage, TOutputImage>::BiasFieldControlPointLatticeType*) [with TInputImage = itk::Image<float, 4>; TMaskImage = itk::Image<float, 4>; TOutputImage = itk::Image<float, 4>; itk::N4BiasFieldCorrectionImageFilter<TInputImage, TMaskImage, TOutputImage>::RealImagePointer = itk::SmartPointer<itk::Image<float, 4> >; itk::N4BiasFieldCorrectionImageFilter<TInputImage, TMaskImage, TOutputImage>::BiasFieldControlPointLatticeType = itk::Image<itk::Vector<float, 1>, 4>]' is private within this context
  474 |     typename ImageType::Pointer logField =
      |                                 ^~~~~~~~
In file included from /usr/include/ITK-5.0/itkN4BiasFieldCorrectionImageFilter.h:436,
                 from /var/tmp/portage/sci-biology/ants-9999/work/ants-9999/Examples/N4BiasFieldCorrection.cxx:15:
/usr/include/ITK-5.0/itkN4BiasFieldCorrectionImageFilter.hxx:672:1: note: declared private here
  672 | N4BiasFieldCorrectionImageFilter<TInputImage, TMaskImage, TOutputImage>
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/var/tmp/portage/sci-biology/ants-9999/work/ants-9999/Examples/N4BiasFieldCorrection.cxx:474:33: error: invalid conversion from 'const BiasFieldControlPointLatticeType*' {aka 'const itk::Image<itk::Vector<float, 1>, 4>*'} to 'itk::N4BiasFieldCorrectionImageFilter<itk::Image<float, 4>, itk::Image<float, 4>, itk::Image<float, 4> >::BiasFieldControlPointLatticeType*' {aka 'itk::Image<itk::Vector<float, 1>, 4>*'} [-fpermissive]
  474 |     typename ImageType::Pointer logField =
      |                                 ^~~~~~~~
      |                                 |
      |                                 const BiasFieldControlPointLatticeType* {aka const itk::Image<itk::Vector<float, 1>, 4>*}

I'm just letting you know since this will make it more difficult for me to test your change, because I have to rebase it on an older commit.

@ntustison
Copy link
Member

This error shouldn't be there with the pull I merged yesterday.

@TheChymera
Copy link
Contributor

@ntustison :( but sadly it is. As you can see in the build log pasted above, the failure is with d073c62 (current HEAD).

@gdevenyi
Copy link
Contributor Author

gdevenyi commented Oct 8, 2019

@ntustison he is building against a system ITK that is behind master branch

@TheChymera
Copy link
Contributor

TheChymera commented Oct 8, 2019

@gdevenyi If that's the only way forward, I can bump ITK to 5.1_beta or newer, the Gentoo package manager supports custom version definition at the commit level (so we could have sci-libs/itk-5.1_beta_p20191008) --- which is also what I planned to do with ANTs if I manage to get it to build before your next release (e.g. sci-biology/ants-2.3.1_p20191008). Just to clarify if you're curious, the p segment signifies a patch “release”.

@TheChymera
Copy link
Contributor

TheChymera commented Oct 8, 2019

@ntustison I ran more tests and the problem is not introduced by 64ef514 but by one of the two newer commits.

@ntustison
Copy link
Member

@TheChymera I don't understand the distinction. Yesterday's pull is the same as the current head, is it not? Either way, the issue that you're running into is that an ITK developer changed the class itkN4BiasFieldCorrectionImageFilter to expose a function that was formerly private. I took advantage of that in yesterday's pull to reduce lines of code in the ANTs front-end N4BiasFieldCorrection.cxx.

@TheChymera
Copy link
Contributor

@ntustison no problem. Can you tell me what ITK commit I would be needing?

(though to clarify, I think you linked to a different pull than you intended: that is 64ef514 , the current head is d073c62 )

@ntustison
Copy link
Member

Ah, thanks for the clarification. Yes, I made a mistake. The pull actually contains two commits (because I was lazy, although they both concern N3/N4). I linked to the first commit of the pull while the current head contains both.

@ntustison
Copy link
Member

The ITK tag is here

@TheChymera
Copy link
Contributor

TheChymera commented Oct 8, 2019

ok, brb after I get a sufficiently new ITK building. Don't worry, I won't chase after the HEAD forever, I'm just looking for an ANTs commit where CMake works in my use case. So as soon as I can get that, I'll just pin the corresponding ITK commit and that's probably it until your next versioned ANTs release.

@ntustison
Copy link
Member

I had to revert that commit anyway. Sorry for the waste of time.

@TheChymera
Copy link
Contributor

@ntustison ah well :D

@gdevenyi
Copy link
Contributor Author

gdevenyi commented Oct 8, 2019

Passing here, should fix @TheChymera's make install with system libs issue.

@TheChymera
Copy link
Contributor

@gdevenyi ok, so I got the ITK issue out of the way, and I tested this patch, still, I get the same error:

-- Installing: /var/tmp/portage/sci-biology/ants-9999/image/usr/lib/libl_GetConnectedComponentsFeatureImages.so
-- Installing: /var/tmp/portage/sci-biology/ants-9999/image/usr/bin/GetConnectedComponentsFeatureImages
-- Set runtime path of "/var/tmp/portage/sci-biology/ants-9999/image/usr/bin/GetConnectedComponentsFeatureImages" to "/usr/lib"
-- Installing: /var/tmp/portage/sci-biology/ants-9999/image/usr/lib/libl_DeNrrd.so.2.3.1.dev36-gfbfe7
-- Installing: /var/tmp/portage/sci-biology/ants-9999/image/usr/lib/libl_DeNrrd.so.2
-- Set runtime path of "/var/tmp/portage/sci-biology/ants-9999/image/usr/lib/libl_DeNrrd.so.2.3.1.dev36-gfbfe7" to "/usr/lib"
-- Installing: /var/tmp/portage/sci-biology/ants-9999/image/usr/lib/libl_DeNrrd.so
-- Installing: /var/tmp/portage/sci-biology/ants-9999/image/usr/bin/DeNrrd
-- Set runtime path of "/var/tmp/portage/sci-biology/ants-9999/image/usr/bin/DeNrrd" to "/usr/lib"
-- Installing: /var/tmp/portage/sci-biology/ants-9999/image/usr/lib/libl_StackSlices.so.2.3.1.dev36-gfbfe7
-- Installing: /var/tmp/portage/sci-biology/ants-9999/image/usr/lib/libl_StackSlices.so.2
-- Set runtime path of "/var/tmp/portage/sci-biology/ants-9999/image/usr/lib/libl_StackSlices.so.2.3.1.dev36-gfbfe7" to "/usr/lib"
-- Installing: /var/tmp/portage/sci-biology/ants-9999/image/usr/lib/libl_StackSlices.so
-- Installing: /var/tmp/portage/sci-biology/ants-9999/image/usr/bin/StackSlices
-- Set runtime path of "/var/tmp/portage/sci-biology/ants-9999/image/usr/bin/StackSlices" to "/usr/lib"
CMake Error at cmake_install.cmake:74 (file):
  file INSTALL cannot find
  "/var/tmp/portage/sci-biology/ants-9999/work/ants-9999_build/ANTS-build/../staging/lib".


make: *** [Makefile:86: install] Error 1
 * ERROR: sci-biology/ants-9999::chymeric failed (install phase):
 *   emake failed
 * 
 * If you need support, post the output of `emerge --info '=sci-biology/ants-9999::chymeric'`,
 * the complete build log and the output of `emerge -pqv '=sci-biology/ants-9999::chymeric'`.
 * The complete build log is located at '/var/tmp/portage/sci-biology/ants-9999/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/sci-biology/ants-9999/temp/environment'.
 * Working directory: '/var/tmp/portage/sci-biology/ants-9999/work/ants-9999_build/ANTS-build'
 * S: '/var/tmp/portage/sci-biology/ants-9999/work/ants-9999'

>>> Failed to emerge sci-biology/ants-9999, Log file:

>>>  '/var/tmp/portage/sci-biology/ants-9999/temp/build.log'

 * Messages for package sci-biology/ants-9999:

 * User patches applied.
 * ERROR: sci-biology/ants-9999::chymeric failed (install phase):
 *   emake failed
 * 
 * If you need support, post the output of `emerge --info '=sci-biology/ants-9999::chymeric'`,
 * the complete build log and the output of `emerge -pqv '=sci-biology/ants-9999::chymeric'`.
 * The complete build log is located at '/var/tmp/portage/sci-biology/ants-9999/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/sci-biology/ants-9999/temp/environment'.
 * Working directory: '/var/tmp/portage/sci-biology/ants-9999/work/ants-9999_build/ANTS-build'
 * S: '/var/tmp/portage/sci-biology/ants-9999/work/ants-9999'
 * 
 * The following package has failed to build, install, or execute postinst:
 * 
 *  (sci-biology/ants-9999:0/0::chymeric, ebuild scheduled for merge), Log file:
 *   '/var/tmp/portage/sci-biology/ants-9999/temp/build.log'
 * 
darkhost ~ # cat /etc/portage/patches/sci-biology/ants-9999/logic.patch
From 2dd8f1106cc55f499284fc77396b17fd5c2feae1 Mon Sep 17 00:00:00 2001
From: "Gabriel A. Devenyi" <gdevenyi@gmail.com>
Date: Mon, 7 Oct 2019 22:01:51 -0400
Subject: [PATCH] Fix install logic

---
 ANTS.cmake | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/ANTS.cmake b/ANTS.cmake
index a1baf845..47e4edc2 100644
--- a/ANTS.cmake
+++ b/ANTS.cmake
@@ -172,7 +172,8 @@ install(PROGRAMS Scripts/ANTSpexec.sh
                 COMPONENT SCRIPTS
         )
 
-if(BUILD_SHARED_LIBS AND NOT (USE_SYSTEM_ITK AND USE_SYSTEM_VTK))
+#Only install ITK/VTK libraries if shared build and superbuild is used
+if(BUILD_SHARED_LIBS AND NOT (USE_SYSTEM_ITK AND (USE_SYSTEM_VTK AND USE_VTK)))
   install(DIRECTORY ${CMAKE_BINARY_DIR}/../staging/lib/
           DESTINATION lib)
 endif()
darkhost ~ # cat^Cetc/portage/patches/sci-biology/ants/ants-9999/logic.patch
darkhost ~ # ag BUILD_SHARED_LIB /var/tmp/portage/sci-biology/ants-9999/work/ants-9999/ANTS.cmake
176:if(BUILD_SHARED_LIBS AND NOT (USE_SYSTEM_ITK AND (USE_SYSTEM_VTK AND USE_VTK)))

@gdevenyi
Copy link
Contributor Author

gdevenyi commented Oct 9, 2019

I had to write down an old-fashioned truth table to sort out the logic. Should be correct this time...

@gdevenyi
Copy link
Contributor Author

gdevenyi commented Oct 9, 2019

And bitten by CMAKE again. What a terrible default to silently allow for undefined variables.

@TheChymera
Copy link
Contributor

TheChymera commented Oct 9, 2019

@gdevenyi I am getting the same error again:

-- Installing: /var/tmp/portage/sci-biology/ants-9999/image/usr/lib/libl_DeNrrd.so.2.3.1.dev36-gfbfe7
-- Installing: /var/tmp/portage/sci-biology/ants-9999/image/usr/lib/libl_DeNrrd.so.2
-- Set runtime path of "/var/tmp/portage/sci-biology/ants-9999/image/usr/lib/libl_DeNrrd.so.2.3.1.dev36-gfbfe7" to "/usr/lib"
-- Installing: /var/tmp/portage/sci-biology/ants-9999/image/usr/lib/libl_DeNrrd.so
-- Installing: /var/tmp/portage/sci-biology/ants-9999/image/usr/bin/DeNrrd
-- Set runtime path of "/var/tmp/portage/sci-biology/ants-9999/image/usr/bin/DeNrrd" to "/usr/lib"
-- Installing: /var/tmp/portage/sci-biology/ants-9999/image/usr/lib/libl_StackSlices.so.2.3.1.dev36-gfbfe7
-- Installing: /var/tmp/portage/sci-biology/ants-9999/image/usr/lib/libl_StackSlices.so.2
-- Set runtime path of "/var/tmp/portage/sci-biology/ants-9999/image/usr/lib/libl_StackSlices.so.2.3.1.dev36-gfbfe7" to "/usr/lib"
-- Installing: /var/tmp/portage/sci-biology/ants-9999/image/usr/lib/libl_StackSlices.so
-- Installing: /var/tmp/portage/sci-biology/ants-9999/image/usr/bin/StackSlices
-- Set runtime path of "/var/tmp/portage/sci-biology/ants-9999/image/usr/bin/StackSlices" to "/usr/lib"
CMake Error at cmake_install.cmake:74 (file):
  file INSTALL cannot find
  "/var/tmp/portage/sci-biology/ants-9999/work/ants-9999_build/ANTS-build/../staging/lib".


make: *** [Makefile:86: install] Error 1
 * ERROR: sci-biology/ants-9999::chymeric failed (install phase):
 *   emake failed
 * 
 * If you need support, post the output of `emerge --info '=sci-biology/ants-9999::chymeric'`,
 * the complete build log and the output of `emerge -pqv '=sci-biology/ants-9999::chymeric'`.
 * The complete build log is located at '/var/tmp/portage/sci-biology/ants-9999/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/sci-biology/ants-9999/temp/environment'.
 * Working directory: '/var/tmp/portage/sci-biology/ants-9999/work/ants-9999_build/ANTS-build'
 * S: '/var/tmp/portage/sci-biology/ants-9999/work/ants-9999'

>>> Failed to emerge sci-biology/ants-9999, Log file:

>>>  '/var/tmp/portage/sci-biology/ants-9999/temp/build.log'

 * Messages for package sci-biology/ants-9999:

 * User patches applied.
 * ERROR: sci-biology/ants-9999::chymeric failed (install phase):
 *   emake failed
 * 
 * If you need support, post the output of `emerge --info '=sci-biology/ants-9999::chymeric'`,
 * the complete build log and the output of `emerge -pqv '=sci-biology/ants-9999::chymeric'`.
 * The complete build log is located at '/var/tmp/portage/sci-biology/ants-9999/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/sci-biology/ants-9999/temp/environment'.
 * Working directory: '/var/tmp/portage/sci-biology/ants-9999/work/ants-9999_build/ANTS-build'
 * S: '/var/tmp/portage/sci-biology/ants-9999/work/ants-9999'
 * 
 * The following package has failed to build, install, or execute postinst:
 * 
 *  (sci-biology/ants-9999:0/0::chymeric, ebuild scheduled for merge), Log file:
 *   '/var/tmp/portage/sci-biology/ants-9999/temp/build.log'
 * 
darkhost ~ # cat /etc/portage/patches/sci-biology/ants-9999/logic.patch 
From 98c454c4c1bf933a4bf6dea8176bed33175a6a44 Mon Sep 17 00:00:00 2001
From: "Gabriel A. Devenyi" <gdevenyi@gmail.com>
Date: Mon, 7 Oct 2019 22:01:51 -0400
Subject: [PATCH] Fix install logic

---
 ANTS.cmake       | 3 ++-
 SuperBuild.cmake | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/ANTS.cmake b/ANTS.cmake
index a1baf845..75ffbcef 100644
--- a/ANTS.cmake
+++ b/ANTS.cmake
@@ -172,7 +172,8 @@ install(PROGRAMS Scripts/ANTSpexec.sh
                 COMPONENT SCRIPTS
         )
 
-if(BUILD_SHARED_LIBS AND NOT (USE_SYSTEM_ITK AND USE_SYSTEM_VTK))
+#Only install ITK/VTK libraries if shared build and superbuild is used
+if(BUILD_SHARED_LIBS AND ((NOT USE_SYSTEM_ITK) OR (NOT (USE_SYSTEM_VTK AND USE_VTK))))
   install(DIRECTORY ${CMAKE_BINARY_DIR}/../staging/lib/
           DESTINATION lib)
 endif()
diff --git a/SuperBuild.cmake b/SuperBuild.cmake
index f4630e64..32b930c2 100644
--- a/SuperBuild.cmake
+++ b/SuperBuild.cmake
@@ -207,6 +207,8 @@ list(APPEND ${CMAKE_PROJECT_NAME}_SUPERBUILD_EP_VARS
   CMAKE_C_COMPILER_LAUNCHER:STRING
   CMAKE_CXX_COMPILER_LAUNCHER:STRING
   CMAKE_CUDA_COMPILER_LAUNCHER:STRING
+  USE_SYSTEM_ITK:BOOL
+  USE_SYSTEM_VTK:BOOL
   )
 
 _expand_external_project_vars()
darkhost ~ # ag BUILD_SHARED_LIB /var/tmp/portage/sci-biology/ants-9999/work/ants-9999/ANTS.cmake
176:if(BUILD_SHARED_LIBS AND ((NOT USE_SYSTEM_ITK) OR (NOT (USE_SYSTEM_VTK AND USE_VTK))))
darkhost ~ # ag BUILD_SHARED_LIB /var/tmp/portage/sci-biology/ants-9999/work/ants-9999/SuperBuild.cmake 
172:  BUILD_SHARED_LIBS:BOOL

maybe I am using the wrong commit for the patch? What I see you updated this PR to is 98c454c, but that seems to be 2 days old already, and probably not the newest version you were referring to.

@gdevenyi
Copy link
Contributor Author

gdevenyi commented Oct 9, 2019

Is this a complete rebuild from a clean directory?

I have tested the version you're referring to, and it works as expected. The date is such because it is an amended commit.

@TheChymera
Copy link
Contributor

TheChymera commented Oct 10, 2019

@gdevenyi yes, sadly this is the case. I even wiped everything and tried again. And as you can see in the snippet above the respective files are also correctly edited :-/ any other info I could share?

I can archive and upload the entire build directory tree if you would like.

@gdevenyi
Copy link
Contributor Author

gdevenyi commented Oct 10, 2019

Okay, I've just tested again and it still works so...

  • cmake --version
  • the complete build log
  • the contents of CMakeCache.txt and ANTS-build/CMakeCache.txt

Please

@TheChymera
Copy link
Contributor

@gdevenyi

Cmake:

darkhost ~ # cmake --version
cmake version 3.15.3

CMake suite maintained and supported by Kitware (kitware.com/cmake).
darkhost ~ # eix -I cmake
[U] dev-util/cmake
     Available versions:  (~)3.13.5 3.14.6 (~)3.14.7 (~)3.15.3 (~)3.15.4 {doc emacs ncurses qt5 system-jsoncpp test}
     Installed versions:  3.15.3(21:28:23 09/10/19)(ncurses -doc -emacs -qt5 -system-jsoncpp -test)
     Homepage:            https://cmake.org/
     Description:         Cross platform Make

CMakeCache.txt: CMakeCache.txt

ANTS-build/CMakeCache.txt: CMakeCache.txt

Directory tree: tree.txt

@gdevenyi
Copy link
Contributor Author

And the build log please?

@TheChymera
Copy link
Contributor

@gdevenyi build.log

@gdevenyi
Copy link
Contributor Author

Okay, we have a corner case.
You have specified -DUSE_SYSTEM_VTK and -DVTK_DIR, but you never specified -DUSE_VTK.

So

  1. You didn't actually get any of the VTK binaries built
  2. This corner case breaks the logic.

So, you can fix your build by adding -DUSE_VTK=ON, but I need to add some kind of error condition on the cmake so that you can't get into this state.

@gdevenyi gdevenyi changed the title Fix install logic [WIP] Fix install step for SYSTEM/ITK/VTK, fix corner case in cmake config. Oct 10, 2019
@TheChymera
Copy link
Contributor

TheChymera commented Oct 10, 2019

@gdevenyi ok, will do. Just so that I now whether to hard-code of parameterize this: can ANTs be built and is it of much use with -DUSE_VTK=OFF? Is vtk an optional feature? Do I also need to explicitly set -DUSE_ITK=ON --- or is that one mandatory?

@TheChymera
Copy link
Contributor

@gdevenyi ok, now it seems to fail earlier: build.log

@gdevenyi
Copy link
Contributor Author

VTK is optional and enables a number of surface enabled tools.

@gdevenyi
Copy link
Contributor Author

You're missing itkvtkglue in your itk build

list(APPEND ${proj}_CMAKE_OPTIONS -DModule_ITKVtkGlue:BOOL=ON)

@TheChymera
Copy link
Contributor

@gdevenyi while I sort my ITK out, I have tested the build again with all the VTK flags disabled (CMake command at the beginning of the log), and I get the following
build.log. So the logic problem also crops up if all VTK-support features are turned off, it seems.

@gdevenyi
Copy link
Contributor Author

Yup, further adjustment to the logic here, tested locally found your bug.

@TheChymera
Copy link
Contributor

Ok, this worked, thank you :)

@gdevenyi gdevenyi changed the title [WIP] Fix install step for SYSTEM/ITK/VTK, fix corner case in cmake config. Fix install step for SYSTEM/ITK/VTK, fix corner case in cmake config. Oct 14, 2019
@gdevenyi
Copy link
Contributor Author

Ready for merge.

@ntustison ntustison merged commit 57cc85f into ANTsX:master Oct 14, 2019
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.

3 participants