nihui / ncnn_on_esp32

64 stars 9 forks source link

CMake Error #2

Closed nnn112358 closed 3 months ago

nnn112358 commented 6 months ago

Problem Description

When I run "idf.py build", cmake gives an error. Build cannot be completed at this time.

% idf.py build
~~~
~~~
CMake Error at CMakeLists.txt:16 (target_link_libraries):
  The keyword signature for target_link_libraries has already been used with
  the target "main.elf".  All uses of target_link_libraries with a target
  must be either all-keyword or all-plain.

  The uses of the keyword signature are here:

   * /opt/esp-idf-v5.0.5/tools/cmake/project.cmake:608 (target_link_libraries)
   * /opt/esp-idf-v5.0.5/tools/cmake/project.cmake:617 (target_link_libraries)
-- Configuring incomplete, errors occurred!
make: *** [Makefile:1670: cmake_check_build_system] エラー 1
HINT: Projects using target_link_libraries with project_elf explicitly and custom CMake projects must specify PRIVATE, PUBLIC or INTERFACE arguments.
make failed with exit code 2, output of the command is in the /home/user/Desktop/esp-idf/ncnn_on_esp32/build/log/idf_py_stderr_output_61322 and /home/user/Desktop/esp-idf/ncnn_on_esp32/build/log/idf_py_stdout_output_61322

Environment

Solution

Add private to CMakeLists.txt:16 according to the error statement of idf.py build

#Before
target_link_libraries(${CMAKE_PROJECT_NAME}.elf ncnn)

#After fixing
target_link_libraries(${CMAKE_PROJECT_NAME}.elf PRIVATE ncnn)

The problem was resolved by the above fix. I've posted it here so others don't have trouble.

nihui commented 3 months ago

fixed , thanks !