7

I'm trying to build an Arduino example without using its IDE. My OS is Windows 8.1 and I'm using the last version of CMake (2.8.12.2) and MinGW (GNU Make 3.82.90).

I downloaded the Arduino CMakeLists and I learned all about make/upload any firmware in my Arduino. I'm using Arduino UNO.

Then, if I modify the CMakeLists saved in ~/arduino-cmake-master/example/CMakeLists.txt (arduino-cmake-master is the repository folder) to build the WiFi example WiFiWebClient too:

...

#Add the WiFi example -> WiFiWebClient
generate_arduino_example(wifi_example
                     LIBRARY WiFi
                     EXAMPLE WiFiWebClient)
...

And execute:

  $ cmake -G "MinGW Makefiles"

  ...

  CMake Warning (dev) in example/CMakeLists.txt:
  Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES defines the link
  interface.  Run "cmake --help-policy CMP0022" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

  Target "uno_example" has an INTERFACE_LINK_LIBRARIES property.  This should
  be preferred as the source of the link interface for this library but
  because CMP0022 is not set CMake is ignoring the property and using the
  link implementation as the link interface instead.

  INTERFACE_LINK_LIBRARIES:

    uno_CORE;uno_example;uno_Wire

  Link implementation:

    uno_CORE;uno_Wire

This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) in example/CMakeLists.txt:
  Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES defines the link
  interface.  Run "cmake --help-policy CMP0022" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

  Target "uno_Wire" has an INTERFACE_LINK_LIBRARIES property.  This should be
  preferred as the source of the link interface for this library but because
  CMP0022 is not set CMake is ignoring the property and using the link
  implementation as the link interface instead.

  INTERFACE_LINK_LIBRARIES:

    uno_CORE;uno_Wire

  Link implementation:

    uno_CORE

This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) in example/CMakeLists.txt:
  Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES defines the link
  interface.  Run "cmake --help-policy CMP0022" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

  Target "uno_SPI" has an INTERFACE_LINK_LIBRARIES property.  This should be
  preferred as the source of the link interface for this library but because
  CMP0022 is not set CMake is ignoring the property and using the link
  implementation as the link interface instead.

  INTERFACE_LINK_LIBRARIES:

    uno_CORE;uno_SPI

  Link implementation:

    uno_CORE

This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) in example/CMakeLists.txt:
  Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES defines the link
  interface.  Run "cmake --help-policy CMP0022" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

  Target "uno_WiFi" has an INTERFACE_LINK_LIBRARIES property.  This should be
  preferred as the source of the link interface for this library but because
  CMP0022 is not set CMake is ignoring the property and using the link
  implementation as the link interface instead.

  INTERFACE_LINK_LIBRARIES:

    uno_CORE;uno_WiFi

  Link implementation:

    uno_CORE

This warning is for project developers.  Use -Wno-dev to suppress it.

-- Generating done
-- Build files have been written to: ~/arduino-cmake-master

Later I execute:

$ mingw32-make

...


Linking CXX static library libuno_WiFi.a
[ 89%] Built target uno_WiFi
Scanning dependencies of target wifi_example
[ 92%] Building CXX object example/CMakeFiles/wifi_example.dir/wifi_example_WiFiWebClient.cpp.obj
Linking CXX executable wifi_example.elf
libuno_WiFi.a(WiFiClient.cpp.obj): In function `WiFiClient::status()':
C:\Program Files\Arduino\libraries\WiFi/WiFiClient.cpp:160: undefined reference to `ServerDrv::getClientState(unsigned char)'
libuno_WiFi.a(WiFiClient.cpp.obj): In function `WiFiClient::stop()':
C:\Program Files\Arduino\libraries\WiFi/WiFiClient.cpp:131: undefined reference to `ServerDrv::stopClient(unsigned char)'
libuno_WiFi.a(WiFiClient.cpp.obj): In function `WiFiClient::peek()':
C:\Program Files\Arduino\libraries\WiFi/WiFiClient.cpp:117: undefined reference to `ServerDrv::getData(unsigned char, unsigned char*, unsigned char)'
libuno_WiFi.a(WiFiClient.cpp.obj): In function `WiFiClient::read()':
C:\Program Files\Arduino\libraries\WiFi/WiFiClient.cpp:101: undefined reference to `ServerDrv::getData(unsigned char, unsigned char*, unsigned char)'
libuno_WiFi.a(WiFiClient.cpp.obj): In function `WiFiClient::read(unsigned char*, unsigned int)':
C:\Program Files\Arduino\libraries\WiFi/WiFiClient.cpp:107: undefined reference to `ServerDrv::getDataBuf(unsigned char, unsigned char*, unsigned int*)'
libuno_WiFi.a(WiFiClient.cpp.obj): In function `WiFiClient::available()':
C:\Program Files\Arduino\libraries\WiFi/WiFiClient.cpp:90: undefined reference to `ServerDrv::availData(unsigned char)'
libuno_WiFi.a(WiFiClient.cpp.obj): In function `WiFiClient::write(unsigned char const*, unsigned int)':
C:\Program Files\Arduino\libraries\WiFi/WiFiClient.cpp:73: undefined reference to `ServerDrv::sendData(unsigned char, unsigned char const*, unsigned int)'
C:\Program Files\Arduino\libraries\WiFi/WiFiClient.cpp:78: undefined reference to `ServerDrv::checkDataSent(unsigned char)'
libuno_WiFi.a(WiFiClient.cpp.obj): In function `WiFiClient::connect(IPAddress, unsigned int)':
C:\Program Files\Arduino\libraries\WiFi/WiFiClient.cpp:36: undefined reference to `ServerDrv::startClient(unsigned long, unsigned int, unsigned char, unsigned char)'
libuno_WiFi.a(WiFi.cpp.obj): In function `WiFiClass::hostByName(char const*, IPAddress&)':
C:\Program Files\Arduino\libraries\WiFi/WiFi.cpp:228: undefined reference to `WiFiDrv::getHostByName(char const*, IPAddress&)'
libuno_WiFi.a(WiFi.cpp.obj): In function `WiFiClass::status()':
C:\Program Files\Arduino\libraries\WiFi/WiFi.cpp:223: undefined reference to `WiFiDrv::getConnectionStatus()'
libuno_WiFi.a(WiFi.cpp.obj): In function `WiFiClass::RSSI()':
C:\Program Files\Arduino\libraries\WiFi/WiFi.cpp:181: undefined reference to `WiFiDrv::getCurrentRSSI()'
libuno_WiFi.a(WiFi.cpp.obj): In function `WiFiClass::SSID()':
C:\Program Files\Arduino\libraries\WiFi/WiFi.cpp:169: undefined reference to `WiFiDrv::getCurrentSSID()'
libuno_WiFi.a(WiFi.cpp.obj): In function `WiFiClass::localIP()':
C:\Program Files\Arduino\libraries\WiFi/WiFi.cpp:149: undefined reference to `WiFiDrv::getIpAddress(IPAddress&)'
libuno_WiFi.a(WiFi.cpp.obj): In function `WiFiClass::begin(char*, char const*)':
C:\Program Files\Arduino\libraries\WiFi/WiFi.cpp:87: undefined reference to `WiFiDrv::wifiSetPassphrase(char*, unsigned char, char const*, unsigned char)'
C:\Program Files\Arduino\libraries\WiFi/WiFi.cpp:92: undefined reference to `WiFiDrv::getConnectionStatus()'
libuno_WiFi.a(WiFi.cpp.obj): In function `WiFiClass::init()':
C:\Program Files\Arduino\libraries\WiFi/WiFi.cpp:22: undefined reference to `WiFiDrv::wifiDriverInit()'
example\CMakeFiles\wifi_example.dir\build.make:95: recipe for target 'example/wifi_example.elf' failed
mingw32-make[2]: *** [example/wifi_example.elf] Error 1
CMakeFiles\Makefile2:748: recipe for target 'example/CMakeFiles/wifi_example.dir/all' failed
mingw32-make[1]: *** [example/CMakeFiles/wifi_example.dir/all] Error 2
Makefile:74: recipe for target 'all' failed
mingw32-make: *** [all] Error 2

