This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Zephyr CMake error (No SOURCES given to target) for out of tree driver when CONFIG_BOOTLOADER_MCUBOOT is enabled

Hi,

I've successfully integrated an out of tree driver using the out_of_tree_driver example in the application_development sample folder for Zephyr; it has built and ran fine up to this point.

Recently, I added DFU functionality and along the way added CONFIG_BOOTLOADER_MCUBOOT=y to my prj.conf file. Now that this is added, I get an error when trying to build the project:

MCUBoot bootloader key file: C:/Repos/ml-firmware/nRF_NCS/sdk/v1.5.0/bootloader/mcuboot/root-ec-p256.pem
-- Configuring done
CMake Error at C:/Repos/ml-firmware/nRF_NCS/sdk/v1.5.0/zephyr/cmake/extensions.cmake:416 (add_library):
  No SOURCES given to target: _out_of_tree_driver
Call Stack (most recent call first):
  C:/Repos/ml-firmware/nRF_NCS/drivers/out_of_tree_driver/zephyr/CMakeLists.txt:28 (zephyr_library_named)


CMake Generate step failed.  Build files cannot be regenerated correctly.
CMake Error at C:/Repos/ml-firmware/nRF_NCS/sdk/v1.5.0/nrf/cmake/multi_image.cmake:287 (message):
  CMake generation for mcuboot failed, aborting.  Command: 1
Call Stack (most recent call first):
  C:/Repos/ml-firmware/nRF_NCS/sdk/v1.5.0/nrf/cmake/multi_image.cmake:84 (add_child_image_from_source)
  C:/Repos/ml-firmware/nRF_NCS/sdk/v1.5.0/nrf/modules/mcuboot/CMakeLists.txt:112 (add_child_image)

As you can see, it says "No SOURCES given to target" but I do include them with the zephyr_library_sources_ifdef line in my CMakeLists.txt for the driver (and the relevant CONFIG_DRIVER is set to 'y' in my prj.conf). I'm assuming the problem has to do with the mcuboot child image being created and not inheriting everything it should from the app parent image, but I'm not sure how to solve it.

This is the code that adds my out of tree driver to my project, located in my project folder CMakeLists.txt:

list(APPEND ZEPHYR_EXTRA_MODULES
  ${CMAKE_CURRENT_SOURCE_DIR}/../drivers/out_of_tree_driver
)

And here is an excerpt of the CMakeLists.txt in that driver folder:

zephyr_include_directories(.)
zephyr_library_named("_out_of_tree_driver")
zephyr_library_sources_ifdef(CONFIG_DRIVER            out_of_tree_driver.c)

I've taken a look at section 2.2.2 titled "Modify device tree and configurations of a child image" per the NCS tutorial here, but it's not exactly what I'm looking to do. For reference I'm using NCS v1.5.0.

Thanks in advance for any help!

Parents Reply Children
  • Great, thanks! Yes, I followed the v1.5.0 tutorial. I look forward to hearing from you once you've had a chance to look over the sample.

  • Hello again, 

    I was not able to finish my testing the other day. I did some testing now, and verify what you got. 

    CMake Error at C:/NordicSemi/v1.5.1/zephyr/cmake/extensions.cmake:416 (add_library):
      No SOURCES given to target: lis2dw12
    Call Stack (most recent call first):
      C:/Temp/Support/271083/sample/drivers/lis2dw12/zephyr/CMakeLists.txt:9 (zephyr_library_named)

    Based on the last line CMakeLists.txt:9 (zephyr_library_named), I commented this line out and was able to build with CONFIG_BOOTLOADER_MCUBOOT=y

    Kind regards,
    Øyvind

  • Hi,
    Thanks for your response! I did some more testing in response to your discovery and it turns out that whichever driver comes first in the list(APPEND ZEPHYR_EXTRA_MODULES list is the one that can't be a named library through zephyr_library.
    The project has multiple out of tree drivers, and would like each to show up as a module in my Segger IDE, so I was able to confirm that whichever driver was first in that list couldn't be named or else the project wouldn't compile.
    I was able to get around this problem by creating a dummy driver, with no source or header files, that did not have zephyr_library in its CMakeLists and I included it as the first line in my list(APPEND ZEPHYR_EXTRA_MODULES list in the project CMakeLists and now the subsequent drivers successfully compile, all of them with zephyr_library included in their CMakeLists as well.
    I'm not an expert in cmake so I don't know what's going on for certain, but it is strange to me that this is the case. I'd love to find a cleaner solution rather than rely on this workaround, but I'll keep it in place for now.
Related