# generated source by external project

**URL:** <https://discourse.cmake.org/t/generated-source-by-external-project/3081>\
**Category:** Code\
**Tags:** gen:ninja\
**Created:** [April 3, 2021, 11:42am UTC](https://discourse.cmake.org/t/generated-source-by-external-project/3081 "2021-04-03T11:42:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MBZ](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mbz/32/268_2.png) [@MBZ](https://discourse.cmake.org/u/MBZ)\
**Post date:** [April 3, 2021, 11:42am UTC](https://discourse.cmake.org/t/generated-source-by-external-project/3081/1 "2021-04-03T11:42:00Z")

</div>

I have ExternalProject that builds static library _libfoo.a_  
My shared library is linked with foo.a using:  
target\_link\_libraries ( proj PRIVATE \<FULL\_PATH\>/libfoo.a )

But, I get an error:  
ninja: error: ‘\<FULL\_PATH\>/libfoo.a’, needed by ‘libproj.so’, missing and no known rule to make it

I tried to use:  
set\_source\_files\_properties ( \<FULL\_PATH\>/libfoo.a PROPERTIES GENERATED TRUE )  
but this did not help

---

<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:** [April 3, 2021, 1:48pm UTC](https://discourse.cmake.org/t/generated-source-by-external-project/3081/2 "2021-04-03T13:48:53Z")

</div>

Ninja sees the path and doesn’t know that the external project will build it, so it errors. You’d need to inform that the path is an output of the relevant `ExternalProject` somehow. I don’t think there’s a way to do this today though.

Generally, mixing `ExternalProject` in with regular `add_library` calls doesn’t work too well. I’d recommend using `FetchContent` instead.

---

<div class="post-metadata">

**Author:** ![fenrir](https://discourse.cmake.org/user_avatar/discourse.cmake.org/fenrir/32/734_2.png) [@fenrir](https://discourse.cmake.org/u/fenrir)\
**Post date:** [April 3, 2021, 1:55pm UTC](https://discourse.cmake.org/t/generated-source-by-external-project/3081/3 "2021-04-03T13:55:44Z")

</div>

If `libfoo` is not a CMake project then there’s always the superbuild pattern also.
