CMake CMAKE_C_FLAGS vs add_compile_options

OP Persönliche Seite #5770736
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"
Beitrag #5770938 wurde von einem Moderator gelöscht.

Antwort schreiben

Eine eigene Frage? Dieser Thread ist über 7 Jahre alt. Stell sie in einem eigenen Thread – dort lesen mehr Leute mit, und sie wird öfter und schneller beantwortet.

Neuen Thread starten

Eine Lösung, Ergänzung oder Rückmeldung zu diesem Thread? Dann antworte hier.

Formatierung
  • [c]C-Code[/c]
  • [code]Code in anderen Sprachen, ASCII-Zeichnungen[/code]
  • [math]Formel in LaTeX-Syntax[/math]
  • [[Titel]] – Link zu einem Artikel
  • Verweis auf einen anderen Beitrag: Rechtsklick auf dessen Beitrags-ID (#8078628), „Adresse kopieren“, in den Text einfügen

Mehr zur Formatierung

Längeren Sourcecode als Anhang, nicht in den Text. JPG nur für Fotos und Scans; Zeichnungen und Screenshots als PNG oder GIF. Siehe Bildformate.

Schon registriert? Anmelden

Wird nicht angezeigt. Wir schicken dir einen Link; sobald du damit bestätigst, erscheint dein Beitrag.

Mit dem Abschicken legst du einen kostenlosen Account an und erkennst die Nutzungsbedingungen und die Datenschutzerklärung an.