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

Integrating KWSys & VNL+VCL into CTK as external libraries #949

Closed
al-sabr opened this issue Feb 9, 2021 · 42 comments
Closed

Integrating KWSys & VNL+VCL into CTK as external libraries #949

al-sabr opened this issue Feb 9, 2021 · 42 comments

Comments

@al-sabr
Copy link
Contributor

al-sabr commented Feb 9, 2021

Greetings

I would like to be able to use KWSys inside of CTK as a submodule can someone guide toward achieving my goal?

Best Regards

@jcfr
Copy link
Member

jcfr commented Feb 9, 2021

To better understand, could you indicate what you are trying to achieve ?

Without more details, I suggest to use Qt built-in features instead of adding a dependencies to kwsys.

If you have ITK or VTK based classes, kwsys is available as itksys or vtksys

@al-sabr
Copy link
Contributor Author

al-sabr commented Feb 9, 2021

I tried to use ITK which has kwsys but it doesn't download at all it gets stucked.

2>
2>  fatal: clone of 'git://itk.org/ITKData.git' into submodule path 'G:/programming/cpp/CTK/build/ITK/Testing/Data' failed
2>  Failed to clone 'Testing/Data'. Retry scheduled
2>  Cloning into 'G:/programming/cpp/CTK/build/ITK/Testing/Data'...
2>  fatal: unable to connect to itk.org:
2>  itk.org[0: 66.194.253.19]: errno=Invalid argument
2>
2>  fatal: clone of 'git://itk.org/ITKData.git' into submodule path 'G:/programming/cpp/CTK/build/ITK/Testing/Data' failed
2>  Failed to clone 'Testing/Data' a second time, aborting
2>  CMake Error at ITK-cmake/tmp/ITK-gitclone.cmake:52 (message):
2>    Failed to update submodules in: 'G:/programming/cpp/CTK/build/ITK'
2>

@al-sabr
Copy link
Contributor Author

al-sabr commented Feb 9, 2021

Actually I am trying to make a custom version of CTK without ITK & VTK but I still need KWSys. I want to learn how to be able to integrate external projects which I am depending on inside of CTK so that it gets recognized with library linking.

It is connected with my goal of porting the Blueberry Framework from MITK towards CTK... I almost achieved it but the lack of KWSys is blocking the compilation. Parts of Blueberry are deeply rooted with KWSys & ITK.

I extracted the necessary components required and isolated them into the Libs folder.

Now I just need KWSys to work out without depending on the massive ITK & VTK.

Is this clear enough?

@jcfr
Copy link
Member

jcfr commented Feb 9, 2021

It turns out that ITK external project in CTK is obsolete (see https:/commontk/CTK/blob/master/CMakeExternals/ITK.cmake).

In practice, we build CTK passing -DITK_DIR:PATH=/path/to/ITK-build and do not rely on CTK building its own ITK

@al-sabr
Copy link
Contributor Author

al-sabr commented Feb 9, 2021

I want to remove from CTK all ITK & VTK and unnecessary components without getting rid of KWSys and VNL. I want to be able to build my Workspace with Blueberry Framework without any Medial Visualisation dependencies.

@jcfr
Copy link
Member

jcfr commented Feb 9, 2021

Since most of the functionalities of kwsys are available through Qt, I don't think it makes sense to integrate it.

Few options:

  • In the Blueberry Framework project, you could add a dependency to CTK, KWSys and VTK.
  • or add a file called CMakeExternals/KWSys.cmake in your fork of CTK.

@al-sabr
Copy link
Contributor Author

al-sabr commented Feb 9, 2021

This is the file I added like you mentioned:

#
# ZMQ
#


set(proj KWSys)


set(${proj}_DEPENDENCIES "")


ExternalProject_Include_Dependencies(${proj}
  PROJECT_VAR proj
  DEPENDS_VAR ${proj}_DEPENDENCIES
  EP_ARGS_VAR ${proj}_EXTERNAL_PROJECT_ARGS
  USE_SYSTEM_VAR ${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj}
  )


if(${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj})
  message(FATAL_ERROR "Enabling ${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj} is not supported !")
endif()


# Sanity checks
if(DEFINED KWSys_DIR AND NOT EXISTS ${ZMQ_DIR})
  message(FATAL_ERROR "KWSys_DIR variable is defined but corresponds to non-existing directory")
endif()


