Forum: Compiler & IDEs CMake CMAKE_C_FLAGS vs add_compile_options


von D a v i d K. (oekel) Benutzerseite


Lesenswert?

Hi,

kann mir Jeman erklären, wieso ich bei folgendem:
1
    SET(CMAKE_C_COMPILER ${AVRBIN}/avr-gcc)
2
    SET(CMAKE_CXX_COMPILER ${AVRBIN}/avr-g++)
3
4
    #Binaryinterface (ABI)
5
        #-funsigned-char
6
        #-funsigned-bitfields
7
        #-fpack-struct
8
        #-fshort-enums
9
    add_compile_options(-funsigned-char) # CMake 2.8.12 or newer
10
    add_compile_options(-fshort-enums)
11
    add_compile_options(-ffunction-sections)
12
    add_compile_options(-fdata-sections)
13
14
    add_compile_options(-Wall)#all Warnings
15
    add_compile_options(-std=gnu99)
16
17
    SET(COMMON_FLAGS -Os -mmcu=${DEVICE} -DF_CPU=${FREQ}UL -Wl,--gc-sections)
18
    #add_compile_options(${COMMON_FLAGS}) #(__AVR_ATmega??__)
19
    #add_link_options(${COMMON_FLAGS})
20
21
    SET(CMAKE_C_FLAGS "-Os -mmcu=${DEVICE} -DF_CPU=${FREQ}UL -std=gnu99 -Wl,--gc-sections")
22
    SET(CMAKE_CXX_FLAGS "-Os -mmcu=${DEVICE} -DF_CPU=${FREQ}UL -Wl,--gc-sections")
auf ein Compilat von:

Device: atmega88
Program:    7830 bytes (95.6% Full)
(.text + .data + .bootloader)
Data:         85 bytes (8.3% Full)
(.data + .bss + .noinit)
EEPROM:        6 bytes (1.2% Full)
(.eeprom)

und hingegen bei:
1
    SET(CMAKE_C_COMPILER ${AVRBIN}/avr-gcc)
2
    SET(CMAKE_CXX_COMPILER ${AVRBIN}/avr-g++)
3
4
    #Binaryinterface (ABI)
5
        #-funsigned-char
6
        #-funsigned-bitfields
7
        #-fpack-struct
8
        #-fshort-enums
9
    add_compile_options(-funsigned-char) # CMake 2.8.12 or newer
10
    add_compile_options(-fshort-enums)
11
    add_compile_options(-ffunction-sections)
12
    add_compile_options(-fdata-sections)
13
14
    add_compile_options(-Wall)#all Warnings
15
    add_compile_options(-std=gnu99)
16
17
    SET(COMMON_FLAGS -Os -mmcu=${DEVICE} -DF_CPU=${FREQ}UL -Wl,--gc-sections)
18
    add_compile_options(${COMMON_FLAGS}) #(__AVR_ATmega??__)
19
    add_link_options(${COMMON_FLAGS})
20
21
    #SET(CMAKE_C_FLAGS "-Os -mmcu=${DEVICE} -DF_CPU=${FREQ}UL -std=gnu99 -Wl,--gc-sections")
22
    #SET(CMAKE_CXX_FLAGS "-Os -mmcu=${DEVICE} -DF_CPU=${FREQ}UL -Wl,--gc-sections")

auf:
Device: atmega88
Program:    5382 bytes (65.7% Full)
(.text + .data + .bootloader)
Data:         85 bytes (8.3% Full)
(.data + .bss + .noinit)
EEPROM:        6 bytes (1.2% Full)
(.eeprom)

Meines Verständnisses nach haben ich nur andere Befehle verwendet, um 
die Optionen hinzuzufügen. Das Resultät lässt mich aber glauben, dass 
bei einem von beiden etwas anders greift.

Viele Grüße

PS: die letzten vier Zeilen sind mit Kommetaren "getoggelt"

von Jörg W. (dl8dtl) (Moderator) Benutzerseite


Lesenswert?

Vielleicht lässt du dir ja mal die entsprechenden 
Compiler-Kommandozeilen anzeigen, die sich daraus ergeben?

Beitrag #5770938 wurde vom Autor gelöscht.
von Rolf M. (rmagnus)


Lesenswert?

Jörg W. schrieb:
> Vielleicht lässt du dir ja mal die entsprechenden Compiler-Kommandozeilen
> anzeigen, die sich daraus ergeben?

Das geht übrigens am einfachsten mit:
1
make VERBOSE=1

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.