9

I am trying to add FreeRtos to a project of mine using cmake and eclipse but I am getting an error. I am running debian 10 and my cmake version is 3.13.4. The files for cmake can be found at this git repo. When I run the following command:

frank@debian:~/temp2/build$ cmake ../../temp2/AM335X-FreeRTOS-lwip/ -G"Eclipse CDT4 - Unix Makefiles"

I get the following error:

    CMake Error at ProjectIncludes.cmake:46 (add_library):
  No SOURCES given to target: lib_third_party_ti_platform_beaglebone
Call Stack (most recent call first):
  CMakeLists.txt:33 (include)


CMake Error at ProjectIncludes.cmake:30 (add_library):
  No SOURCES given to target: lib_third_party_ti_utils
Call Stack (most recent call first):
  CMakeLists.txt:33 (include)


CMake Error at ProjectIncludes.cmake:38 (add_library):
  No SOURCES given to target: lib_third_party_ti_mmcsdlib
Call Stack (most recent call first):
  CMakeLists.txt:33 (include)


CMake Error at ProjectIncludes.cmake:54 (add_library):
  No SOURCES given to target: lib_third_party_ti_nandlib
Call Stack (most recent call first):
  CMakeLists.txt:33 (include)


CMake Error at CMakeLists.txt:15 (add_executable):
  No SOURCES given to target: freeRTOSBBB.elf


CMake Error at ProjectIncludes.cmake:23 (add_library):
  No SOURCES given to target: lib_third_party_ti_drivers
Call Stack (most recent call first):
  CMakeLists.txt:33 (include)


CMake Error at ProjectIncludes.cmake:115 (add_library):
  No SOURCES given to target:
  lib_third_party_amazon_freertos_kernel_portable_MemMang
Call Stack (most recent call first):
  CMakeLists.txt:33 (include)


CMake Error at ProjectIncludes.cmake:86 (add_library):
  No SOURCES given to target:
  lib_third_party_amazon_libraries_3rdparty_lwip_src
Call Stack (most recent call first):
  CMakeLists.txt:33 (include)


CMake Error at ProjectIncludes.cmake:101 (add_library):
  No SOURCES given to target: src_portable_lwip_ports_cpsw_netif
Call Stack (most recent call first):
  CMakeLists.txt:33 (include)


CMake Error at ProjectIncludes.cmake:106 (add_library):
  No SOURCES given to target: lib_third_party_amazon_freertos_kernel
Call Stack (most recent call first):
  CMakeLists.txt:33 (include)


CMake Error at ProjectIncludes.cmake:111 (add_library):
  No SOURCES given to target:
  src_portable_FreeRTOS_portable_GCC_ARM_CA8_amm335x
Call Stack (most recent call first):
  CMakeLists.txt:33 (include)


CMake Error at ProjectIncludes.cmake:65 (add_library):
  No SOURCES given to target: lib_third_party_ti_system_config_armv7a
Call Stack (most recent call first):
  CMakeLists.txt:33 (include)


CMake Error at ProjectIncludes.cmake:134 (add_library):
  No SOURCES given to target: src_application
Call Stack (most recent call first):
  CMakeLists.txt:33 (include)


CMake Error at ProjectIncludes.cmake:120 (add_library):
  No SOURCES given to target: src_portable_AM335X
Call Stack (most recent call first):
  CMakeLists.txt:33 (include)


CMake Error at ProjectIncludes.cmake:129 (add_library):
  No SOURCES given to target: src_portable_ported_aws_bufpool
Call Stack (most recent call first):
  CMakeLists.txt:33 (include)
Gulzar
  • 23,452
  • 27
  • 113
  • 201
