Open lucasmyers97 opened 2 years ago
Should still go through this, but this comment should clarify: From the CMake documentation
"Generally, a dependency should be specified in a use of target_link_libraries() with the PRIVATE keyword if it is used by only the implementation of a library, and not in the header files. If a dependency is additionally used in the header files of a library (e.g. for class inheritance), then it should be specified as a PUBLIC dependency. A dependency which is not used by the implementation of a library, but only by its headers should be specified as an INTERFACE dependency. The target_link_libraries() command may be invoked with multiple uses of each keyword"
Basically:
PRIVATE
when the linked entity is only used in the .cpp
file.PUBLIC
when the linked entity is used in the .hpp
and .cpp
filesINTERFACE
when the linked entity is only used in the .hpp
file.
When you link libraries with CMake you must include a PUBLIC, PRIVATE, and INTERFACE keyword. I am unsure which to use when, but it appears that if I use PRIVATE then oftentimes the include directories are not linked downstream so that it throws an error when trying to include a file from a dependency (which is more than one node up the graph). In this case I don't really understand the use of the keywords, but I think using the proper one must be important for good software design.