if(NOT DEFINED KWSys_DIR)


  set(revision_tag d2c2f96b49ed3835a47e)
  if(${proj}_REVISION_TAG)
    set(revision_tag ${${proj}_REVISION_TAG})
  endif()


  set(location_args )
  if(${proj}_URL)
    set(location_args URL ${${proj}_URL})
  elseif(${proj}_GIT_REPOSITORY)
    set(location_args GIT_REPOSITORY ${${proj}_GIT_REPOSITORY}
                      GIT_TAG ${revision_tag})
  else()
    set(location_args GIT_REPOSITORY "${EP_GIT_PROTOCOL}://gitlab.kitware.com/utils/kwsys.git"
                      GIT_TAG ${revision_tag})
  endif()


  ExternalProject_Add(${proj}
    ${${proj}_EXTERNAL_PROJECT_ARGS}
    SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj}
    BINARY_DIR ${proj}-build
    PREFIX ${proj}${ep_suffix}
    ${location_args}
    INSTALL_COMMAND ""
    CMAKE_CACHE_ARGS
      ${ep_common_cache_args}
      #-DKWSYS_NAMESPACE:STRING=itksys
     DEPENDS
      ${${proj}_DEPENDENCIES}
    )
  set(KWSys_DIR ${CMAKE_BINARY_DIR}/${proj}-build)


else()
  ExternalProject_Add_Empty(${proj} DEPENDS ${${proj}_DEPENDENCIES})
endif()


mark_as_superbuild(
  VARS KWSys_DIR:PATH
  LABELS "FIND_PACKAGE"
  )

How do I use this in my code ?

@jcfr
Copy link
Member

jcfr commented Feb 9, 2021

Then, you need to introduce the dependency to KWSys in your library like it is done here: https:/commontk/CTK/blob/master/Libs/Visualization/VTK/Widgets/target_libraries.cmake

This will ensure the external project is build when you build Blueberry library.

That said, by default the namespace for KWsys will be kwsys, but you would need to change that to something like ctksys and you will have to update blueberry to use that namespace.

See https://gitlab.kitware.com/utils/kwsys/-/blob/master/README.rst

@jcfr
Copy link
Member

jcfr commented Feb 9, 2021

Here is a pull request updating the version of ITK along with few other tweaks, see #951

In the pull request I linked, looking at what was done to removed older project like ZMQ should help you understand what need to be done to add KWSys ...

@al-sabr
Copy link
Contributor Author

al-sabr commented Feb 9, 2021

I was able to add KWSys & VXL(vnl,vcl) but I get to a point where the linking doesn't work with your method:

You can check what I did for the last 3 commits. https:/al-sabr/CTK/commits/ctk-blueberry-port-from-mitk

