# Setting CMake with a library INTERFACE (DS3231)

**URL:** https://discourse.cmake.org/t/setting-cmake-with-a-library-interface-ds3231/15134
**Category:** Usage
**Created:** [August 30, 2025, 9:14pm UTC](https://discourse.cmake.org/t/setting-cmake-with-a-library-interface-ds3231/15134 "2025-08-30T21:14:38Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![SCosimo](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/c5a1d2/32.png) [@SCosimo](https://discourse.cmake.org/u/SCosimo)
#### Post date: [August 30, 2025, 9:14pm UTC](https://discourse.cmake.org/t/setting-cmake-with-a-library-interface-ds3231/15134/1 "2025-08-30T21:14:38Z")

</div>

Hello everyone,

really I don’t understand what’s wrong.

Simple folder tree:

```auto
- Development
  - CMakeLists.txt (1)
  - main.cpp
  - hwconfig.c
  - pico_sdk_import
  - build
  - lib
    - CMakeLists.txt (2)
    - pico-ds3231
       - examples
       - lib
          - CMakeLists.txt (3)
          - ds3231.c
          - include
             - ds3231.h

```

(1)

… raspberry pi pico stuff

add\_subdirectory(lib)

add\_executable(${PROJECT\_NAME}  
main.cpp  
hw\_config.c  
)

target\_include\_directories(app PRIVATE  
lib/pico-ds3231/lib/include  
)

target\_link\_libraries(${PROJECT\_NAME}  
pico\_stdlib  
hardware\_rtc  
pico-ds3231  
)

(2)

add\_subdirectory(pico-ds3231/lib)

(3)

add\_library(pico-ds3231 INTERFACE)

target\_sources(pico-ds3231 INTERFACE  
${CMAKE\_CURRENT\_LIST\_DIR}/ds3231.c  
${CMAKE\_CURRENT\_LIST\_DIR}/include/ds3231.h  
)

target\_include\_directories(FatFs\_SPI INTERFACE  
include  
)

target\_link\_libraries(pico-ds3231 INTERFACE  
hardware\_i2c  
pico\_stdlib  
)

The error is always

[build] [78/79 98% :: 2.912] Linking CXX executable app.elf

[build] FAILED: app.elf

undefined reference to `ds3231\_init(i2c\_inst\*, unsigned char, unsigned char, ds3231\_rtc\*)’

any suggestion?
