CMakeLists.txt 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. cmake_minimum_required(VERSION 2.8.9)
  2. # MCU name
  3. # set(MCU atmega32)
  4. set(MCU at90can128)
  5. # Processor frequency.
  6. # This will define a symbol, F_CPU, in all source code files equal to the
  7. # processor frequency. You can then use this symbol in your source code to
  8. # calculate timings. Do NOT tack on a 'UL' at the end, this will be done
  9. # automatically to create a 32-bit value in your source code.
  10. # Typical values are:
  11. # F_CPU = 1000000
  12. # F_CPU = 1843200
  13. # F_CPU = 2000000
  14. # F_CPU = 3686400
  15. # F_CPU = 4000000
  16. # F_CPU = 7372800
  17. # F_CPU = 8000000
  18. # F_CPU = 11059200
  19. # F_CPU = 14745600
  20. # F_CPU = 16000000
  21. # F_CPU = 18432000
  22. # F_CPU = 20000000
  23. set(F_CPU 16000000)
  24. ############################################
  25. # !!!!!! NO CHANGES BELOW THIS LINE !!!!!! #
  26. ############################################
  27. add_definitions(-DF_CPU=${F_CPU})
  28. add_definitions(-DHAS_CAN_CONFIG_H)
  29. # program names
  30. set(AVRCPP avr-g++)
  31. set(AVRC avr-gcc)
  32. set(AVRSTRIP avr-strip)
  33. set(OBJCOPY avr-objcopy)
  34. set(OBJDUMP avr-objdump)
  35. set(AVRSIZE avr-size)
  36. set(AVRDUDE avrdude)
  37. # Sets the compiler
  38. # Needs to come before the project function
  39. set(CMAKE_SYSTEM_NAME Generic)
  40. set(CMAKE_CXX_COMPILER ${AVRCPP})
  41. set(CMAKE_C_COMPILER ${AVRC})
  42. set(CMAKE_ASM_COMPILER ${AVRC})
  43. project (avr-can-lib C CXX ASM)
  44. # Important project paths
  45. set(BASE_PATH "${PROJECT_NAME}")
  46. set(INC_PATH "${BASE_PATH}")
  47. set(CONFIG_PATH ".")
  48. set(SRC_PATH "${BASE_PATH}/src")
  49. # Files to be compiled
  50. file(GLOB SRC_FILES "${SRC_PATH}/*.cpp"
  51. "${SRC_PATH}/*.cc"
  52. "${SRC_PATH}/*.c"
  53. "${SRC_PATH}/*.cxx"
  54. "${SRC_PATH}/*.S"
  55. "${SRC_PATH}/*.s"
  56. "${SRC_PATH}/*.sx"
  57. "${SRC_PATH}/*.asm")
  58. # Compiler flags
  59. set(CSTANDARD "-std=gnu99")
  60. set(CDEBUG "-gstabs -g -ggdb")
  61. set(CWARN "-Wall -Wstrict-prototypes -Wl,--gc-sections -Wl,--relax")
  62. set(CTUNING "-funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -ffunction-sections -fdata-sections")
  63. set(COPT "-Os -lm -lprintf_flt")
  64. set(CMCU "-mmcu=${MCU}")
  65. set(CDEFS "-DF_CPU=${F_CPU}")
  66. set(CFLAGS "${CMCU} ${CDEBUG} ${CDEFS} ${COPT} ${CWARN} ${CSTANDARD} ${CTUNING}")
  67. set(CXXFLAGS "${CMCU} ${CDEBUG} ${CDEFS} ${COPT} ${CTUNING}")
  68. set(CMAKE_C_FLAGS "${CFLAGS}")
  69. set(CMAKE_CXX_FLAGS "${CXXFLAGS}")
  70. set(CMAKE_ASM_FLAGS "${CFLAGS}")
  71. set(CONFIG_FILE can_config.h)
  72. # Project setup
  73. include_directories(${INC_PATH} ${CONFIG_PATH})
  74. add_library(can STATIC ${SRC_FILES})
  75. set_target_properties(can PROPERTIES
  76. ARCHIVE_OUTPUT_DIRECTORY ${BASE_PATH})
  77. # Config logging
  78. message("* ")
  79. message("* Project Name:\t\t${PROJECT_NAME}")
  80. message("* Project Source:\t${SRC_PATH}")
  81. message("* Project Include:\t${INC_PATH}")
  82. message("* Project Config:\t${CONFIG_FILE}")
  83. message("* ")
  84. message("* C Flags:\t${CMAKE_C_FLAGS}")
  85. message("* ")
  86. message("* CXX Flags:\t${CMAKE_C_FLAGS}")
  87. message("* ")