# Linking VL53L0X Api

**URL:** <https://discourse.cmake.org/t/linking-vl53l0x-api/1938>\
**Category:** Code\
**Created:** [September 29, 2020, 1:33pm UTC](https://discourse.cmake.org/t/linking-vl53l0x-api/1938 "2020-09-29T13:33:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hack-mike](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/h/5f8ce5/32.png) [@hack-mike](https://discourse.cmake.org/u/hack-mike)\
**Post date:** [September 29, 2020, 1:33pm UTC](https://discourse.cmake.org/t/linking-vl53l0x-api/1938/1 "2020-09-29T13:33:51Z")

</div>

Hi everybody,

I’m new in CMake and I have some difficult to import VL53L0X Api to my ESP-IDF project.

I created inside Api folder this CMake.txt  
 ![image](https://discourse.cmake.org/uploads/default/original/1X/f3bd7921ed8d89937fa24d80397a3e99df516c15.png)

then in main/Cmake.txt I called **add\_subdirectory(/Users/michelemocellin/Desktop/Api VL53L0X)**

But when I reloaded CMake I received this error

**add\_library cannot create target “\_\_idf\_main” because another target with the same name already exists. The existing target is a static library created in source directory**

What am I doing wrong ?  
What is the best way to add that API ?

Hope your help, thank you.

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [November 22, 2020, 7:51pm UTC](https://discourse.cmake.org/t/linking-vl53l0x-api/1938/2 "2020-11-22T19:51:54Z")

</div>

It seems you have a conflicting target name. You’ll need to find and fix it.

Note that for using third-party libraries, `find_package` is generally better than `add_subdirectory(/somewhere/not/in/the/main/project/tree)`.

Cc: @craig.scott
