[En-Nut-Discussion] GCC 4.8, -Og and -g3
Thiago A. Corrêa
thiago.correa at gmail.com
Sat Jan 18 01:46:29 CET 2014
Hi,
On 17 de janeiro de 2014 20:07, Ole Reinhardt
<ole.reinhardt at embedded-it.de> wrote:
>> and use -O0 if GCC_VERSION < 480 or -Og else. But I doubt this solution is
>> portable. Any ideas for a portable solution.
>
> Unfortunately it is not. You can not use any shell code on Windows
> without a full cygwin environment.
>
> But I just though: Why don't we move some compiler options into the
> Configurator? This way we could provide different sets of debugging and
> other compiler options while not have to maintain 100 different Makefiles?
>
This may sound like a crazy idea, but how about using cmake to
generate our makefiles?
I've done this before on embedded and it works well. Then we could use
detection code inside CMakeLists.txt
If we provide the toolchain variables, then client code could use cmake as well.
I kind of wanted to create something like that for myself just for
client code, but it could be done for the library code.
Here is an example (from working code):
SET(CMAKE_SYSTEM_NAME Generic)
SET(CMAKE_C_COMPILER avr-gcc)
SET(CMAKE_CXX_COMPILER avr-g++)
SET(CSTANDARD "-std=gnu99")
SET(CDEBUG "-gstabs")
SET(CWARN "-Wall -Wstrict-prototypes")
SET(CTUNING "-funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums")
SET(COPT "-Os")
SET(CMCU "-mmcu=atmega32")
SET(CFLAGS "${CMCU} ${CDEBUG} ${CDEFS} ${CINCS} ${COPT} ${CWARN}
${CSTANDARD} ${CEXTRA}")
SET(CXXFLAGS "${CMCU} ${CDEFS} ${CINCS} ${COPT}")
SET(CMAKE_C_FLAGS "${CFLAGS}" CACHE STRING "Flags used by the compiler
during all build types.")
SET(CMAKE_CXX_FLAGS "${CXXFLAGS}")
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0)
PROJECT(myproject)
SET(HEADER_FILES
hd44780.h
)
SET(SOURCE_FILES
dev/hd44780.c
main.c
)
add_definitions(
-D__HARVARD_ARCH__
-D__AVR_ENHANCED__
-DF_CPU=16000000UL
)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/include
/Program Files (x86)/Atmel/AVR Tools/AVR Toolchain/avr/include
)
option(LCD2X40 "LCD 2 linhas por 40 colunas" OFF)
option(LCD4X20 "LCD 4 linhas por 20 colunas" OFF)
if(LCD2X40)
add_definitions( -DLCD_ROWS=2 -DLCD_COLS=40 )
endif()
if(LCD4X20)
add_definitions( -DLCD_ROWS=4 -DLCD_COLS=20 )
endif()
add_executable(myproject ${SOURCE_FILES})
More information about the En-Nut-Discussion
mailing list