Giter VIP home page Giter VIP logo

Comments (9)

Julusian avatar Julusian commented on May 25, 2024 1

I just hit this issue, and after some digging I figured out the fix:
ustisha/CMake@master...Julusian:patch-1

from arduino-cmake-ng.

MrPointer avatar MrPointer commented on May 25, 2024

Hello @ustisha, please attach your CMakeLists.txt file as well.

from arduino-cmake-ng.

ustisha avatar ustisha commented on May 25, 2024

Sorry i thought example project will be enough
Here is two files
CMakeLists.txt
CMakeLists.txt
Project structure you can check in https://github.com/ustisha/CMake

from arduino-cmake-ng.

MrPointer avatar MrPointer commented on May 25, 2024

@ustisha Actually you're right, my bad.
Usually people embed it in the comment like a code snippet, so I'm used to that pattern.

Regarding your files, I can see 2 problems:

  1. You've set the toolchain file path inside the CMakeLists - It's not recommended and not the way to do it in this framework. Please refer to this wiki page for more info.
  2. It appears from your attached error message that your libraries are located in a non-standard location, that the framework has no way of finding by its own. For that, please refer to the libraries wiki section.

from arduino-cmake-ng.

ustisha avatar ustisha commented on May 25, 2024

@MrPointer Thank you for quick answers.

  1. You are right, removed it.
  2. Maybe i missunderstood wiki, but as I see libraries (or dependencies) directory must be lokated in PROJECT_SOURCE_DIR (for example in my case it is C:/Arduino/CMake/test1) and library directory has name as .cpp and .h files. Include <OneWire.h> and <DallasTemperature.h> in main.cpp works great. Eg
  • CMakeLists.txt
  • test1/CMakeLists.txt
  • test1/main.cpp
  • test1/libraries/DallasTemperature/DallasTemperature.h
  • test1/libraries/OneWire/OneWire.h
message(${ARDUINO_SDK_LIBRARIES_PATH})
message(${PROJECT_SOURCE_DIR})
C:/Program Files (x86)/Arduino/libraries
C:/Arduino/CMake/test1

CMake output

C:\JetBrains\apps\CLion\ch-0\183.4886.39\bin\cmake\win\bin\cmake.exe -DCMAKE_BUILD_TYPE= -DCMAKE_TOOLCHAIN_FILE=arduino-cmake-ng/cmake/Arduino-Toolchain.cmake -G "CodeBlocks - MinGW Makefiles" C:\Arduino\CMake
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Arduino SDK version 1.8.8: C:/Program Files (x86)/Arduino
-- Determined Platform Header: C:/Program Files (x86)/Arduino/hardware/arduino/avr/cores/arduino/Arduino.h
-- Arduino SDK version 1.8.8: C:/Program Files (x86)/Arduino
-- Determined Platform Header: C:/Program Files (x86)/Arduino/hardware/arduino/avr/cores/arduino/Arduino.h
-- Check for working C compiler: C:/Program Files (x86)/Arduino/hardware/tools/avr/bin/avr-gcc.exe
-- Check for working C compiler: C:/Program Files (x86)/Arduino/hardware/tools/avr/bin/avr-gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Arduino SDK version 1.8.8: C:/Program Files (x86)/Arduino
-- Determined Platform Header: C:/Program Files (x86)/Arduino/hardware/arduino/avr/cores/arduino/Arduino.h
-- Check for working CXX compiler: C:/Program Files (x86)/Arduino/hardware/tools/avr/bin/avr-g++.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Arduino/hardware/tools/avr/bin/avr-g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
C:/Program Files (x86)/Arduino/libraries
C:/Arduino/CMake/test1
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Arduino/CMake/cmake-build-default-mingw

[Finished]

Build output

====================[ Build | test1 | Default-MinGW ]===========================
C:\JetBrains\apps\CLion\ch-0\183.4886.39\bin\cmake\win\bin\cmake.exe --build C:\Arduino\CMake\cmake-build-default-mingw --target test1 -- -j 2
[ 80%] Built target mini_atmega328_core_lib
[ 83%] Building CXX object test1/CMakeFiles/DallasTemperature.dir/C_/Program_Files_(x86)/Arduino/libraries/DallasTemperature/DallasTemperature.cpp.obj
[ 90%] Built target OneWire
In file included from C:\Program Files (x86)\Arduino\libraries\DallasTemperature\DallasTemperature.cpp:6:0:
C:\Program Files (x86)\Arduino\libraries\DallasTemperature\DallasTemperature.h:25:21: fatal error: OneWire.h: No such file or directory
compilation terminated.
test1\CMakeFiles\DallasTemperature.dir\build.make:61: recipe for target 'test1/CMakeFiles/DallasTemperature.dir/C_/Program_Files_(x86)/Arduino/libraries/DallasTemperature/DallasTemperature.cpp.obj' failed
mingw32-make.exe[3]: *** [test1/CMakeFiles/DallasTemperature.dir/C_/Program_Files_(x86)/Arduino/libraries/DallasTemperature/DallasTemperature.cpp.obj] Error 1
mingw32-make.exe[2]: *** [test1/CMakeFiles/DallasTemperature.dir/all] Error 2
CMakeFiles\Makefile2:208: recipe for target 'test1/CMakeFiles/DallasTemperature.dir/all' failed
CMakeFiles\Makefile2:109: recipe for target 'test1/CMakeFiles/test1.dir/rule' failed
mingw32-make.exe[1]: *** [test1/CMakeFiles/test1.dir/rule] Error 2
mingw32-make.exe: *** [test1] Error 2
Makefile:117: recipe for target 'test1' failed

