链接外部库cmake arduino

时间:2016-10-27 08:37:24

标签: c++ json arduino cmake libraries

我正在尝试使用CMake将名为ArduinoJson的下载库链接到我的项目,但似乎每当我包含文件时它都会丢失,它只会要求丢失下一个文件。我最终将会有很多包含行,我认为这些行不正确。我似乎无法找到在CMake中包含库的正确语法

的CMakeLists.txt

cmake_minimum_required(VERSION 2.8.11)

SET(CMAKE_CXX_STANDARD 11)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
SET(CMAKE_CXX_FLAGS "-DTESTING")

include_directories(
    /usr/share/arduino/libraries/ArduinoJson/include
    /usr/share/arduino/hardware/arduino/cores/arduino
    )


set(files
    DataHandler.h 
    DataHandler.cpp
    JSON.cpp 
    JSON.h 
    HAL_mock.cpp 
    HAL_mock.h 
    HAL_Protocol.h 
    lib/ArduinoJson/ArduinoJson.h
    )

# Locate GTest
find_package(GTest REQUIRED)

# Link runTests with what we want to test and the GTest library
add_executable(runTests DataHandlerTests.cpp JSONTests.cpp HALTests.cpp ${files})

target_link_libraries(runTests GTest::Main ArduinoJson)

我得到的错误

[ 14%] Building CXX object CMakeFiles/runTests.dir/JSONTests.cpp.o
In file included from /usr/share/arduino/libraries/ArduinoJson/include/ArduinoJson/Internals/../Internals/../String.hpp:14:0,
                 from /usr/share/arduino/libraries/ArduinoJson/include/ArduinoJson/Internals/../Internals/DynamicStringBuilder.hpp:11,
                 from /usr/share/arduino/libraries/ArduinoJson/include/ArduinoJson/Internals/../Internals/JsonPrintable.hpp:12,
                 from /usr/share/arduino/libraries/ArduinoJson/include/ArduinoJson/Internals/../JsonVariant.hpp:13,
                 from /usr/share/arduino/libraries/ArduinoJson/include/ArduinoJson/Internals/../JsonBuffer.hpp:14,
                 from /usr/share/arduino/libraries/ArduinoJson/include/ArduinoJson/Internals/BlockJsonBuffer.hpp:10,
                 from /usr/share/arduino/libraries/ArduinoJson/include/ArduinoJson/DynamicJsonBuffer.hpp:10,
                 from /usr/share/arduino/libraries/ArduinoJson/include/ArduinoJson.hpp:10,
                 from /usr/share/arduino/libraries/ArduinoJson/include/ArduinoJson.h:8,
                 from /usr/share/arduino/libraries/ArduinoJson/ArduinoJson.h:8,
                 from /home/zizyx/Desktop/git-sensorNetwerk/sensor-network/gtest/JSON.h:6,
                 from /home/zizyx/Desktop/git-sensorNetwerk/sensor-network/gtest/JSONTests.cpp:5:
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:29:26: fatal error: avr/pgmspace.h: No such file or directory
compilation terminated.
CMakeFiles/runTests.dir/build.make:86: recipe for target 'CMakeFiles/runTests.dir/JSONTests.cpp.o' failed
make[2]: *** [CMakeFiles/runTests.dir/JSONTests.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/runTests.dir/all' failed
make[1]: *** [CMakeFiles/runTests.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

我想添加2行3行,其中包含我ArduinoJson库所需的所有库

0 个答案:

没有答案