Reformatted the CMakeLists for consistency

This commit is contained in:
Avamander 2020-10-02 21:43:30 +03:00
parent 9348f9936d
commit 455d8319e4
2 changed files with 463 additions and 435 deletions

View file

@ -4,7 +4,7 @@ project(pinetime VERSION 0.8.2 LANGUAGES C CXX ASM)
set(NRF_TARGET "nrf52") set(NRF_TARGET "nrf52")
if (NOT ARM_NONE_EABI_TOOLCHAIN_PATH) if (NOT ARM_NONE_EABI_TOOLCHAIN_PATH)
message(FATAL_ERROR "The path to the toolchain (arm-non-eabi) must be specified on the command line (add -DARM_NONE_EABI_TOOLCHAIN_PATH=<path>") message(FATAL_ERROR "The path to the toolchain (arm-none-eabi) must be specified on the command line (add -DARM_NONE_EABI_TOOLCHAIN_PATH=<path>")
endif () endif ()
if (NOT NRF5_SDK_PATH) if (NOT NRF5_SDK_PATH)

View file

@ -10,20 +10,20 @@ set(NRF_BOARD pca10040)
if (NOT NRF5_SDK_PATH) if (NOT NRF5_SDK_PATH)
message(FATAL_ERROR "The path to the nRF5 SDK (NRF5_SDK_PATH) must be set.") message(FATAL_ERROR "The path to the nRF5 SDK (NRF5_SDK_PATH) must be set.")
endif () endif ()
if(DEFINED ARM_NONE_EABI_TOOLCHAIN_PATH) if (DEFINED ARM_NONE_EABI_TOOLCHAIN_PATH)
set(ARM_NONE_EABI_TOOLCHAIN_BIN_PATH ${ARM_NONE_EABI_TOOLCHAIN_PATH}/bin) set(ARM_NONE_EABI_TOOLCHAIN_BIN_PATH ${ARM_NONE_EABI_TOOLCHAIN_PATH}/bin)
endif() endif ()
if (NOT NRF_TARGET MATCHES "nrf52") if (NOT NRF_TARGET MATCHES "nrf52")
message(FATAL_ERROR "Only rRF52 boards are supported right now") message(FATAL_ERROR "Only rRF52 boards are supported right now")
endif() endif ()
# Setup toolchain # Setup toolchain
include(${CMAKE_SOURCE_DIR}/cmake-nRF5x/arm-gcc-toolchain.cmake) include(${CMAKE_SOURCE_DIR}/cmake-nRF5x/arm-gcc-toolchain.cmake)
if(NOT DEFINED ARM_GCC_TOOLCHAIN) if (NOT DEFINED ARM_GCC_TOOLCHAIN)
message(FATAL_ERROR "The toolchain must be set up before calling this macro") message(FATAL_ERROR "The toolchain must be set up before calling this macro")
endif() endif ()
set(CMAKE_OSX_SYSROOT "/") set(CMAKE_OSX_SYSROOT "/")
set(CMAKE_OSX_DEPLOYMENT_TARGET "") set(CMAKE_OSX_DEPLOYMENT_TARGET "")
@ -84,7 +84,7 @@ set(SDK_SOURCE_FILES
# GPIOTE # GPIOTE
"${NRF5_SDK_PATH}/components/libraries/gpiote/app_gpiote.c" "${NRF5_SDK_PATH}/components/libraries/gpiote/app_gpiote.c"
) )
set(TINYCRYPT_SRC set(TINYCRYPT_SRC
libs/mynewt-nimble/ext/tinycrypt/src/aes_encrypt.c libs/mynewt-nimble/ext/tinycrypt/src/aes_encrypt.c
@ -376,7 +376,7 @@ list(APPEND SOURCE_FILES
SystemTask/SystemTask.cpp SystemTask/SystemTask.cpp
drivers/TwiMaster.cpp drivers/TwiMaster.cpp
) )
list(APPEND GRAPHICS_SOURCE_FILES list(APPEND GRAPHICS_SOURCE_FILES
# FreeRTOS # FreeRTOS
@ -394,7 +394,7 @@ list(APPEND GRAPHICS_SOURCE_FILES
Components/Brightness/BrightnessController.cpp Components/Brightness/BrightnessController.cpp
graphics.cpp graphics.cpp
) )
set(INCLUDE_FILES set(INCLUDE_FILES
Logging/Logger.h Logging/Logger.h
@ -455,7 +455,7 @@ set(INCLUDE_FILES
SystemTask/SystemMonitor.h SystemTask/SystemMonitor.h
DisplayApp/Screens/Symbols.h DisplayApp/Screens/Symbols.h
drivers/TwiMaster.h drivers/TwiMaster.h
) )
include_directories( include_directories(
. .
@ -563,9 +563,9 @@ add_definitions(-DDEBUG_NRF_USER)
add_definitions(-D__STACK_SIZE=8192) add_definitions(-D__STACK_SIZE=8192)
add_definitions(-D__HEAP_SIZE=8192) add_definitions(-D__HEAP_SIZE=8192)
if(NOT CMAKE_BUILD_TYPE) if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release") set(CMAKE_BUILD_TYPE "Release")
endif() endif ()
# NRF SDK # NRF SDK
add_library(nrf-sdk STATIC ${SDK_SOURCE_FILES}) add_library(nrf-sdk STATIC ${SDK_SOURCE_FILES})
@ -616,7 +616,7 @@ target_compile_options(${EXECUTABLE_NAME} PUBLIC
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3> $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:DEBUG>>: ${COMMON_FLAGS} -O0 -g3>
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3> $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>: ${COMMON_FLAGS} -O3>
$<$<COMPILE_LANGUAGE:ASM>: -MP -MD -std=c99 -x assembler-with-cpp> $<$<COMPILE_LANGUAGE:ASM>: -MP -MD -std=c99 -x assembler-with-cpp>
) )
set_target_properties(${EXECUTABLE_NAME} PROPERTIES set_target_properties(${EXECUTABLE_NAME} PROPERTIES
SUFFIX ".out" SUFFIX ".out"
@ -663,7 +663,7 @@ add_custom_command(TARGET ${EXECUTABLE_MCUBOOT_NAME}
COMMAND ${CMAKE_OBJCOPY} -O binary ${EXECUTABLE_MCUBOOT_FILE_NAME}.out "${EXECUTABLE_MCUBOOT_FILE_NAME}.bin" COMMAND ${CMAKE_OBJCOPY} -O binary ${EXECUTABLE_MCUBOOT_FILE_NAME}.out "${EXECUTABLE_MCUBOOT_FILE_NAME}.bin"
COMMAND ${CMAKE_OBJCOPY} -O ihex ${EXECUTABLE_MCUBOOT_FILE_NAME}.out "${EXECUTABLE_MCUBOOT_FILE_NAME}.hex" COMMAND ${CMAKE_OBJCOPY} -O ihex ${EXECUTABLE_MCUBOOT_FILE_NAME}.out "${EXECUTABLE_MCUBOOT_FILE_NAME}.hex"
COMMENT "post build steps for ${EXECUTABLE_MCUBOOT_FILE_NAME}" COMMENT "post build steps for ${EXECUTABLE_MCUBOOT_FILE_NAME}"
) )
# Build binary that writes the graphic assets for the bootloader # Build binary that writes the graphic assets for the bootloader
set(EXECUTABLE_GRAPHICS_NAME "pinetime-graphics") set(EXECUTABLE_GRAPHICS_NAME "pinetime-graphics")
@ -695,7 +695,7 @@ add_custom_command(TARGET ${EXECUTABLE_GRAPHICS_NAME}
) )
# FLASH # FLASH
if(USE_JLINK) if (USE_JLINK)
add_custom_target(FLASH_ERASE add_custom_target(FLASH_ERASE
COMMAND ${NRFJPROG} --eraseall -f ${NRF_TARGET} COMMAND ${NRFJPROG} --eraseall -f ${NRF_TARGET}
COMMENT "erasing flashing" COMMENT "erasing flashing"
@ -708,7 +708,7 @@ if(USE_JLINK)
COMMENT "flashing ${EXECUTABLE_NAME}.hex" COMMENT "flashing ${EXECUTABLE_NAME}.hex"
) )
elseif(USE_GDB_CLIENT) elseif (USE_GDB_CLIENT)
add_custom_target(FLASH_ERASE add_custom_target(FLASH_ERASE
COMMAND ${GDB_CLIENT_BIN_PATH} -nx --batch -ex 'target extended-remote ${GDB_CLIENT_TARGET_REMOTE}' -ex 'monitor swdp_scan' -ex 'attach 1' -ex 'mon erase_mass' COMMAND ${GDB_CLIENT_BIN_PATH} -nx --batch -ex 'target extended-remote ${GDB_CLIENT_TARGET_REMOTE}' -ex 'monitor swdp_scan' -ex 'attach 1' -ex 'mon erase_mass'
COMMENT "erasing flashing" COMMENT "erasing flashing"
@ -718,7 +718,36 @@ elseif(USE_GDB_CLIENT)
COMMAND ${GDB_CLIENT_BIN_PATH} -nx --batch -ex 'target extended-remote ${GDB_CLIENT_TARGET_REMOTE}' -ex 'monitor swdp_scan' -ex 'attach 1' -ex 'load' -ex 'kill' ${EXECUTABLE_NAME}.hex COMMAND ${GDB_CLIENT_BIN_PATH} -nx --batch -ex 'target extended-remote ${GDB_CLIENT_TARGET_REMOTE}' -ex 'monitor swdp_scan' -ex 'attach 1' -ex 'load' -ex 'kill' ${EXECUTABLE_NAME}.hex
COMMENT "flashing ${EXECUTABLE_NAME}.hex" COMMENT "flashing ${EXECUTABLE_NAME}.hex"
) )
elseif(USE_OPENOCD) elseif (USE_OPENOCD)
if (USE_CMSIS_DAP)
add_custom_target(FLASH_ERASE
COMMAND ${OPENOCD_BIN_PATH} -c 'source [find interface/cmsis-dap.cfg]' -c 'transport select swd'
-c 'source [find target/nrf52.cfg]'
-c 'init'
-c 'halt'
-c 'nrf5 mass_erase'
-c 'halt'
-c 'reset'
-c 'exit'
COMMENT "erasing flashing"
)
add_custom_target("FLASH_${EXECUTABLE_NAME}"
DEPENDS ${EXECUTABLE_NAME}
COMMAND ${OPENOCD_BIN_PATH}
-c 'tcl_port disabled'
-c 'gdb_port 3333'
-c 'telnet_port 4444'
-c 'source [find interface/cmsis-dap.cfg]'
-c 'transport select swd'
-c 'source [find target/nrf52.cfg]'
-c 'halt'
-c "program \"${EXECUTABLE_NAME}.hex\""
-c 'reset'
-c 'shutdown'
COMMENT "flashing ${EXECUTABLE_NAME}.hex"
)
else ()
message()
add_custom_target(FLASH_ERASE add_custom_target(FLASH_ERASE
COMMAND ${OPENOCD_BIN_PATH} -f interface/stlink.cfg -c 'transport select hla_swd' -f target/nrf52.cfg -c init -c halt -c 'nrf5 mass_erase' -c reset -c shutdown COMMAND ${OPENOCD_BIN_PATH} -f interface/stlink.cfg -c 'transport select hla_swd' -f target/nrf52.cfg -c init -c halt -c 'nrf5 mass_erase' -c reset -c shutdown
COMMENT "erasing flashing" COMMENT "erasing flashing"
@ -728,6 +757,5 @@ elseif(USE_OPENOCD)
COMMAND ${OPENOCD_BIN_PATH} -c "tcl_port disabled" -c "gdb_port 3333" -c "telnet_port 4444" -f interface/stlink.cfg -c 'transport select hla_swd' -f target/nrf52.cfg -c "program \"${EXECUTABLE_NAME}.hex\"" -c reset -c shutdown COMMAND ${OPENOCD_BIN_PATH} -c "tcl_port disabled" -c "gdb_port 3333" -c "telnet_port 4444" -f interface/stlink.cfg -c 'transport select hla_swd' -f target/nrf52.cfg -c "program \"${EXECUTABLE_NAME}.hex\"" -c reset -c shutdown
COMMENT "flashing ${EXECUTABLE_NAME}.hex" COMMENT "flashing ${EXECUTABLE_NAME}.hex"
) )
endif ()
endif() endif ()