我正在尝试使用 cmake 和 eclipse 将 FreeRtos 添加到我的项目中,但出现错误。我运行的是 debian 10,我的 cmake 版本是 3.13.4。 cmake 的文件可以在 this git repo 找到。当我运行以下命令时:
frank@debian:~/temp2/build$ cmake ../../temp2/AM335X-FreeRTOS-lwip/ -G"Eclipse CDT4 - Unix Makefiles"
我收到以下错误:
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)
对于我(来自 Google),当 CMake
target_sources
只有 PRIVATE
源,而没有 PUBLIC
源时,会发生此错误。
我必须制作至少一个
PUBLIC
源文件:
旧:
target_sources(${PROJECT_NAME}
PRIVATE
External/dbscan.cpp
main.cpp
)
新:
target_sources(${PROJECT_NAME}
PRIVATE
External/dbscan.cpp
PUBLIC
main.cpp
)
该错误说明了它的含义:没有库的来源。
#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")
您应该阅读 cmake 中有关 add_library 的文档。如果您不提供任何源文件,则应将其声明为
INTERFACE
add_library(库名称接口)
在这种情况下,不会生成编译目标。 否则,您可以将其声明为
IMPORTED
,那么 cmake 也不会尝试创建编译目标。
对于
SHARED
、STATIC
或 OBJECT
,您始终需要提供来源。
您应该检查
ProjectIncludes.cmake
您真正想要做什么:编译新库或导入它们。
我是从谷歌来到这里的。相同的错误消息,但事实模式不同。
我的开发环境是Windows上的Visual Studio,输出的可执行文件需要在Windows和Linux上运行。 Linux 可执行文件是使用 WSL (Ubuntu) 构建的。
这是我的 CMakeLists.txt 中的相关块
add_executable (
myExecutable
"sourcefile1.cpp"
"sourcefile2.cpp"
...
)
该构建在 Windows 上运行良好,但在 Linux 上则不然。
问题原来是最近添加的一个文件。名称中的字母之一在文件系统中为大写,但 CMakeLists 将其包含为小写(sourcefile2.cpp 与 sourceFile2.cpp)。
问题只存在于一百多个文件中的一个。 CMake 错误消息仍然相同“没有给目标提供源”