queezythegreat / arduino-cmake

Arduino CMake Build system
645 stars 216 forks source link

example build cmake warnings #93

Open cevich opened 9 years ago

cevich commented 9 years ago

Under Fedora 21 beta, using Fedora 20 toolchain (bugzilla 1134394), CMake 2.8.12 gives the following warnings:

$ mkdir build && cd build && cmake ..
...cut...
-- Configuring done
CMake Warning (dev) at cmake/Platform/Arduino.cmake:983 (add_library):
  Policy CMP0038 is not set: Targets may not link directly to themselves.
  Run "cmake --help-policy CMP0038" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

  Target "uno_example" links to itself.
Call Stack (most recent call first):
  cmake/Platform/Arduino.cmake:1040 (setup_arduino_library)
  cmake/Platform/Arduino.cmake:391 (setup_arduino_libraries)
  example/CMakeLists.txt:73 (generate_arduino_library)
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_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

  Link implementation:

    uno_CORE

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

CMake Warning (dev) at cmake/Platform/Arduino.cmake:983 (add_library):
  Policy CMP0038 is not set: Targets may not link directly to themselves.
  Run "cmake --help-policy CMP0038" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

  Target "uno_example" links to itself.
Call Stack (most recent call first):
  cmake/Platform/Arduino.cmake:1040 (setup_arduino_library)
  cmake/Platform/Arduino.cmake:391 (setup_arduino_libraries)
  example/CMakeLists.txt:73 (generate_arduino_library)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at cmake/Platform/Arduino.cmake:983 (add_library):
  Policy CMP0038 is not set: Targets may not link directly to themselves.
  Run "cmake --help-policy CMP0038" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

  Target "diecimila_Wire" links to itself.
Call Stack (most recent call first):
  cmake/Platform/Arduino.cmake:1040 (setup_arduino_library)
  cmake/Platform/Arduino.cmake:626 (setup_arduino_libraries)
  example/CMakeLists.txt:12 (generate_arduino_example)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at cmake/Platform/Arduino.cmake:983 (add_library):
  Policy CMP0038 is not set: Targets may not link directly to themselves.
  Run "cmake --help-policy CMP0038" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

  Target "uno_example" links to itself.
Call Stack (most recent call first):
  cmake/Platform/Arduino.cmake:1040 (setup_arduino_library)
  cmake/Platform/Arduino.cmake:391 (setup_arduino_libraries)
  example/CMakeLists.txt:73 (generate_arduino_library)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at cmake/Platform/Arduino.cmake:983 (add_library):
  Policy CMP0038 is not set: Targets may not link directly to themselves.
  Run "cmake --help-policy CMP0038" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

  Target "diecimila_Wire" links to itself.
Call Stack (most recent call first):
  cmake/Platform/Arduino.cmake:1040 (setup_arduino_library)
  cmake/Platform/Arduino.cmake:626 (setup_arduino_libraries)
  example/CMakeLists.txt:12 (generate_arduino_example)
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 "diecimila_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:

    diecimila_CORE;diecimila_Wire

  Link implementation:

    diecimila_CORE

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

-- Generating done
-- Build files have been written to: /tmp/arduino-cmake/build
cevich commented 9 years ago

Looking at the suggested policy details, CMP0022 seems to suggest a fix which will also be compatible with older cmake versions (re: cmake/Platform/Arduino.cmake line 983):

Warning-free future-compatible code which works with CMake 2.8.9 onwards
can be written by using the ``LINK_PRIVATE`` and ``LINK_PUBLIC`` keywords
of ``target_link_libraries()``.

However, I'm not enough of a cmake guru to know what this means, or how to fix it :cry:

cevich commented 9 years ago

Just by total guessing and some poking around, I found this makes all the warnings go away (though I don't know if it is a correct fix, or will work with older versions of cmake):

diff --git a/cmake/Platform/Arduino.cmake b/cmake/Platform/Arduino.cmake
index 22ba5d8..d42a7ec 100644
--- a/cmake/Platform/Arduino.cmake
+++ b/cmake/Platform/Arduino.cmake
@@ -1001,7 +1001,7 @@ function(setup_arduino_library VAR_NAME BOARD_ID LIB_PATH COMPILE_FLAGS LINK_FLA
                 LINK_FLAGS "${ARDUINO_LINK_FLAGS} ${LINK_FLAGS}")
             list(APPEND LIB_INCLUDES "-I\"${LIB_PATH}\" -I\"${LIB_PATH}/utility\"")

-            target_link_libraries(${TARGET_LIB_NAME} ${BOARD_ID}_CORE ${LIB_TARGETS})
+            target_link_libraries(${TARGET_LIB_NAME} ${BOARD_ID}_CORE)
             list(APPEND LIB_TARGETS ${TARGET_LIB_NAME})

         endif()

It does end the complaining, and all the examples seem to build fine as well.

cevich commented 9 years ago

Here's a pull-request with this change if by chance I guessed correctly (please double-check): #94

jorihardman commented 9 years ago

Bump. Anyone ever figure out what's going on with these?

cevich commented 9 years ago

Dunno, but I've been running with #94 applied and it seems to address the issue. But again, I'm not a CMAKE expert, just know enough to be dangerous :smile: