queezythegreat/arduino-cmake — Issue #26: cannot find -l<libraryname>
Author: erictj
Created: 2012-02-11 06:31:18+00:00
State: open

I have an Arduino-style library called GarduinoUtil set up in a libraries/ directory, which is at the same level as my build/ and cmake/ directories:

$> ls
build cmake CMakeLists.txt CMakeLists.txt.sample CMakeLists.txt.test configure configure.bat libraries main.cpp

and inside the library directory:

$> tree libraries/
libraries/
└── GarduinoUtil
├── GarduinoUtil.cpp
└── GarduinoUtil.h

My top-level CMakeLists.txt looks like this:

set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules) # CMake module search path
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Arduino.cmake) # Arduino Toolchain
cmake_minimum_required(VERSION 2.8)

#====================================================================#
# Setup Project #
#====================================================================#
project(GarduinoController C CXX)
find_package(Arduino 1.0 REQUIRED)

link_directories(/home/eric/sketchbook/libraries)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/libraries)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libraries)

#====================================================================#
# Settings #
#====================================================================#
set(FIRMWARE_NAME arduino)

set(${FIRMWARE_NAME}_BOARD mega2560)

set(${FIRMWARE_NAME}_SRCS main.cpp)
set(${FIRMWARE_NAME}_LIBS GarduinoUtil)

set(${FIRMWARE_NAME}_PORT /dev/ttyACM0)
set(${FIRMWARE_NAME}_SERIAL picocom @INPUT_PORT@ -b 115200 -l -e b)

#====================================================================#
# Target generation #
#====================================================================#
generate_arduino_firmware(${FIRMWARE_NAME})

And upon compliation I get this:

$> make
[ 64%] Built target mega2560_CORE
[ 67%] Built target mega2560_GarduinoUtil
[ 67%] Built target mega2560_AverageList
[ 71%] Built target mega2560_XBee
[ 92%] Built target mega2560_WiFly
[ 96%] Built target mega2560_SPI
Linking CXX executable arduino.elf
/usr/lib/gcc/avr/4.5.3/../../../avr/bin/ld: cannot find -lGarduinoUtil
collect2: ld returned 1 exit status
make[2]: *** [arduino.elf] Error 1
make[1]: *** [CMakeFiles/arduino.dir/all] Error 2
make: *** [all] Error 2

I followed your instructions as to how to include Arduino-style libraries, but I must be missing something?