The problem is the Arduino.cmake because it's not linking correctly with the library WiFi, but it links with the Wire library.

Anyone knows why that warning appears and why Wire links ok but WiFi doesn't?

Thanks!

Note: I'm using original code which is in the repository example, I've not modified this one.

4
  • Can you confirm that you could generate the examples BEFORE modifying CMakeLists.txt? Also, did you modify something else in this file?
    – jfpoilpret
    Mar 25, 2014 at 17:39
  • The warning given by cmake does not seem to be a problem (I got the same warning for one of my example projects and it works fine afterwards). Have you tried using another generator (I'm using "Unix Makefiles" and it works fine for my project; I just had to install a Windows version of make).
    – jfpoilpret
    Mar 25, 2014 at 21:39
  • Another point: did you try generate_arduino_library(WiFi...) first, defining all headers and source files included in WiFi directory? Indeed, I don't think cmake will be able to build the library properly as it should not be able to find files in subdirectory utility: these are the files that contain definitions that mingw32-make is complaining about.
    – jfpoilpret
    Mar 25, 2014 at 21:47
  • Related to my previous comment, a faster option that you could try is set(WiFi_RECURSE True); it tells cmake to compile all files including those in subdirectories of the WiFi library.
    – jfpoilpret
    Mar 25, 2014 at 22:21

1 Answer 1

4

Your question actually has 2 distinct parts:

  1. Why does arduino-cmake generate the warning "Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES..."?
  2. Why does make, using the generated MakeFile, fail when building WiFi example?

First off, the arduino-cmake "Policy CMP0022" is just a warning, not an error. As per this cmake article, that CMP policy has been only recently introduced in CMake 2.8.12.

You get this warning simply because arduino-cmake has been created based on an older version of cmake and thus does not specifically support this new policy.

In order to get rid of this warning, the documentation mentions you should add the cmake_policy(SET CMP0022 OLD) command to your cmake configuration.

Unfortunately I tried it in the example CMakeLists.txt to no avail; maybe it has to be set directly in arduino-cmake files (which I have not tested).

Thus, if you want to get rid of this boring warning, it seems the only solution you are left with is to disable all warnings when launching cmake:

cmake -G "MinGW Makefiles" -Wno-dev

This works fine and has removed all warnings..

Your second problem (the real one I would say) is due to to the structure of WiFi library: enter image description here

Indeed, as you can see above, it has a utility subdirectory that contains additional source code that cannot be found by arduino-cmake, as by default it searches for source code files only at first level directory.

How to solve it? Just tell arduino-cmake to do a recursive search for the WiFi library; in your CMakeLists.txt, ensure you add the following line:

set(WiFi_RECURSE True)
generate_arduino_example(wifi_example
                     LIBRARY WiFi
                     EXAMPLE WiFiWebClient)

The added set(WiFi_RECURSE True) line just tells arduino-cmake that, for WiFi library, it should recurse through subdirectories when looking for source code.

I have checked it with "Unix Makefiles" (not "MinGW Makefiles" but I guess that won't make any difference) and it worked fine.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.