# FetchContent with mariadb-connector-cpp

**URL:** <https://discourse.cmake.org/t/fetchcontent-with-mariadb-connector-cpp/6712>\
**Category:** Code\
**Created:** [October 24, 2022, 8:52pm UTC](https://discourse.cmake.org/t/fetchcontent-with-mariadb-connector-cpp/6712 "2022-10-24T20:52:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sampsont](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/fbc32d/32.png) [@sampsont](https://discourse.cmake.org/u/sampsont)\
**Post date:** [October 24, 2022, 8:52pm UTC](https://discourse.cmake.org/t/fetchcontent-with-mariadb-connector-cpp/6712/1 "2022-10-24T20:52:43Z")

</div>

I’m using FetchContent to satisfy the mariadb-connector-cpp dependency for poco. I’m cross-compiling, so I don’t want the library to be installed on my normal system place.

```cmake
include(FetchContent)
FetchContent_Declare(
    mariadb-connector-cpp
    GIT_REPOSITORY https://github.com/mariadb-corporation/mariadb-connector-cpp.git
    GIT_TAG 1.0.2
)

FetchContent_MakeAvailable(mariadb-connector-cpp)

```

During the build, I get this error:

```auto
CMake Error: File /home/dfr/m9kapps/src/maconncpp.rc.in does not exist.

```

because of this line in the mariadb-connector-cpp CMakeLists.txt file:

```cmake
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/src/Version.h.in

```

It looks like the mariadb-connector-cpp CMakeLists.txt file wants you to cd into the root of their cmake project and do the normal; mkdir build; cd build; cmake …

I’m still trying to come up to speed with cmake. Is this telling me that this library is not compatible with FetchContent? Is there something I need to do so that CMAKE\_SOURCE\_DIR in the mariadb-connector-cpp project will point to the correct location?

Thanks!  
Todd

---

<div class="post-metadata">

**Author:** ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)\
**Post date:** [October 24, 2022, 9:37pm UTC](https://discourse.cmake.org/t/fetchcontent-with-mariadb-connector-cpp/6712/2 "2022-10-24T21:37:57Z")

</div>

Their use of `${CMAKE_SOURCE_DIR}` is a typical symptom of a project that doesn’t support being added directly to another parent project. You won’t be able to use `FetchContent` with that project until they replace their use of `CMAKE_SOURCE_DIR` with a variable that is relative to the top of their source tree, not the top of the whole build. That usually means `CMAKE_CURRENT_SOURCE_DIR`, or sometimes a project-specific variable like `PROJECT_SOURCE_DIR` or `<projectName>_SOURCE_DIR`.

---

<div class="post-metadata">

**Author:** ![sampsont](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/fbc32d/32.png) [@sampsont](https://discourse.cmake.org/u/sampsont)\
**Post date:** [October 24, 2022, 9:43pm UTC](https://discourse.cmake.org/t/fetchcontent-with-mariadb-connector-cpp/6712/3 "2022-10-24T21:43:37Z")

</div>

Thanks for your quick response! Can you suggest an alternative approach? I need Marian-connector-cpp to be found by FetchContent while it’s building poco.

---

<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:** [October 25, 2022, 3:49pm UTC](https://discourse.cmake.org/t/fetchcontent-with-mariadb-connector-cpp/6712/4 "2022-10-25T15:49:58Z")

</div>

I would first submit the patch upstream. You can then use that PR branch as your source until a release is made with that fix (and any others that might be relevant).
