Using CMake to develop with mongoc lib

Hello, I am still new to CMake and try to use the mongoc driver. I don’t want to use install feature, I just wish to have my dependencies as git submodules in my main git repository.
This is my folder hierarchy with two dependencies submodules, poco and mongoc.

Then in my top CMake file I add this:

target_link_libraries(tests PUBLIC Poco::Foundation)
target_link_libraries(tests PUBLIC mongo::mongoc_shared)

For the last line which links with library mongo_shared, I just copied what I found in the hello_mongo example.
For some reason I’ve not grasped yet, when doing this, I get the following error:

CMake Error at CMakeLists.txt:12 (target_link_libraries):
  Target "tests" links to:


  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

To fix this, I need to replace “mongo::mongoc_shared” with just “mongoc_shared”, thus removing the namespace mongo, when the same works for namespace Poco.

What did I miss there?

I could fake it with an alias like this:

add_library(mongo::mongoc_shared ALIAS mongoc_shared)

so I guess it was the find_package which is ultimately responsible for creating the namespace mongo:: but I could not figure out how, comparing with what Poco does, given I do not use find_package for Poco linking.