queezythegreat / arduino-cmake

Arduino CMake Build system
648 stars 216 forks source link

Various overrides #46

Closed jefferai closed 12 years ago

jefferai commented 12 years ago

Hi there,

Thanks for this project...for the most part it's working great.

However, I've found it necessary to override different variables. The number of changes necessary to the main CMake functions are minimal if a lot more work is done in an individual user's CMakeLists.txt file, and should probably not cause any issues for anyone else if you'd like that minimal pull request (it just allows for a user-defined variable to be included in CMAKE_C/CXX_FLAGS, ARDUINO_C/CXX_FLAGS, and COMPILE_FLAGS/LINK_FLAGS).

However, with this minimal set I still have to do a lot manually...for instance, here is a snippet of my CMakeLists.txt file (note that this must all be done before including the toolchain file, as otherwise these variables are not considered anymore):

set(ARDUINO_SDK_PATH /home/jmitchell/Arduino/arduino-1.0.1) set(ARDUINO_AVRDUDE_PROGRAM /usr/bin/avrdude) set(ARDUINO_AVRDUDE_CONFIG_PATH /etc/avrdude.conf) set(ARDUINO_PROJECTS_DIR /home/jmitchell/Arduino) set(CUSTOM_LIBS_DIR ${ARDUINO_PROJECTS_DIR}/cust/arduino/libraries)

set(AVR_SDK_PATH /home/jmitchell/Arduino/avr8-gnu-toolchain-linux_x86_64/bin) list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${AVR_SDK_PATH})

set(CUSTOM_INCLUDE_DIRS ${CUSTOM_LIBS_DIR}/messaging ${CUSTOM_LIBS_DIR}/avr-stl ${ARDUINO_SDK_PATH}/libraries/Ethernet ${ARDUINO_SDK_PATH}/libraries/Ethernet/utility )

###################################################

must come before the toolchain file is included

set(ARDUINO_C_FLAGS "-O2 -DMAKELIB -D__STDC_LIMIT_MACROS") foreach(CUSTOM_INCLUDE_DIR ${CUSTOM_INCLUDE_DIRS}) set(ARDUINO_C_FLAGS "${ARDUINO_C_FLAGS} -I${CUSTOM_INCLUDE_DIR}") endforeach()

set(CMAKE_TOOLCHAIN_FILE ${ARDUINO_PROJECTS_DIR}/arduino-cmake/cmake/ArduinoToolchain.cmake)

Probably what I'm doing there is pretty easily understandable...I need to use a custom toolchain (the one included with the Arduino distribution is too old and has some known bugs I need to avoid), need to include some custom directories, define some custom definitions, and so on.

I'd be happy to help you get some of these things integrated into the main CMake handlers if you're amenable to it...otherwise I'll just submit the minimal pull request for your consideration, so please let me know.

Thanks!

queezythegreat commented 12 years ago

Hi, I'm a little bit confused, I think your are over complicating the configuration.

The variables ARDUINO_SDK_PATH, ARDUINO_AVRDUDE_PROGRAM and ARDUINO_AVRDUDE_CONFIG_PATH should be specified before the toolchain if you are setting then from the CMakeLists.txt file, that is expected. The _AVR_SDKPATH also needs to be set like you did. The rest of your overrides are overkill, as there are dedicated commands for that.

To add a directory to the standard include path you use the include_directories() command. When you want to add a compiler define you use the add_definitions() command. Those two commands do not have to be before the toolchain file.

queezythegreat commented 12 years ago

Closing issue due to inactivity... Question has been answered.