You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

157 lines
5.9 KiB

cmake_minimum_required(VERSION 3.10)
project(lpcxpresso_55s69_template)
enable_language(CXX)
enable_language(ASM)
# Different linker scripts
set(TARGET_LDSCRIPT_FLASH "${CMAKE_SOURCE_DIR}/SDK/devices/LPC55S69/gcc/LPC55S69_cm33_core0_flash.ld")
set(TARGET_LDSCRIPT_RAM "${CMAKE_SOURCE_DIR}/SDK/devices/LPC55S69/gcc/LPC55S69_cm33_core0_ram.ld")
set(TARGET_SOURCES
"SDK/components/serial_manager/fsl_component_serial_manager.c"
"SDK/components/serial_manager/fsl_component_serial_port_uart.c"
"SDK/components/uart/fsl_adapter_usart.c"
"SDK/devices/LPC55S69/drivers/fsl_anactrl.c"
"SDK/devices/LPC55S69/drivers/fsl_casper.c"
"SDK/devices/LPC55S69/drivers/fsl_clock.c"
"SDK/devices/LPC55S69/drivers/fsl_cmp.c"
"SDK/devices/LPC55S69/drivers/fsl_common.c"
"SDK/devices/LPC55S69/drivers/fsl_common_arm.c"
"SDK/devices/LPC55S69/drivers/fsl_crc.c"
"SDK/devices/LPC55S69/drivers/fsl_ctimer.c"
"SDK/devices/LPC55S69/drivers/fsl_dma.c"
"SDK/devices/LPC55S69/drivers/fsl_flexcomm.c"
"SDK/devices/LPC55S69/drivers/fsl_gint.c"
"SDK/devices/LPC55S69/drivers/fsl_gpio.c"
"SDK/devices/LPC55S69/drivers/fsl_hashcrypt.c"
"SDK/devices/LPC55S69/drivers/fsl_i2c.c"
"SDK/devices/LPC55S69/drivers/fsl_i2c_dma.c"
"SDK/devices/LPC55S69/drivers/fsl_i2s.c"
"SDK/devices/LPC55S69/drivers/fsl_i2s_dma.c"
"SDK/devices/LPC55S69/drivers/fsl_iap.c"
"SDK/devices/LPC55S69/drivers/fsl_inputmux.c"
"SDK/devices/LPC55S69/drivers/fsl_lpadc.c"
"SDK/devices/LPC55S69/drivers/fsl_mrt.c"
"SDK/devices/LPC55S69/drivers/fsl_ostimer.c"
"SDK/devices/LPC55S69/drivers/fsl_pint.c"
"SDK/devices/LPC55S69/drivers/fsl_plu.c"
"SDK/devices/LPC55S69/drivers/fsl_power.c"
"SDK/devices/LPC55S69/drivers/fsl_prince.c"
"SDK/devices/LPC55S69/drivers/fsl_puf.c"
"SDK/devices/LPC55S69/drivers/fsl_reset.c"
"SDK/devices/LPC55S69/drivers/fsl_rng.c"
"SDK/devices/LPC55S69/drivers/fsl_rtc.c"
"SDK/devices/LPC55S69/drivers/fsl_sctimer.c"
"SDK/devices/LPC55S69/drivers/fsl_sdif.c"
"SDK/devices/LPC55S69/drivers/fsl_spi.c"
"SDK/devices/LPC55S69/drivers/fsl_spi_dma.c"
"SDK/devices/LPC55S69/drivers/fsl_sysctl.c"
"SDK/devices/LPC55S69/drivers/fsl_usart.c"
"SDK/devices/LPC55S69/drivers/fsl_usart_dma.c"
"SDK/devices/LPC55S69/drivers/fsl_utick.c"
"SDK/devices/LPC55S69/drivers/fsl_wwdt.c"
"SDK/devices/LPC55S69/gcc/startup_LPC55S69_cm33_core0.S"
"SDK/devices/LPC55S69/system_LPC55S69_cm33_core0.c"
"SDK/devices/LPC55S69/utilities/debug_console/fsl_debug_console.c"
"SDK/devices/LPC55S69/utilities/str/fsl_str.c"
"board/board.c"
"board/clock_config.c"
"board/peripherals.c"
"board/pin_mux.c"
"src/main.c"
)
set(TARGET_C_DEFINES
"CPU_LPC55S69JBD100_cm33_core0"
"FFR_INCLUDE=\"fsl_iap_ffr.h\""
"MCUXPRESSO_SDK"
"SERIAL_PORT_TYPE_UART=1"
"__STARTUP_CLEAR_BSS"
)
set(TARGET_C_INCLUDES
"SDK/CMSIS/Core/Include"
"SDK/components/serial_manager"
"SDK/components/uart"
"SDK/devices/LPC55S69"
"SDK/devices/LPC55S69/drivers"
"SDK/devices/LPC55S69/utilities/debug_console"
"SDK/devices/LPC55S69/utilities/str"
"board"
"include"
)
# Shared libraries linked with application
set(TARGET_LIBS
"c"
"m"
"nosys"
)
# Shared library and linker script search paths
set(TARGET_LIB_DIRECTORIES
)
# Device specific settings, goes to CFLAGS and LDFLAGS
set(TARGET_CFLAGS_HARDWARE "-mcpu=cortex-m33 -mthumb -mfloat-abi=hard -mfpu=fpv5-sp-d16")
# Conditional flags
# DEBUG
set(CMAKE_C_FLAGS_DEBUG "-DDEBUG -O -g")
set(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG -O -g")
set(CMAKE_ASM_FLAGS_DEBUG "-DDEBUG -O -g")
# RELEASE
set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O2 -flto")
set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O2 -flto")
set(CMAKE_ASM_FLAGS_RELEASE "-DNDEBUG -O2 -flto")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-flto")
# Final compiler flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TARGET_CFLAGS_HARDWARE} -Wall -fno-common -fno-builtin -ffreestanding -fdata-sections -ffunction-sections")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TARGET_CFLAGS_HARDWARE} -Wall -fno-common -fno-builtin -ffreestanding -fdata-sections -ffunction-sections")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ${CMAKE_C_FLAGS} -x assembler-with-cpp")
set(CMAKE_EXE_LINKER_FLAGS "-specs=nano.specs -specs=nosys.specs -Wl,--gc-sections -Wl,--print-memory-usage -Wl,--no-warn-rwx-segments")
# Shared sources, includes and definitions
add_compile_definitions(${TARGET_C_DEFINES})
include_directories(${TARGET_C_INCLUDES})
link_directories(${TARGET_LIB_DIRECTORIES})
link_libraries(${TARGET_LIBS})
# Main targets are added here
# Create ELF
add_executable("${CMAKE_PROJECT_NAME}_FLASH.elf" ${TARGET_SOURCES})
target_link_options("${CMAKE_PROJECT_NAME}_FLASH.elf"
PRIVATE "-T${TARGET_LDSCRIPT_FLASH}"
PRIVATE "-Wl,--Map=${CMAKE_PROJECT_NAME}_FLASH.map"
)
set_property(TARGET "${CMAKE_PROJECT_NAME}_FLASH.elf" APPEND
PROPERTY ADDITIONAL_CLEAN_FILES "${CMAKE_PROJECT_NAME}_FLASH.map"
)
add_custom_command(OUTPUT "${CMAKE_PROJECT_NAME}_FLASH.hex"
COMMAND ${CMAKE_OBJCOPY} "-O" "ihex" "${CMAKE_PROJECT_NAME}_FLASH.elf" "${CMAKE_PROJECT_NAME}_FLASH.hex"
DEPENDS "${CMAKE_PROJECT_NAME}_FLASH.elf"
)
add_custom_target("${CMAKE_PROJECT_NAME}_FLASH_HEX" DEPENDS "${CMAKE_PROJECT_NAME}_FLASH.hex")
# Create ELF
add_executable("${CMAKE_PROJECT_NAME}_RAM.elf" ${TARGET_SOURCES})
target_link_options("${CMAKE_PROJECT_NAME}_RAM.elf"
PRIVATE "-T${TARGET_LDSCRIPT_RAM}"
PRIVATE "-Wl,--Map=${CMAKE_PROJECT_NAME}_RAM.map"
)
set_property(TARGET "${CMAKE_PROJECT_NAME}_FLASH.elf" APPEND
PROPERTY ADDITIONAL_CLEAN_FILES "${CMAKE_PROJECT_NAME}_RAM.map"
)
add_custom_command(OUTPUT "${CMAKE_PROJECT_NAME}_RAM.hex"
COMMAND ${CMAKE_OBJCOPY} "-O" "ihex" "${CMAKE_PROJECT_NAME}_RAM.elf" "${CMAKE_PROJECT_NAME}_RAM.hex"
DEPENDS "${CMAKE_PROJECT_NAME}_RAM.elf"
)
add_custom_target("${CMAKE_PROJECT_NAME}_RAM_HEX" DEPENDS "${CMAKE_PROJECT_NAME}_RAM.hex")