programmer25
  • 375
  • 1
  • 2
  • 14
  • In the README [they suggest](https://github.com/kryochronic/AM335X-FreeRTOS-lwip#steps-to-build) to run python script `AM335xFreeRTOS_cmake_makefile_args.py`. Have you tried that approach? – Tsyvarev Dec 22 '20 at 21:55
  • @Tsyvarev yes i have ran that file without any errors – programmer25 Dec 22 '20 at 22:00
  • So, if the python script works, why do you run `cmake` by yourself? – Tsyvarev Dec 22 '20 at 22:01
  • The command that i entered is supposed to generate project files for eclipse – programmer25 Dec 22 '20 at 22:06
  • Their script most likely runs `cmake` with specific arguments. So you need pass the same arguments in your case. They won't create a complex python script for just run `cmake` without additional options, don't you think so? – Tsyvarev Dec 22 '20 at 23:02

2 Answers2

5

The error says what it means: there are no sources for libraries.

#adding entries for lib_third_party_ti_mmcsdlib
    include_directories("${PROJECT_SOURCE_DIR}/lib/third_party/ti/mmcsdlib")
    include_directories("${PROJECT_SOURCE_DIR}/lib/third_party/ti/mmcsdlib/include")
    add_library(lib_third_party_ti_mmcsdlib "") # NO SOURCES HERE!!!!
    target_compile_definitions(lib_third_party_ti_mmcsdlib 
        PRIVATE -DBOOT=MMCSD -DCONSOLE=UARTCONSOLE
    )
    subdirs("${PROJECT_SOURCE_DIR}/lib/third_party/ti/mmcsdlib")
    subdirs("${PROJECT_SOURCE_DIR}/lib/third_party/ti/mmcsdlib/include")

You should read the docs about add_library in cmake. If you don't provide any source files, you should declare it as INTERFACE

add_library(LibName INTERFACE)

In this case no compilation target would be generated. Otherwise, you can declare it as IMPORTED, then cmake will not try to create a target for compilation either.

For SHARED, STATIC or OBJECT you always need to supply sources.

You should check ProjectIncludes.cmake for what you really want to do: compile new libs or import them.

Sergey Kolesnik
  • 3,009
  • 1
  • 8
  • 28
  • I get this error when i set it to INTERFACE `CMake Error at ProjectIncludes.cmake:47 (target_compile_definitions): target_compile_definitions may only set INTERFACE properties on INTERFACE targets ` – programmer25 Dec 22 '20 at 23:41
  • @programmer25 you should read about cmake modifiers. 'target_compile_definitions(TargetName INTERFACE ...)'. 'PRIVATE' means that preprocessor definitions will be visible only for the target. `PUBLIC` - for target and those who links against it. `INTERFACE` - only for those who links against it. Interface libraries can only have the `INTERFACE` modifier. – Sergey Kolesnik Dec 22 '20 at 23:47
  • The line `add_library(lib_third_party_ti_mmcsdlib "")` isn't wrong by itself: While it creates a library target without adding source file to it, it is possible to add sources **afterwards**. E.g. with [target_sources](https://cmake.org/cmake/help/latest/command/target_sources.html) command. BTW, that possibility to call `add_library` without source files is described in the documentation for [add_library](https://cmake.org/cmake/help/latest/command/add_library.html). – Tsyvarev Dec 23 '20 at 12:34
  • @Tsyvarev no doubt, but if you look into `ProjectIncludes.cmake` from the link, you will not find it either. No sources are added: neither by `add_library` nor by `target_sources` – Sergey Kolesnik Dec 23 '20 at 12:48
  • There is `subdirs("${PROJECT_SOURCE_DIR}/lib/third_party/ti/mmcsdlib")` call, which perfectly could call `target_sources` inside. Why I don't see `CMakeLists.txt` in [this directory](https://github.com/kryochronic/AM335X_StarterWare_02_00_01_01/tree/d8bdb156378074215f4f2a5bdbe9a4714a0228ea/mmcsdlib), that file could be automatically created at some stage. Anyway, you pointed to the file - `ProjectIncludes.cmake` - which belongs to the project which is not written (and is not supported) by the asker. Do you suggest the asker to modify that code? – Tsyvarev Dec 23 '20 at 13:07
4

For me (came here from Google), this error occurred when CMake target_sources had only PRIVATE sources, and no PUBLIC sources.

I had to make at least one PUBLIC source file:

old:

target_sources(${PROJECT_NAME}
        PRIVATE
        External/dbscan.cpp

        main.cpp
        )

new:

target_sources(${PROJECT_NAME}
        PRIVATE
        External/dbscan.cpp

        PUBLIC
        main.cpp
        )
Gulzar
  • 23,452
  • 27
  • 113
  • 201