You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/user-manual/build-system/01-cmake-intro.md
+7-22Lines changed: 7 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,27 +2,20 @@
2
2
3
3
F´ leverages CMake as its underlying build system, adding an [API layer](../../reference/api/cmake/API.md) for ease of use.
4
4
5
-
Since this F´ CMake system is designed to follow CMake norms, certain caveats must be understood before beginning to use CMake. These are described below:
6
-
7
-
1. CMake should not be used in tandem with the original make system. If it is needed to switch
8
-
between make systems, perform a `git clean -xdf` command or otherwise remove **all** generated files.
9
-
2. CMake in-source builds are dangerous. Use CMake out-of-source builds.
10
-
11
-
12
5
Installation guides for CMake can be found here: [https://cmake.org/install/](https://cmake.org/install/).
13
6
14
7
A Basic CMake tutorial can be found here: [https://cmake.org/cmake/help/latest/guide/tutorial/index.html](https://cmake.org/cmake/help/latest/guide/tutorial/index.html).
15
8
Although fprime tries to simplify CMake usage for fprime-specific tasks, an understanding of basic CMake is useful.
16
9
17
10
## Getting Started with CMake and F´
18
11
19
-
CMake as a system auto-generates OS-specific make files for building F´. Once these file are generated, standard make tools can be run to perform the compiling, assembling, linking, etc. In other words, CMake is a high-level build system that defers low-level build systems to build. It generates the inputs to these low-level systems in a straightforward way.
12
+
CMake as a system auto-generates OS-specific build files for building F´. Once these files are generated, standard build tools can be run to perform the compiling, assembling, linking, etc. In other words, CMake is a high-level build system that defers low-level build systems to build. It generates the inputs to these low-level systems in a straightforward way.
20
13
21
-
fprime sets up CMake in such a way that adding a module (component, port, deployment) is easy and automatically takes
14
+
F´ sets up CMake in such a way that adding a module (component, port, deployment) is easy and automatically takes
22
15
advantage of the autocoding capabilities of fprime. To add new modules to the CMake system, users need to perform the following steps:
23
16
24
17
1. Define a `CMakeLists.txt` file to define the module's source files and dependencies
25
-
2. Ensure that `register_fprime_module` or `register_fprime_executable` is called in that `CMakeLists.txt`
18
+
2. Ensure that `register_fprime_module` or `register_fprime_deployment` is called in that `CMakeLists.txt`
26
19
3. Make sure this new directory defining the `CMakeLists.txt` is added to the deployment `CMakeLists.txt` using
27
20
`add_fprime_subdirectory`.
28
21
@@ -33,22 +26,14 @@ steps can be found in [API](./cmake-api.md). This document will explain the usag
33
26
34
27
The CMakeList.txt file defines the steps needed to build **something** in CMake. In fprime, we use this file to define the source, autocoder, and module dependencies for modules in fprime. A `register_` function is called to tie into the fprime autocoder environment. This keeps fprime modules simple, although all of CMake's power can be used when needed.
35
28
36
-
Users need only set the `SOURCE_FILES` variable to a list of autocoder and code sources and then call
37
-
`register_fprime_module` to setup a module for fprime (Port/Component). Deployments are done similarly, but since these
38
-
`CMakeLists.txt` files are the entry point to a build, more setup is needed. Deployments should also call
39
-
`register_fprime_executable` as a binary output is desired. `add_fprime_subdirectory` is also used in deployments to
40
-
link to all the other modules they use.
29
+
Users need only set the `AUTOCODER_INPUTS` and `SOURCES` directives to a list of autocoder and code sources as part of the
30
+
`register_fprime_module` call to setup a module for fprime (Port/Component). Deployments are done similarly but use the
31
+
`register_fprime_deployment` call instead.
41
32
42
33
`add_fprime_subdirectory`, `register_fprime_module`, `register_fprime_executable` docs are here: [API](./cmake-api.md).
43
34
44
-
A template module `CMakeLists.txt` is documented: [module-CMakeLists.txt-template.md](../../../cmake/module-CMakeLists.txt.template)
45
-
Remember it should be renamed to `CMakeLists.txt` in your module's folder.
46
-
47
-
A template deployment `CMakeLists.txt` is documented: [deployment-CMakeLists.txt-template.md](../../../cmake/deployment-CMakeLists.txt.template).
48
-
Remember it should be renamed to `CMakeLists.txt` in your deployments folder.
49
35
50
-
When building a module, ensure it at least calls `register_fprime_module`. Deployments may call
51
-
`register_fprime_executable` in the deployment `CMakeLists.txt` or in any child (usually Top/CMakeLists.txt).
36
+
When defining a module, ensure it at least calls `register_fprime_module`, or `register_fprime_deployment`.
52
37
53
38
When building a module, remember to add it to the deployment by adding a line `add_fprime_subdirectory(path/module/dir)`
Copy file name to clipboardExpand all lines: docs/user-manual/build-system/cmake-customization.md
+7-27Lines changed: 7 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,43 +11,25 @@ cannot be found herein.
11
11
## Build F Prime Utilities
12
12
13
13
Adding a utility executable that depends on F prime code is easy. Just perform a standard call to
14
-
`register_fprime_executable`. Care should be taken to set the variable `EXECUTABLE_NAME` before
15
-
making this call in order to set the utility's name. This executable will then be output as part
16
-
of the deployment's build. A separate tools deployment may be used to build only utilities.
14
+
`register_fprime_executable`. Care should be taken to set the executable name as the first argument to that
15
+
call. This executable will then be output as part of the deployment's build and may be built directly by name.
16
+
A separate tools deployment may be used to build only utilities.
17
17
18
18
See: [API](cmake-api.md)
19
19
20
20
## Custom Build-System Commands (Make Targets)
21
21
22
22
Custom build targets that need to be built against modules and global targets can be generated
23
-
using the hook pattern. This pattern involves creating a file with two functions - `add_global_target`and `add_module_target`. These functions are called to add targets to the top level and each module respectively.
23
+
using the hook pattern. This pattern involves creating a file with three functions - `<target>_add_global_target`, `<target>_add_module_target`, and `<target>_add_deployment_target`. These functions are called to add targets to the top level and each module respectively.
24
24
Then this file is registered with `register_fprime_target`.
25
25
26
-
In the two add functions, the user is expected to call the `add_custom_target` CMake command in order to compose the target itself. **Note:** the user may simply call this function directly to
27
-
add targets that don't have both per-module and global steps.
26
+
These functions can have any code the target needs, but typically uses `add_custom_target` to register the actual target.
28
27
29
28
See:
30
29
-[add_custom_target](https://cmake.org/cmake/help/latest/command/add_custom_target.html) to view
31
30
information on CMake targets.
32
31
-[API](cmake-api.md) for the syntax of the register call
33
32
-[Targets](cmake-targets.md) for information on the built-in targets
34
-
-[F´ standard targets](https://github.com/nasa/fprime/tree/devel/cmake/target) as an example of adding targets
Certain parts of F´ have different implementations that a project may choose from. The canonical example of this is a file system implementation. Projects may wish to use the stubbed implementation of the file system, the platform supplied standard implementation, or something project-specific like a flash chip or SD card.
4
4
5
5
These packages must be fully specified. Thus, every platform must specify a specific implementation for every package. These specific implementations may be overridden for a specific executable deployment or unit test.
6
6
7
7
## Requiring an Implementation
8
8
9
-
Modules that require an implementation should call the CMake API function `require_fprime_implementation()` to declare a requirement on a specific implementation. For example, the Os module `require_fprime_implementation(Os/Task)` declares that some implementation of `Os/Task` is required.
9
+
Modules that require an implementation should use the directive `REQUIRES_IMPLEMENTATIONS` in the `register_fprime_module` call.
10
10
11
11
> [!NOTE]
12
-
> Only `Os` requires an implementation of `Os/Task` as users of the `Os` package get the implementation through `Os` and should not specify it directly.
12
+
> `REQUIRES_IMPLEMENTATIONS` is only needed for modules that have a direct dependency on the implementation, not on their dependents.
13
13
14
14
## Choosing an Implementation
15
15
16
16
Platform developers *must* specify an implementation of every package used in the system. Failing to do so means that a given functionality is undefined and impossible to link. Stub implementations are provided in the case that a platform does not support a given package's functionality.
17
17
18
-
Choosing an implementation is done with a series of `choose_fprime_implementation` calls. One for each required implementation defined in the system. These calls are put in a platform CMake file.
18
+
Choosing an implementation is done with the `CHOOSES_IMPLEMENTATIONS` directive available to `register_fprime_config`. Platform developers should choose implementations as part of the platform definition.
Some executables, unit tests, and deployments may wish to use a different implementation than that specified by the platform. This can be done by a `choose_fprime_implementation` call in the deployment, executable, or unit test's module. For example, a unit test may wish to choose `Os_File_Stub` as an implementation of `Os_File` to disable platform file system support for the given unit test.
24
+
Executables, unit tests, and deployments may wish to use a different implementation than that specified by the platform. This can be done by using `CHOOSES_IMPLEMENTATIONS` directive call in the deployment, executable, or unit test's registration. For example, a unit test may wish to choose `Os_File_Stub` as an implementation of `Os_File` to disable platform file system support for the given unit test:
25
+
26
+
```
27
+
register_fprime_ut(
28
+
...
29
+
CHOOSES_IMPLEMENTATIONS
30
+
Os_File_Stub
31
+
)
32
+
```
23
33
24
34
> [!NOTE]
25
35
> A CMake target with the name of the chosen implementor *must* be defined somewhere in F´, an F´ library used by the project, or by the project itself.
26
36
27
37
## Defining an Implementation
28
38
29
-
To define an implementation, developers should declare an F´ module (using `register_fprime_module`) that implements the needed interface of the package. Then call `register_fprime_implementation`to specify this module is an implementation.
39
+
To define an implementation, developers should declare an F´ module (using `register_fprime_module`) that implements the needed interface of the package and supply the `IMPLEMENTS` directive to that call.
30
40
31
41
## Conclusion
32
42
33
-
F´ provides for various implementations for certain packages needed by the framework. See `cmake/API` and `Os` for API descriptions and Os implementations.
43
+
F´ provides for various implementations for certain packages needed by the framework.
Users can create platform-specific build files for the purposes of tailoring fprime
4
-
for given platform targets. Any CMake toolchain file should work, but it will require a platform file created here to add target-specific configuration using the name "${CMAKE_SYSTEM_NAME}.cmake".
4
+
for given platform targets. Any CMake toolchain file should work, but it will require a platform file created here to add target-specific configuration using the name "${FPRIME_PLATFORM}.cmake".
5
5
6
-
At minimum, this file can be blank, but more commonly there are included paths for "StandardTypes.hpp" to support.
7
-
Build flags and other includes can be added in to support different compile-time options. In addition, these files can define CMake option flags specific to the build.
6
+
Platforms should register a configuration module using `register_fprime_config` that sets the `AUTOCODER_INPUTS`, `HEADERS` and
7
+
`CHOOSES_IMPLEMENTATIONS` directives.
8
8
9
-
In order to create a new platform from scratch, the user can copy "platform.cmake.template" and fill it out to generate the new platform file. It will guide the user through the setup of this piece.
10
-
11
-
To understand the platform template: [Platform Template File](https://github.com/nasa/fprime/blob/docs/auto-documentation/docs/UsersGuide/api/cmake/platform/platform-template.md)
12
-
To use the template: [fprime Platform Template](https://github.com/nasa/fprime/blob/devel/cmake/platform/platform.cmake.template)
9
+
`AUTOCODER_INPUTS`: must include one .fpp file defining the platform's [platform types](../../reference/numerical-types.md#platform-configured-types)
10
+
`HEADERS`: lists the `PlatformTypes.h` header defining `PlatformPointerCastType`
11
+
`CHOOSES_IMPLEMENTATIONS`: lists all implementations chosen for the current platform. See: [CMake Implementations](./cmake-implementations.md).
Copy file name to clipboardExpand all lines: docs/user-manual/build-system/cmake-targets.md
-3Lines changed: 0 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,9 +8,6 @@ and have it available to the build system.
8
8
9
9
Targets are applied both at the global scope and per-module scope. Thus each target can provide a set of build targets (one per registered module) and a global build target. For example, a counting target might provide a `count` global target to count all files, and a `<MODULE>_count` to count the files of a given module.
10
10
11
-
For projects generating GNU make files, these targets can be executed with the `make <target>` and
12
-
`make <MODULE>_<target>` commands. i.e. `make Svc_CmdDispatcher_coverage`.
13
-
14
11
## Built-In Targets
15
12
16
13
The CMake system supplies several targets that are useful for all projects and thus are included
0 commit comments