From 1e1bb1c6b7d7fdf6299c97bc11555b08f034f324 Mon Sep 17 00:00:00 2001 From: JF Date: Mon, 17 Aug 2020 16:48:12 +0200 Subject: [PATCH] Build lvgl, nimble and nrf sdk as static libs. This allows to specify custom build param and to remove warnings from these libs. This also speeds up the build of the whole project as those libs are now built once for the 3 targets. --- src/CMakeLists.txt | 46 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b48b8510..d5b4e1be 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -363,11 +363,6 @@ list(APPEND SOURCE_FILES FreeRTOS/port.c FreeRTOS/port_cmsis_systick.c FreeRTOS/port_cmsis.c - ${TINYCRYPT_SRC} - ${NIMBLE_SRC} - ${LVGL_SRC} - #${IMAGE_FILES} - ${SDK_SOURCE_FILES} DisplayApp/LittleVgl.cpp DisplayApp/Fonts/jetbrains_mono_extrabold_compressed.c @@ -378,8 +373,6 @@ list(APPEND SOURCE_FILES ) list(APPEND GRAPHICS_SOURCE_FILES - ${SDK_SOURCE_FILES} - # FreeRTOS FreeRTOS/port.c FreeRTOS/port_cmsis_systick.c @@ -564,10 +557,47 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release") endif() +# NRF SDK +add_library(nrf-sdk STATIC ${SDK_SOURCE_FILES}) +target_include_directories(nrf-sdk SYSTEM PUBLIC . ../) +target_include_directories(nrf-sdk SYSTEM PUBLIC ${INCLUDES_FROM_LIBS}) +target_compile_options(nrf-sdk PRIVATE + $<$,$>: ${COMMON_FLAGS} -O0 -g3> + $<$,$>: ${COMMON_FLAGS} -O3> + $<$,$>: ${COMMON_FLAGS} -O0> + $<$,$>: ${COMMON_FLAGS} -O3> + $<$: -MP -MD -std=c99 -x assembler-with-cpp> + ) + +# NimBLE +add_library(nimble STATIC ${NIMBLE_SRC} ${TINYCRYPT_SRC}) +target_include_directories(nimble SYSTEM PUBLIC . ../) +target_include_directories(nimble SYSTEM PUBLIC ${INCLUDES_FROM_LIBS}) +target_compile_options(nimble PRIVATE + $<$,$>: ${COMMON_FLAGS} -O0 -g3 -Wno-unused-but-set-variable -Wno-maybe-uninitialized> + $<$,$>: ${COMMON_FLAGS} -O3 -Wno-unused-but-set-variable -Wno-maybe-uninitialized> + $<$,$>: ${COMMON_FLAGS} -O0 -g3 -Wno-unused-but-set-variable -Wno-maybe-uninitialized> + $<$,$>: ${COMMON_FLAGS} -O3 -Wno-unused-but-set-variable -Wno-maybe-uninitialized> + $<$: -MP -MD -std=c99 -x assembler-with-cpp> + ) + +# lvgl +add_library(lvgl STATIC ${LVGL_SRC}) +target_include_directories(lvgl SYSTEM PUBLIC . ../) +target_include_directories(lvgl SYSTEM PUBLIC ${INCLUDES_FROM_LIBS}) +target_compile_options(lvgl PRIVATE + $<$,$>: ${COMMON_FLAGS} -O0 -g3> + $<$,$>: ${COMMON_FLAGS} -O3> + $<$,$>: ${COMMON_FLAGS} -O0 -g3> + $<$,$>: ${COMMON_FLAGS} -O3> + $<$: -MP -MD -std=c99 -x assembler-with-cpp> + ) + # Build autonomous binary (without support for bootloader) set(EXECUTABLE_NAME "pinetime-app") set(NRF5_LINKER_SCRIPT "${CMAKE_SOURCE_DIR}/gcc_nrf52.ld") add_executable(${EXECUTABLE_NAME} ${SOURCE_FILES}) +target_link_libraries(${EXECUTABLE_NAME} nimble nrf-sdk lvgl) target_compile_options(${EXECUTABLE_NAME} PUBLIC $<$,$>: ${COMMON_FLAGS} -O0 -g3> $<$,$>: ${COMMON_FLAGS} -O3> @@ -596,6 +626,7 @@ set(EXECUTABLE_MCUBOOT_NAME "pinetime-mcuboot-app") set(EXECUTABLE_MCUBOOT_WITH_BOOTLOADER_NAME "pinetime-mcuboot-app-wth-bootloader") set(NRF5_LINKER_SCRIPT_MCUBOOT "${CMAKE_SOURCE_DIR}/gcc_nrf52-mcuboot.ld") add_executable(${EXECUTABLE_MCUBOOT_NAME} ${SOURCE_FILES}) +target_link_libraries(${EXECUTABLE_MCUBOOT_NAME} nimble nrf-sdk lvgl) target_compile_options(${EXECUTABLE_MCUBOOT_NAME} PUBLIC $<$,$>: ${COMMON_FLAGS} -O0 -g3> $<$,$>: ${COMMON_FLAGS} -O3> @@ -622,6 +653,7 @@ add_custom_command(TARGET ${EXECUTABLE_MCUBOOT_NAME} # Build binary that writes the graphic assets for the bootloader set(EXECUTABLE_GRAPHICS_NAME "pinetime-graphics") add_executable(${EXECUTABLE_GRAPHICS_NAME} ${GRAPHICS_SOURCE_FILES}) +target_link_libraries(${EXECUTABLE_GRAPHICS_NAME} nrf-sdk) target_compile_options(${EXECUTABLE_GRAPHICS_NAME} PUBLIC $<$,$>: ${COMMON_FLAGS} -O0 -g3> $<$,$>: ${COMMON_FLAGS} -O3>