lucasmyers97 / maier-saupe-lc-hydrodynamics

Work at University of Minnesota using finite element methods to simulate hydrodynamics of liquid crystals with a Maier-Saupe field theory free energy
4 stars 0 forks source link

Use proper keyword when linking libraries with CMake #24

Open lucasmyers97 opened 2 years ago

lucasmyers97 commented 2 years ago

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.

lucasmyers97 commented 1 year 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: