cmake同名无法创建(已解决,未深入探究)

问题日志

CMake Error at /home/li/LocalWare/mars-firmware/thirdlib/esp-idf/tools/cmake/component.cmake:471 (add_library):
add_library cannot create target "__idf_WEB" because another target with
the same name already exists.  The existing target is a static library
created in source directory
"/home/li/LocalWare/esp32-camera/examples/camera_example/components/WEB".
See documentation for policy CMP0002 for more details.
Call Stack (most recent call first):
/home/li/LocalWare/mars-firmware/thirdlib/esp-idf/tools/cmake/component.cmake:593 (idf_component_register)
components/WEB/CMakeLists.txt:15 (register_component)

cmake的代码似乎是有两种风格(没有专门学过,有错漏的地方欢迎大佬指点一二)
风格1

set(srcs "./bsp_camera.c"
	)
idf_component_register(SRCS "${srcs}"
                    INCLUDE_DIRS "include"
		    REQUIRES "esp_adc_cal" "freertos" "FactoryTest"
		    #PRIV_REQUIRES nvs_flash bt wfap)
			)

风格2

set(COMPONENT_SRCS "bsp_camera.c" )
set(COMPONENT_ADD_INCLUDEDIRS "include")

set(COMPONENT_REQUIRES
    esp32-camera
   
    )
set(COMPONENT_EMBED_FILES
        "www/index_ov2640.html.gz"
        "www/index_ov3660.html.gz"
        "www/index_ov5640.html.gz"
        "www/monitor.html.gz")
register_component()

问题出现的点在于我使用风格1的camke代码后由于项目需要添加了风格2中的set(COMPONENT_EMBED_FILES "www/index_ov2640.html.gz" "www/index_ov3660.html.gz" "www/index_ov5640.html.gz" "www/monitor.html.gz") register_component()导致了该问题出现。
解决方案为全部改成风格2的方式就没有上述问题了。
但是这样子只能说解决问题,具体的问题产生原因以及cmake的一些编写规范需要各位查证学习。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值