How to compile part of ITK integrated into another library?

For this to be includable via this path, External\KWSys\src should be one of include_directories for ITK.

Isnā€™t it automatically handled by KWSys? Where do I need to add if manually needed?

Is this what I am missing ?

This seemed to clear the compilation error for KWSys:

But although VNL VCL are recognized by Visual Studio 2019 thereā€™s still a compilation error.

I think that vcl_compiler.h is generated during CMake configuration and placed in the build folder. You need to add it to include path.

I kind of made it work but it is really an ugly hack. Let me explain!

Adding this target_link_libraries at : https://github.com/al-sabr/CTK/blob/8af983c5605c8b939c0eb8df35c0bfff54344a07/Libs/mbilog/CMakeLists.txt#L91

Allowed me to compile with mbilog + KWSys & VNL when I open the solution in VS2019 with successful compilation. The problem is the root CMakeLists.txt doesnā€™t compile anymore because of this added hack. Do you understand?

This is how I overcame the compilation errors : Final compilation of mbilog successful. Ā· al-sabr/CTK@d4059dd Ā· GitHub

This is the error I am getting with the root CMakeLists.txt :

1>CUSTOMBUILD : CMake error : install(EXPORT "CTKExports" ...) includes target "CTKmbilog" which requires target "itksys" that is not in any export set.
1>CUSTOMBUILD : CMake error : install(EXPORT "CTKExports" ...) includes target "CTKmbilog" which requires target "itkvnl" that is not in any export set.
1>CUSTOMBUILD : CMake error : install(EXPORT "CTKExports" ...) includes target "CTKmbilog" which requires target "itkvcl" that is not in any export set.

How can I include those external dependencies so that it is recognized inside of my build system?
They are although compiling ā€¦

You need to export itksys, itkvnl and itkvcl in their respective CMakeLists.

Why isnā€™t this already handled automatically by ITK ?

Because you only took part of ITK.

Hehe makes sense! And which part of ITK integrates KWSys & VNL? I would like to learn that part because I donā€™t fully grasp CMake in its entirety.

You probably want to take this part of code for VNL:


and for KWSys some or all of CMake code from

and

Isnā€™t it this which is already there ?

https://github.com/al-sabr/CTK/blob/ctk-blueberry-port-from-mitk/External/VNL/CMakeLists.txt

https://github.com/al-sabr/CTK/blob/ctk-blueberry-port-from-mitk/External/KWSys/src/CMakeLists.txt

https://github.com/al-sabr/CTK/blob/ctk-blueberry-port-from-mitk/External/KWSys/src/KWSys/CMakeLists.txt

All of these are included here : CTK/CMakeLists.txt at 226ce09057fc5c66654d868e079761316a60f7ad Ā· al-sabr/CTK Ā· GitHub

You need to remove this conditional, use add_subdirectory instead of find_package. Maybe something similar for KWSys.

It is already like you suggested CTK/CMakeLists.txt at 226ce09057fc5c66654d868e079761316a60f7ad Ā· al-sabr/CTK Ā· GitHub

But you need the additional code for linking:

  set(ITKVNL_SYSTEM_INCLUDE_DIRS
    ${VXL_NETLIB_INCLUDE_DIR}
    ${VXL_VCL_INCLUDE_DIRS}
    ${VXL_VCL_INCLUDE_DIR}
    ${VXL_CORE_INCLUDE_DIRS}
    ${VXL_CORE_INCLUDE_DIR}
    )
  set(ITKVNL_LIBRARIES vnl_algo vnl v3p_netlib netlib vcl)
  set(ITKVNL_SYSTEM_LIBRARY_DIRS "${VXL_LIBRARY_DIR}")

You might also need to modify it.

Actually in my CMake window I didnā€™t check the ITK_USE_SYSTEM_VXL so it by pass that condition.

@dzenanz We were complicating everything up until now ā€¦ the trick was this :

Although everything seems to be fine with the includes VNL is recognized but not KWSys why do you have an idea?

@dzenanz it seems that adding this line : https://github.com/al-sabr/CTK/blob/36f04e0c5a69162422c5fe86c66d808013bae28d/Libs/mbilog/CMakeLists.txt#L91

Make the compilation goes through but adding it here : https://github.com/al-sabr/CTK/blob/36f04e0c5a69162422c5fe86c66d808013bae28d/Libs/mbilog/target_libraries.cmake#L9

Doesnā€™t recognize itā€¦ is there any bug in KWSys structure?

Since you are changing a lot of defines and directory structure, you might need to change #include "itksys/Directory.h into #include "KWSys/Directory.h or just #include "Directory.h.