4>  G:\programming\cpp\CTK\Libs\itk\itkMacro.h(1142,1): warning C4005: 'ITK_EXPORT': macro redefinition [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>  G:\programming\cpp\CTK\build\CTK-build\Libs\itk\itkExport.h(18): message : see previous definition of 'ITK_EXPORT' [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>    itkObjectFactoryBase.cxx
4>  G:\programming\cpp\CTK\Libs\itk\itkMacro.h(1142,1): warning C4005: 'ITK_EXPORT': macro redefinition [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>  G:\programming\cpp\CTK\build\CTK-build\Libs\itk\itkExport.h(18): message : see previous definition of 'ITK_EXPORT' [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>  G:\programming\cpp\CTK\Libs\itk\itkDirectory.h(22,10): fatal error C1083: Cannot open include file: 'itksys/Directory.hxx': No such file or directory [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>    itkDataObject.cxx
4>  G:\programming\cpp\CTK\Libs\itk\itkMacro.h(1142,1): warning C4005: 'ITK_EXPORT': macro redefinition [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>  G:\programming\cpp\CTK\build\CTK-build\Libs\itk\itkExport.h(18): message : see previous definition of 'ITK_EXPORT' [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>    itkThreadPool.cxx
4>  G:\programming\cpp\CTK\Libs\itk\itkMacro.h(1142,1): warning C4005: 'ITK_EXPORT': macro redefinition [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>  G:\programming\cpp\CTK\build\CTK-build\Libs\itk\itkExport.h(18): message : see previous definition of 'ITK_EXPORT' [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>  G:\programming\cpp\CTK\Libs\itk\itkThreadPool.cxx(21,10): fatal error C1083: Cannot open include file: 'kwsys/SystemTools.hxx': No such file or directory [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>    itkMultiThreaderBase.cxx
4>  G:\programming\cpp\CTK\Libs\itk\itkMacro.h(1142,1): warning C4005: 'ITK_EXPORT': macro redefinition [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>  G:\programming\cpp\CTK\build\CTK-build\Libs\itk\itkExport.h(18): message : see previous definition of 'ITK_EXPORT' [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>  G:\programming\cpp\CTK\Libs\itk\itkVector.h(23,10): fatal error C1083: Cannot open include file: 'vnl/vnl_vector_ref.h': No such file or directory [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>    itkRealTimeStamp.cxx
4>  G:\programming\cpp\CTK\Libs\itk\itkMacro.h(1142,1): warning C4005: 'ITK_EXPORT': macro redefinition [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>  G:\programming\cpp\CTK\build\CTK-build\Libs\itk\itkExport.h(18): message : see previous definition of 'ITK_EXPORT' [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>    itkMath.cxx
4>  G:\programming\cpp\CTK\Libs\itk\itkMacro.h(1142,1): warning C4005: 'ITK_EXPORT': macro redefinition [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>  G:\programming\cpp\CTK\build\CTK-build\Libs\itk\itkExport.h(18): message : see previous definition of 'ITK_EXPORT' [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>  G:\programming\cpp\CTK\Libs\itk\itkMath.h(34,10): fatal error C1083: Cannot open include file: 'vnl/vnl_math.h': No such file or directory [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>    itkNumericTraitsPointPixel.cxx
4>  G:\programming\cpp\CTK\Libs\itk\itkMacro.h(1142,1): warning C4005: 'ITK_EXPORT': macro redefinition [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>  G:\programming\cpp\CTK\build\CTK-build\Libs\itk\itkExport.h(18): message : see previous definition of 'ITK_EXPORT' [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>  G:\programming\cpp\CTK\Libs\itk\itkVector.h(23,10): fatal error C1083: Cannot open include file: 'vnl/vnl_vector_ref.h': No such file or directory [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>    itkVector.cxx
4>  G:\programming\cpp\CTK\Libs\itk\itkMacro.h(1142,1): warning C4005: 'ITK_EXPORT': macro redefinition [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>  G:\programming\cpp\CTK\build\CTK-build\Libs\itk\itkExport.h(18): message : see previous definition of 'ITK_EXPORT' [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>  G:\programming\cpp\CTK\Libs\itk\itkVector.h(23,10): fatal error C1083: Cannot open include file: 'vnl/vnl_vector_ref.h': No such file or directory [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>    itkVersion.cxx
4>  G:\programming\cpp\CTK\Libs\itk\itkMacro.h(1142,1): warning C4005: 'ITK_EXPORT': macro redefinition [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>  G:\programming\cpp\CTK\build\CTK-build\Libs\itk\itkExport.h(18): message : see previous definition of 'ITK_EXPORT' [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>    itkBuildInformation.cxx
4>  G:\programming\cpp\CTK\Libs\itk\itkMacro.h(1142,1): warning C4005: 'ITK_EXPORT': macro redefinition [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>  G:\programming\cpp\CTK\build\CTK-build\Libs\itk\itkExport.h(18): message : see previous definition of 'ITK_EXPORT' [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>    itkPlatformMultiThreader.cxx
4>  G:\programming\cpp\CTK\Libs\itk\itkMacro.h(1142,1): warning C4005: 'ITK_EXPORT': macro redefinition [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>  G:\programming\cpp\CTK\build\CTK-build\Libs\itk\itkExport.h(18): message : see previous definition of 'ITK_EXPORT' [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>  G:\programming\cpp\CTK\Libs\itk\itkVector.h(23,10): fatal error C1083: Cannot open include file: 'vnl/vnl_vector_ref.h': No such file or directory [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>    itkImageSourceCommon.cxx
4>  G:\programming\cpp\CTK\Libs\itk\itkMacro.h(1142,1): warning C4005: 'ITK_EXPORT': macro redefinition [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>  G:\programming\cpp\CTK\build\CTK-build\Libs\itk\itkExport.h(18): message : see previous definition of 'ITK_EXPORT' [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>  G:\programming\cpp\CTK\Libs\itk\itkVector.h(23,10): fatal error C1083: Cannot open include file: 'vnl/vnl_vector_ref.h': No such file or directory [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>    itkImageRegionSplitterBase.cxx
4>  G:\programming\cpp\CTK\Libs\itk\itkMacro.h(1142,1): warning C4005: 'ITK_EXPORT': macro redefinition [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>  G:\programming\cpp\CTK\build\CTK-build\Libs\itk\itkExport.h(18): message : see previous definition of 'ITK_EXPORT' [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>  G:\programming\cpp\CTK\Libs\itk\itkVector.h(23,10): fatal error C1083: Cannot open include file: 'vnl/vnl_vector_ref.h': No such file or directory [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>    itkImageIORegion.cxx
4>  G:\programming\cpp\CTK\Libs\itk\itkMacro.h(1142,1): warning C4005: 'ITK_EXPORT': macro redefinition [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>  G:\programming\cpp\CTK\build\CTK-build\Libs\itk\itkExport.h(18): message : see previous definition of 'ITK_EXPORT' [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>  G:\programming\cpp\CTK\Libs\itk\itkVector.h(23,10): fatal error C1083: Cannot open include file: 'vnl/vnl_vector_ref.h': No such file or directory [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>    itkImageRegionSplitterSlowDimension.cxx
4>  G:\programming\cpp\CTK\Libs\itk\itkMacro.h(1142,1): warning C4005: 'ITK_EXPORT': macro redefinition [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>  G:\programming\cpp\CTK\build\CTK-build\Libs\itk\itkExport.h(18): message : see previous definition of 'ITK_EXPORT' [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>  G:\programming\cpp\CTK\Libs\itk\itkVector.h(23,10): fatal error C1083: Cannot open include file: 'vnl/vnl_vector_ref.h': No such file or directory [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>    itkProcessObject.cxx
4>  G:\programming\cpp\CTK\Libs\itk\itkMacro.h(1142,1): warning C4005: 'ITK_EXPORT': macro redefinition [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>  G:\programming\cpp\CTK\build\CTK-build\Libs\itk\itkExport.h(18): message : see previous definition of 'ITK_EXPORT' [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>  G:\programming\cpp\CTK\Libs\itk\itkVector.h(23,10): fatal error C1083: Cannot open include file: 'vnl/vnl_vector_ref.h': No such file or directory [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>    itkDirectory.cxx
4>  G:\programming\cpp\CTK\Libs\itk\itkMacro.h(1142,1): warning C4005: 'ITK_EXPORT': macro redefinition [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>  G:\programming\cpp\CTK\build\CTK-build\Libs\itk\itkExport.h(18): message : see previous definition of 'ITK_EXPORT' [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>  G:\programming\cpp\CTK\Libs\itk\itkDirectory.h(22,10): fatal error C1083: Cannot open include file: 'itksys/Directory.hxx': No such file or directory [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>    itkNumericTraitsVectorPixel.cxx
4>  G:\programming\cpp\CTK\Libs\itk\itkMacro.h(1142,1): warning C4005: 'ITK_EXPORT': macro redefinition [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>  G:\programming\cpp\CTK\build\CTK-build\Libs\itk\itkExport.h(18): message : see previous definition of 'ITK_EXPORT' [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>  G:\programming\cpp\CTK\Libs\itk\itkVector.h(23,10): fatal error C1083: Cannot open include file: 'vnl/vnl_vector_ref.h': No such file or directory [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>    itkProgressReporter.cxx
4>  G:\programming\cpp\CTK\Libs\itk\itkMacro.h(1142,1): warning C4005: 'ITK_EXPORT': macro redefinition [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>  G:\programming\cpp\CTK\build\CTK-build\Libs\itk\itkExport.h(18): message : see previous definition of 'ITK_EXPORT' [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>    Generating Code...
4>    Compiling...
4>    itkPoolMultiThreader.cxx
4>  G:\programming\cpp\CTK\Libs\itk\itkMacro.h(1142,1): warning C4005: 'ITK_EXPORT': macro redefinition [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>  G:\programming\cpp\CTK\build\CTK-build\Libs\itk\itkExport.h(18): message : see previous definition of 'ITK_EXPORT' [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]
4>  G:\programming\cpp\CTK\Libs\itk\itkVector.h(23,10): fatal error C1083: Cannot open include file: 'vnl/vnl_vector_ref.h': No such file or directory [G:\programming\cpp\CTK\build\CTK-build\Libs\itk\CTKitk.vcxproj]

@al-sabr
Copy link
Contributor Author

al-sabr commented Feb 9, 2021

Missing elements in Visual Studio 2019 Project Property Pages

@al-sabr al-sabr changed the title Integrating KWSys into CTK as a library Integrating KWSys & VNL+VCL into CTK as external libraries Feb 9, 2021
@jcfr
Copy link
Member

jcfr commented Feb 9, 2021

re: ITK error

The current version used in CTK is old, consider re-basing on top of #951

@al-sabr
Copy link
Contributor Author

al-sabr commented Feb 9, 2021

How can I achieve your advice? By the way both KWSYS(itksys) & VXL compile successfully but are somehow not linked by CTK.

The only library which is not compiling is https:/al-sabr/CTK/tree/ctk-blueberry-port-from-mitk/Libs/itk

I think that I added everything as dependencies : https:/al-sabr/CTK/blob/f7c8c98630a86db70b349ef49c53e3a675748b49/Libs/itk/target_libraries.cmake#L7

Am I linking the wrong target names or what?

The generated folder is itksys as supposed:

Due to

@jcfr
Copy link
Member

jcfr commented Feb 9, 2021

I noticed that the following library have been added to your topic, I would suggest to remove these:

re: qtsingleapplication (https:/al-sabr/CTK/tree/f7c8c98630a86db70b349ef49c53e3a675748b49/Libs/qtsingleapplication)

This one should probably be contributed in its own CTK pull request or we could re-assess if it is really needed. Reading this post was informative: https://stackoverflow.com/questions/17937618/how-to-use-qtsingleapplication#17937747

Last, since there is a maintained project for Qt5 and Qt6, I would prefer we use this instead of maintaining our own .... https:/itay-grudev/SingleApplication

@jcfr
Copy link
Member

jcfr commented Feb 9, 2021

Am I linking the wrong target names or what?

Sadly, I do not have the bandwidth to review in details.

That said, there are few red flags to address:

  • A Library called itk inside CTK should probably not be added. May be useful classes could be contributed to upstream ITK or to an independent ITK module (see https://itk.org/ITKSoftwareGuide/html/Book1/ITKSoftwareGuide-Book1ch9.html#x50-1430009)
  • The namespace associated with KWSys should not be itksys as it is "reserved" for ITK project. We should really avoid KWSys as a dependency.
  • Adding VNL as a direct dependency is likely out of the scope of CTK

The plugins living in the Plugins directory of CTK are expected to be CTK plugins, your branch integrates a different flavor of plugins following the "blueberry" paradigm.

It may be worth to step back and try to understand the following:

  • What is the current usage of the CTK plugins infrastructure ? my understanding is that it was intended to be used in MITK (@nolden may be able to comment further)
  • Is there a way to work on a roadmap where we would deprecate (or update) CTK plugins ? I really would like to avoid having to maintain multiple plugin mechanism.

cc: @pieper @lassoan @nolden

@saschazelzer
Copy link
Member

saschazelzer commented Feb 9, 2021 via email

@al-sabr
Copy link
Contributor Author

al-sabr commented Feb 9, 2021

@jcfr My goal right now is to modularize the CTKitk to get rid of ITK in its whole, What you are suggesting I will consider for the next stages but I only want to be able to have my CTK, PluginFramework, Blueberry & my Workspace so that I can start to build my app.

I don't want at the moment to remove those :

This is my last compilation error and I am not compiling anything which is depending on ITK neither VTK.

I didn't activated the ImageProcessing library or Vizualisation library.

As I said I want to remove any Libs or Apps or Plugins which are DMTK ITK VTK or any other TK dependant ending libraries.

Is there any bug with the handling of external dependencies by CTK for the following?

set(target_libraries
  KWSYS_LIBRARIES
  VXL_LIBRARIES
  ITKSYS_LIBRARIES
  VCL_LIBRARIES VNL_LIBRARIES
  CTKCore
)

@jcfr
Copy link
Member

jcfr commented Feb 9, 2021

BlueBerry plugins are CTK plugins. [...] CTK Plugin Framework as "not maintained" [...] People could be pointed to CppMicroServices

@saschazelzer

Thanks for your input, this is really helpful and informative. I will write an email on the CTK list and create an issue accordingly so that we can move forward.

it lacks some plugins present in CTK though

Do you recall the details ?

@jcfr
Copy link
Member

jcfr commented Feb 9, 2021

Is there any bug with the handling of external dependencies by CTK for the following?

@al-sabr

The following file should be updated as well: https:/al-sabr/CTK/blob/f7c8c98630a86db70b349ef49c53e3a675748b49/CMake/ctkBlockCheckDependencies.cmake#L64-L113

@al-sabr
Copy link
Contributor Author

al-sabr commented Feb 10, 2021

I am now having errors from CMake:

CMake Error at CMakeLists.txt:1164 (find_package):
4>    By not providing "FindKWSYS.cmake" in CMAKE_MODULE_PATH this project has
4>    asked CMake to find a package configuration file provided by "KWSYS", but
4>    CMake did not find one.
4>
4>    Could not find a package configuration file provided by "KWSYS" with any of
4>    the following names:
4>
4>      KWSYSConfig.cmake
4>      kwsys-config.cmake
4>
4>    Add the installation prefix of "KWSYS" to CMAKE_PREFIX_PATH or set
4>    "KWSYS_DIR" to a directory containing one of the above files.  If "KWSYS"
4>    provides a separate development package or SDK, be sure it has been
4>    installed.
4>

I found this file and tried to add it in the CMake folder but not success!

https:/lbaehren/CMakeModules/blob/master/FindKWSys.cmake

3>  -- target_info=
3>  -- target_info_list=G:/programming/cpp/CTK/Applications/ctkXnatTreeBrowser;CTK_APP_ctkXnatTreeBrowser;ctkXnatTreeBrowser
3>  -- target_project_name=ctkXnatTreeBrowser
3>  -- type=
3>  -- v=
3>  -- varname=
3>  -- verbose=0
3>  -- Unable to find KWSYS header files!
3>  CMake Error at CMake/FindKWSys.cmake:94 (message):
3>  -- Unable to find KWSYS library files!
3>    Could not find KWSYS!
3>  Call Stack (most recent call first):
3>    CMakeLists.txt:1164 (find_package)
3>
3>
3>  -- Configuring incomplete, errors occurred!

I could not test this one neither : https:/OpenMBIR/OpenMBIR-TEM/blob/master/Support/cmp/Modules/FindVXL.cmake

I found this tutorial which says that FindXXX.cmake files are not good : https://cliutils.gitlab.io/modern-cmake/chapters/install.html

@al-sabr
Copy link
Contributor Author

al-sabr commented Feb 10, 2021

I really don't know what to do yet! I am out of options ...

@jcfr
Copy link
Member

jcfr commented Feb 10, 2021

Since the itk part of blueberry project already depends on itksys (see here), you should not have to include the FindKWSys.cmake. Instead, you should have to configure KWSys so that it generate the itksys namespace. See here

But again, all files in the itk library of blueberry are already maintained in ITK itself, if you compile ITK statically ... it would have a very low footprint and likely achieve the same thing.

@al-sabr
Copy link
Contributor Author

al-sabr commented Feb 10, 2021

As you can see here I initialized the namespace:

al-sabr/CTK@a523ed3

For the sake of understanding and getting better in CMake I am trying to remove all external dependencies and have a clean slate.

I don't get it why KWSYS & VXL are compiling super smooth but are not linked. I want to understand why this beast of CMake is behaving weird.

You can also see that I applied your recommendations : https:/al-sabr/CTK/blob/a523ed3a183793c6bdc8d789df12455d27ca3783/CMake/ctkBlockCheckDependencies.cmake#L64

I am pretty sure it is something really small detail which is hindering me.

@al-sabr
Copy link
Contributor Author

al-sabr commented Feb 10, 2021

@jcfr I tried your suggestion with ITK at the end and still it doesn't work:

@jcfr
Copy link
Member

jcfr commented Feb 10, 2021

I tried your suggestion with ITK at the end and still it doesn't work:

Thanks for moving in that direction, removing the copy of ITK files and using the official built statically is the most sustainable path forward.

Now, to address the issue regarding the static build of ITK. Could you post the options you used to configure it on the ITK forum. See https://discourse.itk.org/.

You post should include step for reproducing the problem using instructions like these where you will use correct values instead of placeholders:

git clone ...
cmake -G "" -A "" -DOPT1:STRING= .... 
cmake --build C:\path\to\build --config Release -- /maxcpucount:8

@jcfr
Copy link
Member

jcfr commented Feb 10, 2021

It also looks like the CTKmitk library is not calling find_package(ITK COMPONENTS NameOfComponent1 ... REQUIRED) ...

@al-sabr
Copy link
Contributor Author

al-sabr commented Feb 10, 2021

This is the full log : https://pastebin.com/RRxxNci2

I am using CMake GUI and CTKmitk has this:

Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19041.
Generated: G:/programming/cpp/CTK/build/DGraphInput-alldep.txt
Generated: G:/programming/cpp/CTK/build/DGraphInput-alldep-withext.txt
Generated: G:/programming/cpp/CTK/build/DGraphInput.txt
SuperBuild - First pass
SuperBuild - First pass - done
SuperBuild - Log4Qt[OPTIONAL]
SuperBuild - VTK[OPTIONAL]
SuperBuild - PythonQt[OPTIONAL]
SuperBuild - DCMTK[OPTIONAL]
SuperBuild - ZMQ[OPTIONAL]
SuperBuild - QtSOAP[OPTIONAL]
SuperBuild - qxmlrpc[OPTIONAL]
SuperBuild - qRestAPI[OPTIONAL]
SuperBuild - OpenIGTLink[OPTIONAL]
SuperBuild - QtTesting[OPTIONAL]
SuperBuild - CTK => Requires ITK,
SuperBuild - ITK[OK]
SuperBuild - CTK[OK]
Configuring done
Generating done
set(target_libraries
ITK_LIBRARIES
  CTKCore
  CTKmbilog
)

Ticket ITK : https://discourse.itk.org/t/compiling-ctk-with-itk-activated-fails/3855

@dzenanz
Copy link
Contributor

dzenanz commented Feb 10, 2021

The first error is this:

gdcmSystem.cxx
2>  G:\programming\cpp\CTK\build\ITK\Modules\ThirdParty\GDCM\src\gdcm\Source\Common\gdcmSystem.cxx(812,3): error C3861: 'gettimeofday''rusage' uses undefined struct 'rusage' [G:\programming\cpp\CTK\build\ITK-build\Modules\ThirdParty\HDF5\src\itkhdf5\src\hdf5-static.vcxproj]
2>  G:\programming\cpp\CTK\build\ITK\Modules\ThirdParty\HDF5\src\itkhdf5\src\H5timer.c(126,5): error C2065: 'RUSAGE_SELF': undeclared identifier [G:\programming\cpp\CTK\build\ITK-build\Modules\ThirdParty\HDF5\src\itkhdf5\src\hdf5-static.vcxproj]
2>  G:\programming\cpp\CTK\build\ITK\Modules\ThirdParty\HDF5\src\itkhdf5\src\H5timer.c(127,35): error C2224: left of '.ru_utime' must have struct/union type [G:\programming\cpp\CTK\build\ITK-build\Modules\ThirdParty\HDF5\src\itkhdf5\src\hdf5-static.vcxproj]
2>  G:\programming\cpp\CTK\build\ITK\Modules\ThirdParty\HDF5\src\itkhdf5\src\H5timer.c(128,36): error C2224: left of '.ru_utime' must have struct/union type [G:\programming\cpp\CTK\build\ITK-build\Modules\ThirdParty\HDF5\src\itkhdf5\src\hdf5-static.vcxproj]
2>  G:\programming\cpp\CTK\build\ITK\Modules\ThirdParty\HDF5\src\itkhdf5\src\H5timer.c(129,35): error C2224: left of '.ru_stime' must have struct/union type [G:\programming\cpp\CTK\build\ITK-build\Modules\ThirdParty\HDF5\src\itkhdf5\src\hdf5-static.vcxproj]
2>  G:\programming\cpp\CTK\build\ITK\Modules\ThirdParty\HDF5\src\itkhdf5\src\H5timer.c(130,36): error C2224: left of '.ru_stime' must have struct/union type [G:\programming\cpp\CTK\build\ITK-build\Modules\ThirdParty\HDF5\src\itkhdf5\src\hdf5-static.vcxproj]

I don't remember seeing this error before. Is this coming from GDCM, HDF5, or somehow their interaction?

@al-sabr
Copy link
Contributor Author

al-sabr commented Feb 10, 2021

Look at the screenshots it is detailed.

New log with more details : https://pastebin.com/HNx6QBam

CMake Error at build/ITK/CMake/ITKModuleAPI.cmake:78 (message):
2>    No such module: "ITKSYS"
2>  Call Stack (most recent call first):
2>    build/ITK/CMake/ITKModuleAPI.cmake:31 (itk_module_load)
2>    build/ITK/CMake/ITKModuleAPI.cmake:129 (_itk_module_config_recurse)
2>    build/ITK-build/ITKConfig.cmake:83 (itk_module_config)
2>    Libs/mitk/CMakeLists.txt:3 (find_package)
2>
2>
2>  -- Configuring incomplete, errors occurred!

@al-sabr
Copy link
Contributor Author

al-sabr commented Feb 11, 2021

What do you think the problem is ! How can I deactivate the build for ITKGDCM?

Can this be the solution for the compiling error : https://gist.github.com/ugovaretto/5875385

Guys why is this so complicated I just want to use my port of Blueberry!

@al-sabr
Copy link
Contributor Author

al-sabr commented Feb 12, 2021

Is there any one who still reading this ticket ?

@dzenanz
Copy link
Contributor

dzenanz commented Feb 12, 2021

When compiling ITK, you can turn off a CMake setting ITK_BUILD_DEFAULT_MODULES, then you will be able to turn on and off modules per group. If you turn of a group, then you will be able to turn on/off individual modules from that group. Use CMake-GUI to experiment with this to figure out which settings you need to pass to ITK in superbuild to turn off GDCM.

@al-sabr
Copy link
Contributor Author

al-sabr commented Feb 12, 2021

What are the basic low footprint required modules for ITK to compile with KWSys & VXL

@dzenanz
Copy link
Contributor

dzenanz commented Feb 12, 2021

Only ITKCommon (the base module). It depends on VNL and KWSys, I belive.

@al-sabr
Copy link
Contributor Author

al-sabr commented Feb 12, 2021

Is there any kind of setting for basic compile ?

@dzenanz
Copy link
Contributor

dzenanz commented Feb 12, 2021

Disable all modules except ITKCommon, and use default settings for the rest?

@al-sabr
Copy link
Contributor Author

al-sabr commented Feb 12, 2021

There is no other options even when I created a variable in CMake with ITK_BUILD_DEFAULT_MODULES = OFF

Created a ticket : https://discourse.itk.org/t/only-necessary-to-compile-itkcommon-with-kwsys-vxl/3863

@al-sabr
Copy link
Contributor Author

al-sabr commented Feb 13, 2021

I found this blog post concerning ITK and settings : https://blog.kitware.com/advance-itk-with-modules/

But what is weird is that in CTK no ITK_BUILD_DEFAULT_MODULES is appearing to be deactivated in the CMake GUI.

There is only a few options which are available after the first configure.

I added the Module_XXXX by myself !

When I use the command line I get this message:

PS G:\programming\cpp\CTK\build> cmake .. -DITK_BUILD_DEFAULT_MODULES:BOOL=OFF
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19041.
-- Generated: G:/programming/cpp/CTK/build/DGraphInput-alldep.txt
-- Generated: G:/programming/cpp/CTK/build/DGraphInput-alldep-withext.txt
-- Generated: G:/programming/cpp/CTK/build/DGraphInput.txt
-- SuperBuild - First pass
-- SuperBuild - First pass - done
-- SuperBuild - Log4Qt[OPTIONAL]
-- SuperBuild - VTK[OPTIONAL]
-- SuperBuild - PythonQt[OPTIONAL]
-- SuperBuild - DCMTK[OPTIONAL]
-- SuperBuild - ZMQ[OPTIONAL]
-- SuperBuild - QtSOAP[OPTIONAL]
-- SuperBuild - qxmlrpc[OPTIONAL]
-- SuperBuild - qRestAPI[OPTIONAL]
-- SuperBuild - OpenIGTLink[OPTIONAL]
-- SuperBuild - QtTesting[OPTIONAL]
-- SuperBuild - CTK => Requires ITK,  
-- SuperBuild -   ITK[OK]
-- SuperBuild - CTK[OK]
-- Configuring done
-- Generating done
CMake Warning:
 Manually-specified variables were not used by the project:

   ITK_BUILD_DEFAULT_MODULES

@al-sabr
Copy link
Contributor Author

al-sabr commented Feb 14, 2021

Trying to move basic KWSys & VXL in independant module : InsightSoftwareConsortium/ITK#2298

@thewtex
Copy link
Contributor

thewtex commented Feb 15, 2021

But what is weird is that in CTK no ITK_BUILD_DEFAULT_MODULES is appearing to be deactivated in the CMake GUI.

@al-sabr since this is a SuperBuild, i.e. a CMake build that coordinates the build of other projects, options are only available for the SuperBuild in the CMake GUI, not the component projects, e.g. ITK.

@al-sabr
Copy link
Contributor Author

al-sabr commented Feb 18, 2021

The integration was successfully completed with a custom ITK version that I need to work a little bit more on so that it doesn't break Core/Common.

@dzenanz
Copy link
Contributor

dzenanz commented Feb 18, 2021

A bit longer explanation is given here: InsightSoftwareConsortium/ITK#2325 (comment). This issue can be closed (I don't have permission to do it myself).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

5 participants