Support for multiple platforms in a single repository is possible and several platform repositories can be used as reference. A good example of this file for a repository which supports only a single platform is from ot-cc2538. This is where you define the source files, include paths, and compiler flags for your platform library. In the above CMakeLists.txt, an existing library target named app is configured to include the source file src/main.c. This post shows how to create and consume simple libraries using modern CMake. In practice, very few projects are fully self-contained, as they either depend on external libraries or are themselves libraries that other projects depend on. A good starting point would be to copy the ot-efr32 version of this file and modify it to fit your platform. My previous post about CMake provided a simple CMakeLists.txt for a small, self-contained, project. This is a toolchain file which defines some variables that CMake uses in the build process. It also contains a few other required files. This is the heart of the repository and is where the platform abstraction layer is implemented. If you would like to include sample applications in the repo, create an examples folder and add it to the build tree as well. If you want to build multiple CMake projects and include their outputs in your Android project, you can use one CMakeLists.txt file as the top-level CMake build script (which is the one you link to Gradle) and add additional CMake projects as dependencies of that build script. The third_party folder contains any third-party code. Add a filepath to the include-path used during build. Typical actions include: Build a library or an executable out of some of the source files in this directory. It also defines which subdirectories CMake should handle as well. The src folder is where the platform-abstration layer source code is located. Each directory's CMakeLists file defines what the buildsystem should do in that specific directory. Now that the top-level configuration is defined, it's time to add other subdirectories to the build tree. set_property(CACHE EFR32_PLATFORM PROPERTY STRINGS $/crypto The CMakeLists.txt file includes a check that aborts builds launched for unsupported platforms. CMake variable names are case sensitive and may only contain alphanumeric characters and underscores. For the sake of this example, we've defined multiple platforms, but having a single platform for the _PLATFORM_VALUES variable is fine as well. CMakeLists files use variables much like any programming language. We also define a variable EFR32_PLATFORM_VALUES which is a list of efr32 platforms supported by ot-efr32. In this example, we set the project name to ot-efr32 with a version of 0.0.1. The very first values to define are the project name and the supported platforms. The CMakeLists.txt at the root of your repository is the top of the build tree and is a good place to start defining the various targets, options, and macros used in the build process. The CMake build system relies on CMakeLists.txt files which define build targets.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |