https://simpleitk.readthedocs.io/en/master/link_CppCMake_docs.html
The project is not used target_include_directories
I am confuse about when to use the target_include_directories
https://simpleitk.readthedocs.io/en/master/link_CppCMake_docs.html
The project is not used target_include_directories
I am confuse about when to use the target_include_directories
Use target_include_directories
if you need to add a path to header files, that is not a part of any linked targets.
In the example you mentioned, I suspect the SimpleITK_LIBRARIES
actually contains a list of CMake targets to link, not libraries (like *.so, or *.a). CMake targets carry the information about include directories with them, thus there’s no need to use target_include_directories
.
Do you have the method to know whether the target include directories with them?
or
for a good cmake project, we should use target_include_directories and target_link_libraries? Both are necessary
If you have a target, it carries the include directories with it (unless there’s a bug).
I simply test if the oldest version of the required lib that I want to support in the oldest CMake version I want to support provides a correct target. If not - make adjustments.
This is basically something you need to test for each dependency separately. Rule of the thumb would be: if there’s a target - use it. First when that does not work you need to start thinking