CLionArduinoPlugin icon indicating copy to clipboard operation
CLionArduinoPlugin copied to clipboard

using set(${PROJECT_NAME}_SRCS ) has no effect on compile

Open rklosinski opened this issue 6 years ago • 5 comments

Just installed the latest version of this plugin. Skeleton code compiled and uploaded fine. So I tried adding a new class (test cpp/h) then added them to the CMakeList.txt file using set(${PROJECT_NAME}_SRCS test.cpp) and set(${PROJECT_NAME}_HDRS User_Setup.h test.h). This had no effect on the outcome of the compile.

What did worked was to change set(${PROJECT_NAME}_SRCS) and set(${PROJECT_NAME}_HDRS User_Setup.h), then rename test.cpp to test.ino. It seems only ino files are searched for automatically, and set(${PROJECT_NAME}_SRCS) is broken.

rklosinski avatar Aug 22 '19 22:08 rklosinski

@rklosinski, did you reload the CMakeLists.txt after modifying it? The IDE needs to reload the file to change its project build files.

vsch avatar Aug 22 '19 22:08 vsch

yes I did

rklosinski avatar Aug 22 '19 22:08 rklosinski

@rklosinski, just figured out that if you want to include extra cpp files in the project then instead of set(${PROJECT_NAME}_SKETCH untitled8.ino) main file you should rename the .ino to .cpp and add all cpp file as set(${PROJECT_NAME}_SRCS test.cpp untitled8.cpp)

Loading CMakeLists.txt now recognizes all .cpp and .h files as part of the project. This must be somewhere in the docs of Arduino CMake but I don't remember coming across it.

With a sketch file all the .cpp files need to be included into the .ino file as part of its source.

vsch avatar Aug 22 '19 23:08 vsch

@vsch Thanks! I'll try that when Im able to get back to my Arduino project. another project's priority just bumped it down a notch.

rklosinski avatar Aug 26 '19 02:08 rklosinski

For future reference (edit these two lines in your own project): https://github.com/francoiscampbell/arduino-cmake/pull/10

After this de _SKETCH, _SRCS and _HDRS all work.

jord1e avatar Mar 09 '21 13:03 jord1e