On 2018-03-08 20:05+0100 Nils Gladitz wrote:

On 08.03.2018 19:50, Alan W. Irwin wrote:
So what are the actual benefits of namespacing the exported targets
associated with libraries?

On the consumer side it makes linking to targets less error prone.

When you link to a library target without a namespace and e.g. get the name or scope wrong CMake will silently assume that you want to link a library by name (e.g. in context of gcc "foo" becomes "-lfoo"). When the library and its headers happens to be in the compiler's standard search directories this might not even get caught at build time right away.

When the library target has a namespace CMake will require the given name to be a target and will fail during generation if the target is not actually available.

Hi Nils:

Thanks for that explanation which convinced me this particular "best
practice" is worth implementing along with the rest mentioned in
<https://pabloariasal.github.io/2018/02/19/its-time-to-do-cmake-right/>.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (freeeos.sf.net); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.sf.net); the libLASi project
(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
and the Linux Brochure Project (lbproject.sf.net).
__________________________

Linux-powered Science
__________________________
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

Reply via email to