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的一些编写规范需要各位查证学习。