from arduino-cmake-ng.

MrPointer avatar MrPointer commented on May 25, 2024

@ustisha Sorry again for the long delay, was sure I was the last one commented here 😆
Anyways, could you somehow share your entire project? I need to take a look at your structure, thanks.

Update:

It's been a while, but I've just realized that I haven't been entirely focused last time I looked at this issue, so I missed @ustisha your link to an example project, describing everything I need.

So I ran through your CMakeLists.txt again, and noticed you're not treating your included libraries as 3rd party libraries, which is how Arduino-CMake expects you to treat them.
I'm not sure if it's going to solve your issue, but that's a general tip you could apply.
Besides, it might be that Arduino-CMake does not recognize your relative directory structure, but to assure that, I'll need your help reporting.

from arduino-cmake-ng.

ustisha avatar ustisha commented on May 25, 2024

Hello back @MrPointer ! I'm do some research as much as I can. For now still do not understand few things.

  1. I updated my example project
  2. Adding libs works as I described in CMakeLists.txt I added some debug message and i see adding is succesfull
C:\JetBrains\apps\CLion\ch-0\191.6707.69\bin\cmake\win\bin\cmake.exe -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=arduino-cmake-ng/cmake/Arduino-Toolchain.cmake -G "CodeBlocks - MinGW Makefiles" C:\Arduino\CMake
-- Arduino SDK version 1.8.8: C:/Program Files (x86)/Arduino
-- Determined Platform Header: C:/Program Files (x86)/Arduino/hardware/arduino/avr/cores/arduino/Arduino.h
-- Arduino SDK version 1.8.8: C:/Program Files (x86)/Arduino
-- Determined Platform Header: C:/Program Files (x86)/Arduino/hardware/arduino/avr/cores/arduino/Arduino.h
-- Arduino SDK version 1.8.8: C:/Program Files (x86)/Arduino
-- Determined Platform Header: C:/Program Files (x86)/Arduino/hardware/arduino/avr/cores/arduino/Arduino.h
add_arduino_library OneWire_Lib - mini.atmega328 - C:/Arduino/CMake/libraries/Onewire/OneWire.h;C:/Arduino/CMake/libraries/Onewire/OneWire.cpp
add_arduino_library DallasTemperature_Lib - mini.atmega328 - C:/Arduino/CMake/libraries/Dallastemperature/DallasTemperature.h;C:/Arduino/CMake/libraries/Dallastemperature/DallasTemperature.cpp
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Arduino/CMake/cmake-build-debug

[Finished]

But build still failed

====================[ Build | test1 | Debug ]===================================
C:\JetBrains\apps\CLion\ch-0\191.6707.69\bin\cmake\win\bin\cmake.exe --build C:\Arduino\CMake\cmake-build-debug --target test1 -- -j 4
[ 80%] Built target mini_atmega328_core_lib
Scanning dependencies of target DallasTemperature_Lib
[ 90%] Building CXX object test1/CMakeFiles/DallasTemperature_Lib.dir/__/libraries/DallasTemperature/DallasTemperature.cpp.obj
[ 90%] Built target OneWire_Lib
In file included from C:\Arduino\CMake\libraries\DallasTemperature\DallasTemperature.cpp:6:0:
C:\Arduino\CMake\libraries\DallasTemperature\DallasTemperature.h:25:21: fatal error: OneWire.h: No such file or directory
compilation terminated.
mingw32-make.exe[3]: *** [test1/CMakeFiles/DallasTemperature_Lib.dir/__/libraries/DallasTemperature/DallasTemperature.cpp.obj] Error 1
test1\CMakeFiles\DallasTemperature_Lib.dir\build.make:61: recipe for target 'test1/CMakeFiles/DallasTemperature_Lib.dir/__/libraries/DallasTemperature/DallasTemperature.cpp.obj' failed
mingw32-make.exe[2]: *** [test1/CMakeFiles/DallasTemperature_Lib.dir/all] Error 2
CMakeFiles\Makefile2:95: recipe for target 'test1/CMakeFiles/DallasTemperature_Lib.dir/all' failed
mingw32-make.exe[1]: *** [test1/CMakeFiles/test1.dir/rule] Error 2
CMakeFiles\Makefile2:146: recipe for target 'test1/CMakeFiles/test1.dir/rule' failed
mingw32-make.exe: *** [test1] Error 2
Makefile:130: recipe for target 'test1' failed
  1. 3rd party libraries not helped. When I paste 3RD_PARTY nothing changed.

from arduino-cmake-ng.

ustisha avatar ustisha commented on May 25, 2024

I just hit this issue, and after some digging I figured out the fix:
ustisha/[email protected]:patch-1

Good Job!
Dependencies should be linked manually, this is main problem.
link_arduino_library(DallasTemperature_Lib OneWire_Lib ${board_id})

I will try this fix on my project with much libs, but if each lib will be need linked manually it can be problem (( Also i already make some fix in old https://github.com/queezythegreat/arduino-cmake and use it.

from arduino-cmake-ng.

MrPointer avatar MrPointer commented on May 25, 2024

@ustisha Oh, I'm not really familiar with any Arduino libraries so I didn't know DallasTemperature depends on OneWire 😆
Yes, that explains it all.
As for the annoyance it might cause, unfortunately there's not much we can do about it, as there's no way for the framework (at least currently or in the near future) to resolve dependencies on its' own.
Moreover, I believe this feature couldn't be implemented in plain CMake, and would require a 3rd-party tool such as python.

from arduino-cmake-ng.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.