mbed.h library with any bug fixes AV finds.
Dependents: micromouse4_encoder_testing PID_Test Lab1_Test WorkingPID ... more
CMakeLists.txt@1:ebce2ad32f95, 2015-11-02 (annotated)
- Committer:
- aravindsv
- Date:
- Mon Nov 02 03:07:12 2015 +0000
- Revision:
- 1:ebce2ad32f95
- Parent:
- 0:ba7650f404af
Changed the RCC timeout value to 500 ms, so total code startup time before program starts running is ~1s. Hopefully no side-effects from lower startup timeouts
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
aravindsv | 0:ba7650f404af | 1 | # |
aravindsv | 0:ba7650f404af | 2 | # mbed-2 yotta-compatible build system |
aravindsv | 0:ba7650f404af | 3 | # |
aravindsv | 0:ba7650f404af | 4 | |
aravindsv | 0:ba7650f404af | 5 | # make sure necessary features are enabled: |
aravindsv | 0:ba7650f404af | 6 | project(mbed-classic) |
aravindsv | 0:ba7650f404af | 7 | enable_language(ASM) |
aravindsv | 0:ba7650f404af | 8 | |
aravindsv | 0:ba7650f404af | 9 | # override compilation flags: |
aravindsv | 0:ba7650f404af | 10 | if(CMAKE_C_COMPILER_ID MATCHES GNU) |
aravindsv | 0:ba7650f404af | 11 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99") |
aravindsv | 0:ba7650f404af | 12 | endif() |
aravindsv | 0:ba7650f404af | 13 | |
aravindsv | 0:ba7650f404af | 14 | # the mbed.a library is built from two sets of source files + include |
aravindsv | 0:ba7650f404af | 15 | # directories: |
aravindsv | 0:ba7650f404af | 16 | # |
aravindsv | 0:ba7650f404af | 17 | # MBED_COMMON_SOURCES: the source files that are the same for all targets, |
aravindsv | 0:ba7650f404af | 18 | # these are easily found by globbing: |
aravindsv | 0:ba7650f404af | 19 | # |
aravindsv | 0:ba7650f404af | 20 | file(GLOB MBED_COMMON_SOURCES "common/*.cpp" "common/*.c") |
aravindsv | 0:ba7650f404af | 21 | # |
aravindsv | 0:ba7650f404af | 22 | # (always include the hal header directory, too) |
aravindsv | 0:ba7650f404af | 23 | set(MBED_COMMON_INCLUDE_DIRS "hal") |
aravindsv | 0:ba7650f404af | 24 | |
aravindsv | 0:ba7650f404af | 25 | # and MBED_TARGET_SOURCES: these depend on which target we are building for. To |
aravindsv | 0:ba7650f404af | 26 | # find these we need to walk the directories in targets/, and wherever we see a |
aravindsv | 0:ba7650f404af | 27 | # TARGET_<something> name, recurse only if <something> matches what we're |
aravindsv | 0:ba7650f404af | 28 | # currently building for |
aravindsv | 0:ba7650f404af | 29 | macro(mbed_find_target_dirs PARENT_DIRECTORY SOURCES_LIST INCLUDES_LIST) |
aravindsv | 0:ba7650f404af | 30 | # append this directory to the search path: |
aravindsv | 0:ba7650f404af | 31 | list(APPEND ${INCLUDES_LIST} "${PARENT_DIRECTORY}") |
aravindsv | 0:ba7650f404af | 32 | # add all source files in this directory to the sources list: |
aravindsv | 0:ba7650f404af | 33 | file(GLOB sources "${PARENT_DIRECTORY}/*.cpp" "${PARENT_DIRECTORY}/*.c" "${PARENT_DIRECTORY}/*.s" "${PARENT_DIRECTORY}/*.S" ) |
aravindsv | 0:ba7650f404af | 34 | list(APPEND ${SOURCES_LIST} ${sources}) |
aravindsv | 0:ba7650f404af | 35 | |
aravindsv | 0:ba7650f404af | 36 | # get a list of all subdirectories that we want to recurse into: |
aravindsv | 0:ba7650f404af | 37 | file(GLOB dir_children RELATIVE "${PARENT_DIRECTORY}" "${PARENT_DIRECTORY}/*") |
aravindsv | 0:ba7650f404af | 38 | set(matching_subdirs "") |
aravindsv | 0:ba7650f404af | 39 | foreach(child ${dir_children}) |
aravindsv | 0:ba7650f404af | 40 | if(IS_DIRECTORY "${PARENT_DIRECTORY}/${child}") |
aravindsv | 0:ba7650f404af | 41 | # is this directory name a magic one? |
aravindsv | 0:ba7650f404af | 42 | if("${child}" MATCHES "^TARGET_") |
aravindsv | 0:ba7650f404af | 43 | # target-magic: recurse if the MBED_LEGACY_TARGET_DEFINITIONS **list** |
aravindsv | 0:ba7650f404af | 44 | # contains a matching value: |
aravindsv | 0:ba7650f404af | 45 | foreach(legacy_magic_def ${MBED_LEGACY_TARGET_DEFINITIONS}) |
aravindsv | 0:ba7650f404af | 46 | # we could probably unroll the list into a single regex if |
aravindsv | 0:ba7650f404af | 47 | # this is a performance problem: |
aravindsv | 0:ba7650f404af | 48 | if("${child}" MATCHES "^TARGET_${legacy_magic_def}$") |
aravindsv | 0:ba7650f404af | 49 | list(APPEND matching_subdirs ${child}) |
aravindsv | 0:ba7650f404af | 50 | break() |
aravindsv | 0:ba7650f404af | 51 | endif() |
aravindsv | 0:ba7650f404af | 52 | endforeach() |
aravindsv | 0:ba7650f404af | 53 | elseif("${child}" MATCHES "^TOOLCHAIN_") |
aravindsv | 0:ba7650f404af | 54 | # toolchain-magic: (recurse if the MBED_LEGACY_TOOLCHAIN matches |
aravindsv | 0:ba7650f404af | 55 | # this name) |
aravindsv | 0:ba7650f404af | 56 | if("${child}" MATCHES "^TOOLCHAIN_${MBED_LEGACY_TOOLCHAIN}$") |
aravindsv | 0:ba7650f404af | 57 | list(APPEND matching_subdirs "${child}") |
aravindsv | 0:ba7650f404af | 58 | endif() |
aravindsv | 0:ba7650f404af | 59 | else() |
aravindsv | 0:ba7650f404af | 60 | # not special: always recurse into this directory |
aravindsv | 0:ba7650f404af | 61 | list(APPEND matching_subdirs "${child}") |
aravindsv | 0:ba7650f404af | 62 | endif() |
aravindsv | 0:ba7650f404af | 63 | endif() |
aravindsv | 0:ba7650f404af | 64 | endforeach() |
aravindsv | 0:ba7650f404af | 65 | #message("matching_subdirs: ${matching_subdirs}") |
aravindsv | 0:ba7650f404af | 66 | |
aravindsv | 0:ba7650f404af | 67 | # recurse: |
aravindsv | 0:ba7650f404af | 68 | foreach(subdir ${matching_subdirs}) |
aravindsv | 0:ba7650f404af | 69 | mbed_find_target_dirs("${PARENT_DIRECTORY}/${subdir}" ${SOURCES_LIST} ${INCLUDES_LIST}) |
aravindsv | 0:ba7650f404af | 70 | endforeach() |
aravindsv | 0:ba7650f404af | 71 | endmacro() |
aravindsv | 0:ba7650f404af | 72 | |
aravindsv | 0:ba7650f404af | 73 | set(MBED_TARGET_SOURCES "") |
aravindsv | 0:ba7650f404af | 74 | set(MBED_TARGET_INCLUDE_DIRS "") |
aravindsv | 0:ba7650f404af | 75 | mbed_find_target_dirs("${CMAKE_CURRENT_SOURCE_DIR}/targets" MBED_TARGET_SOURCES MBED_TARGET_INCLUDE_DIRS) |
aravindsv | 0:ba7650f404af | 76 | #message("found target sources: ${MBED_TARGET_SOURCES}") |
aravindsv | 0:ba7650f404af | 77 | #message("found target include dirs: ${MBED_TARGET_INCLUDE_DIRS}") |
aravindsv | 0:ba7650f404af | 78 | |
aravindsv | 0:ba7650f404af | 79 | # unfortunately, for ARMCC, the startup code needs to be provided as an object |
aravindsv | 0:ba7650f404af | 80 | # on the command line (not as part of an archive). To do this we override the |
aravindsv | 0:ba7650f404af | 81 | # CMake add_executable command. |
aravindsv | 0:ba7650f404af | 82 | if(CMAKE_C_COMPILER_ID STREQUAL "ARMCC") |
aravindsv | 0:ba7650f404af | 83 | set(MBED_TARGET_STARTUP_CODE_SOURCES "") |
aravindsv | 0:ba7650f404af | 84 | foreach(src ${MBED_TARGET_SOURCES}) |
aravindsv | 0:ba7650f404af | 85 | if("${src}" MATCHES .*startup_.*\\.[sS]) |
aravindsv | 0:ba7650f404af | 86 | LIST(APPEND MBED_TARGET_STARTUP_CODE_SOURCES "${src}") |
aravindsv | 0:ba7650f404af | 87 | endif() |
aravindsv | 0:ba7650f404af | 88 | endforeach() |
aravindsv | 0:ba7650f404af | 89 | add_library(mbed_classic_startupcod OBJECT ${MBED_TARGET_STARTUP_CODE_SOURCES}) |
aravindsv | 0:ba7650f404af | 90 | macro (add_executable _name) |
aravindsv | 0:ba7650f404af | 91 | _add_executable(${ARGV} $<TARGET_OBJECTS:mbed_classic_startupcod>) |
aravindsv | 0:ba7650f404af | 92 | endmacro() |
aravindsv | 0:ba7650f404af | 93 | endif() |
aravindsv | 0:ba7650f404af | 94 | |
aravindsv | 0:ba7650f404af | 95 | # we have to append any target-specific include dirs to the global include dirs |
aravindsv | 0:ba7650f404af | 96 | # list, so that any indirect includes (e.g. via mbed.h) of files in those |
aravindsv | 0:ba7650f404af | 97 | # directories will work: |
aravindsv | 0:ba7650f404af | 98 | # (non-target-specific include dirs are listed in extraIncludes in module.json) |
aravindsv | 0:ba7650f404af | 99 | foreach(dir ${MBED_TARGET_INCLUDE_DIRS}) |
aravindsv | 0:ba7650f404af | 100 | set_property(GLOBAL APPEND PROPERTY YOTTA_GLOBAL_INCLUDE_DIRS ${dir}) |
aravindsv | 0:ba7650f404af | 101 | endforeach() |
aravindsv | 0:ba7650f404af | 102 | |
aravindsv | 0:ba7650f404af | 103 | # finally, we can construct a library using the determined set of include paths |
aravindsv | 0:ba7650f404af | 104 | # + source files. Note that the library name must match the name of the yotta |
aravindsv | 0:ba7650f404af | 105 | # module (defined in module.json) for this module to link properly with other |
aravindsv | 0:ba7650f404af | 106 | # yotta modules. |
aravindsv | 0:ba7650f404af | 107 | include_directories(${MBED_COMMON_INCLUDE_DIRS}) |
aravindsv | 0:ba7650f404af | 108 | include_directories(${MBED_TARGET_INCLUDE_DIRS}) |
aravindsv | 0:ba7650f404af | 109 | add_library(mbed-classic |
aravindsv | 0:ba7650f404af | 110 | ${MBED_COMMON_SOURCES} |
aravindsv | 0:ba7650f404af | 111 | ${MBED_TARGET_SOURCES} |
aravindsv | 0:ba7650f404af | 112 | ) |