On Monday 15 June 2015 16:40:10 Klaim - Joël Lamotte wrote:
> So far I didn't get what imported targets helps with, so I'm a bit lost on
> the usefulness of "namespaces"
> but I am sure that I am missing something.

Imported targets improve the handling of find_package stuff. In the "old days", 
the common pattern for using another library as dependency was as follows:

find_package(XXX)
include_directories( ${XXX_INCLUDE_DIR} )
add_definitions( ${XXX_DEFINITIONS} )
target_link_library(YourTarget ${XXX_LIBRARIES} )

Sometimes you don't need the add_definitions part, and sometimes the variable 
names are a little bit different. Most of the time you inadvertedly add 
definitions and include directories for other targets, too.


With imported targets, you can combine everything that's needed to use a 
library into an imported target, making the above pattern simpler and less 
error-prone:

find_package(XXX)
target_link_library(YourTarget XXX)

With more complex libraries, you often have different components, and that's 
when namespaces come in handy:

find_package(XXX COMPONENTS Base Advanced)
target_link_library(YourTarget XXX::Base)
Find_package(YYY COMPONENTS Base)
target_link_library(YourOtherTarget XXX::Advanced YYY::Base)

Does this answer your question?

Cheers,
  Johannes



-- 

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:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to