# proper way to wrap an imported target around a third-party target

**URL:** https://discourse.cmake.org/t/proper-way-to-wrap-an-imported-target-around-a-third-party-target/2757
**Category:** Usage
**Created:** [February 12, 2021, 4:06pm UTC](https://discourse.cmake.org/t/proper-way-to-wrap-an-imported-target-around-a-third-party-target/2757 "2021-02-12T16:06:58Z")
**Posts on this page:** 1
**Showing post:** 8

<div class="post-metadata">

### Author: ![adaldev](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/9dc877/32.png) [@adaldev](https://discourse.cmake.org/u/adaldev)
#### Post date: [May 17, 2021, 8:47am UTC](https://discourse.cmake.org/t/proper-way-to-wrap-an-imported-target-around-a-third-party-target/2757/8 "2021-05-17T08:47:57Z")

</div>

Hi,

I’m coming back to this thread because I’m a bit stuck with 3rd party libraries that don’t use namespace.  
I require all my dependencies to use namespace for homogeneity.

For instance OpenCV does not provide OpenCV::OpenCV.  
I do this:  
find\_package(${PackName} REQUIRED)  
IF(${PackName}\_FOUND AND NOT TARGET ${PackName}::${PackName})  
add\_library(${PackName}::${PackName} UNKNOWN IMPORTED)  
set\_target\_properties(${PackName}::${PackName} PROPERTIES  
IMPORTED\_LINK\_INTERFACE\_LANGUAGES “CXX”  
IMPORTED\_LOCATION “${${PackName}\_LIBRARIES}”  
INTERFACE\_INCLUDE\_DIRECTORIES “${${PackName}\_INCLUDE\_DIRS}”  
)  
target\_link\_libraries(${TARGET\_NAME} ${Inheritance} ${PackName}::${PackName})  
ENDIF()  
but then I’ve got a build error, telling me that there is no rule to build target opencv\_calib3d required for my target (actually opencv\_calib3d is the first lib in OpenCV\_LIBRARIES)

Besides I do it twice:  
first in a static library L that publicly depends on OpenCV  
then on my application A that depends both on L and on OpenCV

then in the build.make file of A, I see the list of OpenCV libraries twice. The build issues then a warning about an overloaded rule.

What do I miss?  
Is it possible to have also some insights on my more general questions above?

Many thanks in advance  
PS I duplicate the OpenCV related part in another threads as the issue is perhaps more related to opencv than to cmake

---

_[View the full topic](https://discourse.cmake.org/t/proper-way-to-wrap-an-imported-target-around-a-third-party-target/2757)._
