Need to find/replace all #include with new path which doesn't fit with old path

Hi I am having a problem… I took 2 external projects in another project which compile without any problem. The only problem in my code is that the old #include which are in thousands are not working anymore. I give an example:

This is the old #include style and it cannot be found the way KWSys and VNL are actually compiled and recognized by VS2019.

include <vcl_msvc_warnings.h>

it is recognized only when replaced by

include <src/vxl/vcl/vcl_msvc_warnings.h>

#include “itksys/SystemTools.hxx”

it is recognized only when replaced by

#include “src/itksys/SystemTools.hxx”

I don’t want to find and replace all the files so that it can compile…
How can I fix this bug? Did I forgot something in CMake like a command?

It sounds like either some imported targets are missing interface include directories or you forgot a target_include_directories() with some variable from the project.

Cc: @jcfr

Can you elaborate more about what you said. I kind a not understanding what are interface include directories or target_include_directories…

Here are the CMakeLists.txt files I am talking about :

Also this project:

These are not in my project but are required by my project.

This is the sub-library which is using the 2 former external projects…

Here is the compilation log which shows clearly that many sub-targets are created by CMake and that’s why the #include paths have to be all changed…

I don’t think your approach can work. If you only put part of ITK (part you need) into a folder in your project, there are always going to be some compile errors. To make that work, you would need to significantly alter ITK, which is harder to do than to properly incorporate it via ExternalProject_Add or some other common mechanism.

Actually if you look at this folder I was able to extract all the features (which are minimal from ITK) and was able to make almost a full compilation.

You think that it is not possible? I think my approach is better to learn which part to modularize instead of making things monolith… what do you think?

As ITK incorporates KWSys as part of its source code, include's reflect that in the path. If you don’t put KWSys in the same relative path that ITK expects, than you will most likely need to edit those files to put a different path, or no path, depending on what you set as include_directories in CMake code.

As you can see the output of folder structure is the following:

How come that ITK gets the same output but can use simply the #includes and not me?

I would not like to use this kind of file path #include “src/itksys/SystemTools.hxx”
How can I remove the src and all the other subfolders in a more elegant way? It is worst with VNL which is #include <src/vxl/vcl/vcl_msvc_warnings.h>

I am not as expert as you in CMake that’s why I don’t know which direction I could go to bypass the default folder structure.