Hello!
I want create cmake project in following structure:
-amazon-freertos
-components
-src
- main.c
CMakeLists.txt
and the CMakeLists.txt looks like this :
cmake_minimum_required(VERSION 3.13)
project(freertos_examples)
add_executable(my_app src/main.c)
#Tell IDF build to link against this target.
set(IDF_PROJECT_EXECUTABLE my_app)
#Add FreeRTOS as a subdirectory. AFR_BOARD tells which board to target.
set(AFR_BOARD espressif.esp32_devkitc CACHE INTERNAL “”)
add_subdirectory(freertos)
#Link against the mqtt library so that we can use it. Dependencies are transitively
#linked.
target_link_libraries(my_app PRIVATE AFR::mqtt)
target_link_libraries(my_app PRIVATE AFR::freertos)
target_link_libraries(my_app PRIVATE AFR::kernel)
but the problem is in the following Cmake lines :
add_executable(my_app src/main.c)
#Tell IDF build to link against this target.
set(IDF_PROJECT_EXECUTABLE my_app)
when i use my_app in these two lines above as All the CMakeLists Example I have seen online i get the error that says : add_executable cannot create target “my_app” because another target with
the same name already exists. The existing target is an executable created
in source directory
To solve that i changed those two lines as following :
add_executable(my_app src/main.c)
#Tell IDF build to link against this target.
set(IDF_PROJECT_EXECUTABLE my_app2) #replaced my_app with my_app2
after this I can generate the build directory.
however when i run command : cmake --build build i get following errors :
FAILED: my_app
cmd.exe /C “cd . && C:\Users\Naitik.espressif\tools\xtensa-esp32-elf\esp-2020r3-8.4.0\xtensa-esp32-elf\bin\xtensa-esp32-elf-g++.exe -mlongcalls -Wl,–gc-sections -Wl,–cref -Wl,–Map=aws_demos.map -Wl,–undefined=uxTopUsedPriority @CMakeFiles\my_app.rsp -o my_app && cd .”
c:/users/naitik/.espressif/tools/xtensa-esp32-elf/esp-2020r3-8.4.0/xtensa-esp32-elf/bin/…/lib/gcc/xtensa-esp32-elf/8.4.0/…/…/…/…/xtensa-esp32-elf/bin/ld.exe: cannot open linker script file esp32.project.ld: No such file or directory
collect2.exe: error: ld returned 1 exit status
[1784/1804] Generating ld/esp32.project.ld
ninja: build stopped: subcommand failed.
can you please Help me to understand why CMakeLists.txt from examples is not working.
I went through the forum post you’ve linked but its seems like CMake file there consists microchip related directories as well I tried to remove those and edited for esp32 and specified src/main.c but that neither worked for me.