Skip to content

CMake: Include only the libraries required #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ matrix:
- pip install "Jinja2>=2.10.1,<2.11"
- pip install "intelhex>=1.3,<=2.2.1"
script:
- mbedtools checkout
- echo mbedtools build -t GCC_ARM -m ${TARGET_NAME} -b ${PROFILE}
- mbedtools build -t GCC_ARM -m ${TARGET_NAME} -b ${PROFILE}
- mbedtools deploy
- echo mbedtools compile -t GCC_ARM -m ${TARGET_NAME} -b ${PROFILE}
- mbedtools compile -t GCC_ARM -m ${TARGET_NAME} -b ${PROFILE}
- ccache -s

- &build-test
Expand Down
34 changes: 31 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,41 @@ target_sources(${APP_TARGET}
main.cpp
)

list(APPEND mbed_storage_libs)

if("DATAFLASH" IN_LIST MBED_TARGET_LABELS)
list(APPEND mbed_storage_libs mbed-storage-dataflash)
endif()

if("FLASHIAP" IN_LIST MBED_TARGET_LABELS)
list(APPEND mbed_storage_libs mbed-storage-flashiap)
endif()

if("I2CEE" IN_LIST MBED_TARGET_LABELS)
list(APPEND mbed_storage_libs mbed-storage-i2cee)
endif()

if("OSPIF" IN_LIST MBED_TARGET_LABELS)
list(APPEND mbed_storage_libs mbed-storage-ospif)
endif()

if("QSPIF" IN_LIST MBED_TARGET_LABELS)
list(APPEND mbed_storage_libs mbed-storage-qspif)
endif()

if("SD" IN_LIST MBED_TARGET_LABELS)
list(APPEND mbed_storage_libs mbed-storage-sd)
endif()

if("SPIF" IN_LIST MBED_TARGET_LABELS)
list(APPEND mbed_storage_libs mbed-storage-spif)
endif()

target_link_libraries(${APP_TARGET}
PRIVATE
mbed-os
mbed-events
mbed-storage
mbed-storage-qspif
mbed-storage-flashiap
${mbed_storage_libs}
)

mbed_set_post_build(${APP_TARGET})
Expand Down
24 changes: 13 additions & 11 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,32 @@
// Block devices
#if COMPONENT_QSPIF
#include "QSPIFBlockDevice.h"
QSPIFBlockDevice bd;
#endif

#if COMPONENT_OSPIF
#include "OSPIFBlockDevice.h"
OSPIFBlockDevice bd;
#endif

#if COMPONENT_SPIF
#include "SPIFBlockDevice.h"
// Physical block device, can be any device that supports the BlockDevice API
SPIFBlockDevice bd;
#endif

#if COMPONENT_DATAFLASH
#include "DataFlashBlockDevice.h"
#endif
DataFlashBlockDevice bd;
#endif

#if COMPONENT_SD
#include "SDBlockDevice.h"
#endif

#include "HeapBlockDevice.h"


// Physical block device, can be any device that supports the BlockDevice API
SDBlockDevice bd(
MBED_CONF_SD_SPI_MOSI,
MBED_CONF_SD_SPI_MISO,
MBED_CONF_SD_SPI_CLK,
MBED_CONF_SD_SPI_CS);
SDBlockDevice bd;
#endif

#include "HeapBlockDevice.h"

// Entry point for the example
int main() {
Expand Down