**NOTE**: For Flair version <= 0.2.2, see [this page](old/build-system).
**NOTE**: For Flair version <= 0.2.2, see [this page](old/build-system).
Only Flair sources are provided. You need to compile everything by yourself to get development files, demos and tools.
Only Flair sources are provided. You need to compile everything by yourself to get development files, demos and tools.
# Helper scripts
# Helper scripts
Some scripts are provided to help configuration and compilation of projects. Using it you can compile everything easily. They are included in flair-src repository.
Some scripts are provided to help configuration and compilation of projects. Using it you can compile everything easily. They are included in flair-src repository.
*[cmake_codelite_outofsource.sh](https://gitlab.utc.fr/uav-hds/flair/flair-src/-/blob/main/scripts/cmake_codelite_outofsource.sh): configure a project for CodeLite for all available toolchains
*[cmake_codelite_outofsource.sh](https://gitlab.utc.fr/uav-hds/flair/flair-src/-/blob/main/scripts/cmake_codelite_outofsource.sh): configure a project for CodeLite for all available toolchains
*[flair_compile_all.sh](https://gitlab.utc.fr/uav-hds/flair/flair-src/-/blob/main/scripts/flair_compile_all.sh): compile libs, tools and demos with all available toolchains. It calls *cmake_codelite_outofsource.sh* to configure projects.
*[flair_compile_all.sh](https://gitlab.utc.fr/uav-hds/flair/flair-src/-/blob/main/scripts/flair_compile_all.sh): compile libs, tools and demos with all available toolchains. It calls *cmake_codelite_outofsource.sh* to configure projects.
# CMake & CodeLite
# CMake & CodeLite
Flair uses CMake as project descriptor. One recommended IDE is CodeLite. The helper scripts will produce projects for CodeLite from *CMakeLists.txt* but you can adapt it to your favorite IDE.
Flair uses CMake as project descriptor. One recommended IDE is CodeLite. The helper scripts will produce projects for CodeLite from *CMakeLists.txt* but you can adapt it to your favorite IDE.
Note that CodeLite CMake generator has been [patched](https://github.com/2rm-robotics/robomap3-rt/blob/master/meta-poky/recipes-devtools/cmake/cmake/codelite.patch) in robomap3 to better fit flair needs.
Note that CodeLite CMake generator has been [patched](https://github.com/2rm-robotics/robomap3-rt/blob/master/meta-poky/recipes-devtools/cmake/cmake/codelite.patch) in robomap3 to better fit flair needs.
# CMake tricks
# CMake tricks
All CMakeLists in flair use custom modules located in [flair-src](https://gitlab.utc.fr/uav-hds/flair/flair-src/-/tree/main/cmake-modules). The 2 principal ones are:
All CMakeLists in flair use custom modules located in [flair-src](https://gitlab.utc.fr/uav-hds/flair/flair-src/-/tree/main/cmake-modules). The 2 principal ones are:
*[GlobalCmakeFlair.cmake](https://gitlab.utc.fr/uav-hds/flair/flair-src/-/tree/main/cmake-modules/GlobalCmakeFlair.cmake): reimplements some cmake built in functions
*[GlobalCmakeFlair.cmake](https://gitlab.utc.fr/uav-hds/flair/flair-src/-/tree/main/cmake-modules/GlobalCmakeFlair.cmake): reimplements some cmake built in functions
*[FlairUseFile.cmake](https://gitlab.utc.fr/uav-hds/flair/flair-src/-/tree/main/cmake-modules/FlairUseFile.cmake): used by demos/tools, it helps adding include dirs and libraries for programs using flair
*[FlairUseFile.cmake](https://gitlab.utc.fr/uav-hds/flair/flair-src/-/tree/main/cmake-modules/FlairUseFile.cmake): used by demos/tools, it helps adding include dirs and libraries for programs using flair
A better explanation on how to use these modules can be found [here](cmake_modules).
A better explanation on how to use these modules can be found [here](cmake_modules).
Each installed toolchain have a *toolchain.cmake* file (for example */opt/robomap3/2.1.3/armv5te/toolchain.cmake*) which defines everything needed by CMake to compile for a specific architecture.
Each installed toolchain have a _toolchain.cmake_ file (for example _/opt/robomap3/2.1.3/armv5te/toolchain.cmake_) which defines everything needed by CMake to compile for a specific architecture.
# Out of source build
# Out of source build
The recommended usage is to build everything out of source, in order to keep your git repositories clean. Helper script (*flair_compile_all.sh*) will build everything in *$FLAIR_ROOT/flair-build* directory.
The recommended usage is to build everything out of source, in order to keep your git repositories clean. Helper script (_flair_compile_all.sh_) will build everything in _$FLAIR_ROOT/flair-build_ directory.
# One directory by architecture
# One directory by architecture
*cmake_codelite_outofsource.sh* creates a folder for each supported architecture (ie by installed toolchain) in *flair-build* directory. For example:
*cmake_codelite_outofsource.sh* creates a folder for each supported architecture (ie by installed toolchain) in _flair-build_ directory. For example:
***build_armv7a_neon** for armv7a-neon architecture (ardrone2, bebop, hds x8)
***build_armv7a_neon** for armv7a-neon architecture (ardrone2, bebop, hds x8)
***build_armv5e for armv5e** architecture (mambo)
***build_armv5e for armv5e** architecture (mambo)
***build_cortexa7thf_neon_vfpv4** for cortexa7thf-neon-vfpv4 architecture (raspberry pi)
***build_cortexa7thf_neon_vfpv4** for cortexa7thf-neon-vfpv4 architecture (raspberry pi)
***build_core2_64** for core2_64 architecture (PC)
***build_core2_64** for core2_64 architecture (PC)
Note that there is also a symlink from *build* to *build_core2_64*.
Note that there is also a symlink from _build_ to _build_core2_64_.
# Compile flair libraries, tools and demos all together
# Compile flair libraries, tools and demos all together
To compile all flair stuffs, you can execute the dedicated script:
To compile all flair stuffs, you can execute the dedicated script:
If it is the first time you execute this script, you must answer yes to the question *Compile all from scratch*. This will create every projects using cmake.
If it is the first time you execute this script, you must answer yes to the question *Compile all from scratch*. This will create every projects using cmake.
The script detects installed toolchains and compile everything for each supported architecture. It will create a directory *flair-install* in *$FLAIR_ROOT*.
The script detects installed toolchains and compile everything for each supported architecture. It will create a directory *flair-install* in *$FLAIR_ROOT*.
Results are the following:
Results are the following:
* flair libs headers installed in *$FLAIR_ROOT/flair-install/include*
* flair libs headers installed in _$FLAIR_ROOT/flair-install/include_
* flair libs binaries installed in *$FLAIR_ROOT/flair-install/lib*
* flair libs binaries installed in _$FLAIR_ROOT/flair-install/lib_
* flair tools binaries installed in *$FLAIR_ROOT/flair-install/bin/tools/core2-64* (but launching scripts are in *$FLAIR_ROOT/flair-bin/tools/scripts*)
* flair tools binaries installed in _$FLAIR_ROOT/flair-install/bin/tools/core2-64_ (but launching scripts are in $FLAIR_ROOT/flair-bin/tools/scripts)
* flair demos binaries installed in *$FLAIR_ROOT/flair-install/bin/demos*
* flair demos binaries installed in _$FLAIR_ROOT/flair-install/bin/demos_
For Heudiasyc users, additional stuffs are also installed:
For Heudiasyc users, additional stuffs are also installed:
* flair hds libs headers installed in *$FLAIR_ROOT/flair-install/include*
* flair hds libs headers installed in _$FLAIR_ROOT/flair-install/include_
* flair hds libs binaries installed in *$FLAIR_ROOT/flair-install/lib*
* flair hds libs binaries installed in _$FLAIR_ROOT/flair-install/lib_
* flair hds demos binaries installed in *$FLAIR_ROOT/flair-install/bin/demos*
* flair hds demos binaries installed in _$FLAIR_ROOT/flair-install/bin/demos_
# Recompile a particular project
# Recompile a particular project
**NOTE**: this is only for projects provided in *flair-src* and *flair-hds* repositories. For your own project go to next section.
**NOTE**: this is only for projects provided in _flair-src_ and _flair-hds_ repositories. For your own project go to next section.
If you have already done the previous step (compile everything) and you want to just recompile and install a particular project (lib, demo or tool), do the following:
If you have already done the previous step (compile everything) and you want to just recompile and install a particular project (lib, demo or tool), do the following:
`$ cd $FLAIR_ROOT/flair-build/build/project_path`
`$ cd $FLAIR_ROOT/flair-build/build/project_path`
`$ make install`
`$ make install`
It will compile for x86_64 architecture. To compile for a different architecture, go to the corresponding directory, for example:
It will compile for x86_64 architecture. To compile for a different architecture, go to the corresponding directory, for example:
`$ cd $FLAIR_ROOT/flair-build/build_armv5te/project_path`
`$ cd $FLAIR_ROOT/flair-build/build_armv5te/project_path`
or
or
`$ cd $FLAIR_ROOT/flair-build/build_armv7a_neon/project_path`
`$ cd $FLAIR_ROOT/flair-build/build_armv7a_neon/project_path`
or
or
`$ cd $FLAIR_ROOT/flair-build/build_cortexa7thf_neon_vfpv4/project_path`
`$ cd $FLAIR_ROOT/flair-build/build_cortexa7thf_neon_vfpv4/project_path`
*project_path* depends on what you are compiling:
*project_path* depends on what you are compiling:
***FlairLibs/<lib>**: a flair library (for example *FlairLibs/FlairCore*)
***FlairLibs/<lib>**: a flair library (for example *FlairLibs/FlairCore*)
***tools/<tool>**: a flair tool (for example *tools/FlairGCS*)
***tools/<tool>**: a flair tool (for example *tools/FlairGCS*)
***demos/<demo>**: a flair demo (for example *demos/CircleFollower*). Not that you can also have subfolders like *demos/CircleFollower/simulator* or *demos/CircleFollower/uav* if you want to compile just simulator or uav project
***demos/<demo>**: a flair demo (for example *demos/CircleFollower*). Not that you can also have subfolders like *demos/CircleFollower/simulator* or *demos/CircleFollower/uav* if you want to compile just simulator or uav project
For Heudiasyc users *project_path* can also be the following:
For Heudiasyc users *project_path* can also be the following:
***flair-hds/FlairHdsLibs/<lib>**: a flair hds library (for example *flair-hds/FlairHdsLibs/FlairArdrone2*)
***flair-hds/FlairHdsLibs/<lib>**: a flair hds library (for example *flair-hds/FlairHdsLibs/FlairArdrone2*)
***flair-hds/demos/<demo>**: a flair hds demo (for example *flair-hds/demos/ApriltagFollower*). Not that you can also have subfolders like *flair-hds/demos/ApriltagFollower/simulator* or *flair-hds/demos/ApriltagFollower/uav* if you want to compile just simulator or uav project
***flair-hds/demos/<demo>**: a flair hds demo (for example *flair-hds/demos/ApriltagFollower*). Not that you can also have subfolders like *flair-hds/demos/ApriltagFollower/simulator* or *flair-hds/demos/ApriltagFollower/uav* if you want to compile just simulator or uav project
# Compile your own project
# Compile your own project
**NOTE**: this also works for projects provided in *flair-src* and *flair-hds* repositories.
**NOTE**: this also works for projects provided in *flair-src* and *flair-hds* repositories.
You can generate your own project where you want, and compile it. Yet, you need to have compiled and installed Flair libs before, to have all needed development files. But it is not necessary to recompile libs each time you want to compile your project!
You can generate your own project where you want, and compile it. Yet, you need to have compiled and installed Flair libs before, to have all needed development files. But it is not necessary to recompile libs each time you want to compile your project!
The following assumes that your project is in *$FLAIR_ROOT/<path_to_my_project>* and you want to built it in *$FLAIR_ROOT/flair-build/<mywork>/<myproject>*
The following assumes that your project is in `$FLAIR_ROOT/<path_to_my_project>` and you want to built it in `$FLAIR_ROOT/flair-build/<mywork>/<myproject>`
Then when your program crashes, it will generate a *core* file. Use gdb with your binary as the first parameter (again, compiled in debug mode) and the core file as the second parameter (use your cross compiled gdb in case of cross development, arm-poky...-gdb for instance to debug an arm code from your PC).
Then when your program crashes, it will generate a *core* file. Use gdb with your binary as the first parameter (again, compiled in debug mode) and the core file as the second parameter (use your cross compiled gdb in case of cross development, arm-poky...-gdb for instance to debug an arm code from your PC).
It should load your program symbols. Then the *bt* command will show the backtrace, which is the sequence of function calls that resulted in the crash, allowing you to know exactly where is the problem.
It should load your program symbols. Then the *bt* command will show the backtrace, which is the sequence of function calls that resulted in the crash, allowing you to know exactly where is the problem.
## Full framework
## Full framework
If you want to debug the framework itself, you may find beneficial to compile the full framework in debug mode you need to edit the file
If you want to debug the framework itself, you may find beneficial to compile the full framework in debug mode you need to edit the file
`$ /opt/robomap3/<version>/<arch>/toochain.cmake`
`$ /opt/robomap3/<version>/<arch>/toochain.cmake`
and add "-g -O0" to the CMAKE_CXX_FLAGS variable. As of this writing, and for an x86 architecture, the file to edit is */opt/robomap3/2.1.3/core2-64/toolchain.cmake*.
and add "-g -O0" to the CMAKE_CXX_FLAGS variable. As of this writing, and for an x86 architecture, the file to edit is */opt/robomap3/2.1.3/core2-64/toolchain.cmake*.
Then you shall rebuild the whole framework with a call to flair_compile_all.
Then you shall rebuild the whole framework with a call to flair_compile_all.
## Flair based app
## Flair based app
If you want to debug your flair based application code, but don't need to debug the framework itself, you need to edit the file *<app>/build/CMakeFiles/<app>.dir/flags.cmake* and add the command add_definitions("-g -O0").
If you want to debug your flair based application code, but don't need to debug the framework itself, you need to edit the file *<app>/build/CMakeFiles/<app>.dir/flags.cmake* and add the command add_definitions("-g -O0").