/ projects / maixpy_twatch / compile / compile_flags.cmake
compile_flags.cmake
  1  
  2  ########## set C flags #########
  3  set(CMAKE_C_FLAGS 	-mcmodel=medany
  4                      -mabi=lp64f
  5                      -march=rv64imafc
  6                      -fno-common
  7                      -ffunction-sections
  8                      -fdata-sections
  9                      -fstrict-volatile-bitfields
 10                      -fno-zero-initialized-in-bss
 11                      -ffast-math
 12                      -fno-math-errno
 13                      -fsingle-precision-constant
 14                      -ffloat-store
 15                      -std=gnu11
 16                      -Os
 17                      -Wall
 18                      -Werror=all
 19                      -Wno-error=unused-function
 20                      -Wno-error=unused-but-set-variable
 21                      -Wno-error=unused-variable
 22                      -Wno-error=deprecated-declarations
 23                      -Wno-error=maybe-uninitialized
 24                      -Wextra
 25                      -Werror=frame-larger-than=32768
 26                      -Wno-unused-parameter
 27                      -Wno-unused-function
 28                      -Wno-implicit-fallthrough
 29                      -Wno-sign-compare
 30                      -Wno-error=missing-braces
 31                      -Wno-old-style-declaration
 32                      -Wno-error=pointer-sign
 33                      -Wno-pointer-to-int-cast
 34                      -Wno-strict-aliasing
 35                      -Wno-override-init
 36                      -Wno-error=format=
 37                      -Wno-error=format-truncation=
 38                      -Wno-error=restrict
 39                      -Wno-error=sequence-point
 40                      -Wno-int-to-pointer-cast
 41                      )
 42  ################################
 43  
 44  
 45  ###### set CXX(cpp) flags ######
 46  set(CMAKE_CXX_FLAGS -mcmodel=medany
 47                      -mabi=lp64f
 48                      -march=rv64imafc
 49                      -fno-common
 50                      -ffunction-sections
 51                      -fdata-sections
 52                      -fstrict-volatile-bitfields
 53                      -fno-zero-initialized-in-bss
 54                      -Os
 55                      -std=gnu++17
 56                      -Wall
 57                      -Wno-error=unused-function
 58                      -Wno-error=unused-but-set-variable
 59                      -Wno-error=unused-variable
 60                      -Wno-error=deprecated-declarations
 61                      -Wno-error=maybe-uninitialized
 62                      -Wextra
 63                      -Werror=frame-larger-than=32768
 64                      -Wno-unused-parameter
 65                      -Wno-unused-function
 66                      -Wno-implicit-fallthrough
 67                      -Wno-sign-compare
 68                      -Wno-error=missing-braces
 69                      -Wno-error=pointer-sign
 70                      -Wno-strict-aliasing
 71                      -Wno-error=format=
 72                      -Wno-error=format-truncation=
 73                      -Wno-error=restrict
 74                      -Wno-error=sequence-point
 75                      -Wno-int-to-pointer-cast
 76                      )
 77  ################################
 78  
 79  set(LINK_FLAGS ${LINK_FLAGS}
 80              -static
 81              -Wl,-static
 82              -nostartfiles
 83              -Wl,--gc-sections
 84              -Wl,-EL
 85              -T ${PROJECT_SOURCE_DIR}/compile/kendryte.ld
 86              -Wl,--start-group
 87              -Wl,--whole-archive
 88              kendryte_sdk/libkendryte_sdk.a  main/libmain.a
 89              -Wl,--no-whole-archive
 90              -Wl,--end-group
 91              )
 92  set(CMAKE_C_LINK_FLAGS ${CMAKE_C_LINK_FLAGS}
 93                          ${LINK_FLAGS}
 94                          )
 95  set(CMAKE_CXX_LINK_FLAGS ${CMAKE_C_LINK_FLAGS}
 96  	#${LINK_FLAGS}
 97                          )
 98  # set(CMAKE_EXE_LINKER_FLAGS  ${CMAKE_EXE_LINKER_FLAGS}
 99  #                             ${LINK_FLAGS}
100  #                             )
101  # set(CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS}
102  #                               ${LINK_FLAGS}
103  #                               )
104  # set(CMAKE_MODULE_LINKER_FLAGS ${CMAKE_MODULE_LINKER_FLAGS}
105  #                               ${LINK_FLAGS}
106  #                               )
107  
108  
109  # Convert list to string
110  string(REPLACE ";" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
111  string(REPLACE ";" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
112  string(REPLACE ";" " " LINK_FLAGS "${LINK_FLAGS}")
113  string(REPLACE ";" " " CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS}")
114  string(REPLACE ";" " " CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS}")