Update Build system authored by Guillaume Sanahuja's avatar Guillaume Sanahuja
[[PageOutline]]
= Build system
__NOTE__: For Flair version <= 0.2.2, see [wiki:compile_all_old this page].
**NOTE**: For Flair version <= 0.2.2, see [wiki:compile_all_old this page].
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.
* [source:flair-src/trunk/scripts/cmake_codelite_outofsource.sh cmake_codelite_outofsource.sh]: configure a project for !CodeLite for all available toolchains
* [source:flair-src/trunk/scripts/flair_compile_all.sh flair_compile_all.sh]: compile libs, tools and demos with all available toolchains. It calls ''cmake_codelite_outofsource.sh'' to configure projects.
* [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.
== 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 favourite 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 [https://github.com/2rm-robotics/robomap3-rt/blob/master/meta-poky/recipes-devtools/cmake/cmake/codelite.patch patched] 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 [source:flair-src/trunk/cmake-modules flair-src]. 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:
* [source:flair-src/trunk/cmake-modules/GlobalCmakeFlair.cmake 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
* [source:flair-src/trunk/cmake-modules/FlairUseFile.cmake 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 [wiki:cmake_modules here].
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 svn 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:
* ''build_armv7a_neon'' for armv7a-neon architecture (ardrone2, bebop, hds x8)
* ''build_armv5e'' for armv5e architecture (mambo)
* ''build_cortexa7thf_neon_vfpv4'' for cortexa7thf-neon-vfpv4 architecture (raspberry pi)
* ''build_core2_64'' for core2_64 architecture (PC)
*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_armv5e for armv5e** architecture (mambo)
* **build_cortexa7thf_neon_vfpv4** for cortexa7thf-neon-vfpv4 architecture (raspberry pi)
* **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 Fl-AIR stuffs, you can execute the dedicated script:
{{{
$ $FLAIR_ROOT/flair-src/scripts/flair_compile_all.sh
}}}
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.
`$ $FLAIR_ROOT/flair-src/scripts/flair_compile_all.sh`
The script detects installed toolchains and compile everything for each supported architecture. It will create a directory ''flair-install'' in ''$FLAIR_ROOT''.
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*.
Results are the following:
* flair libs headers installed in ''$FLAIR_ROOT/flair-install/include''
* 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 demos binaries installed in ''$FLAIR_ROOT/flair-install/bin/demos''
* flair libs headers installed in *$FLAIR_ROOT/flair-install/include*
* 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 demos binaries installed in *$FLAIR_ROOT/flair-install/bin/demos*
For Heudiasyc users, additional stuffs are also installed:
* flair hds libs headers installed in ''$FLAIR_ROOT/flair-install/include''
* 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 libs headers installed in *$FLAIR_ROOT/flair-install/include*
* flair hds libs binaries installed in *$FLAIR_ROOT/flair-install/lib*
* 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 [wiki:compile_all#Compileyourownproject 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:
{{{
$ cd $FLAIR_ROOT/flair-build/build/project_path
$ make install
}}}
`$ cd $FLAIR_ROOT/flair-build/build/project_path`
`$ make install`
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
$ cd $FLAIR_ROOT/flair-build/build_armv7a_neon/project_path
'$ cd $FLAIR_ROOT/flair-build/build_armv7a_neon/project_path'
or
$ cd $FLAIR_ROOT/flair-build/build_cortexa7thf_neon_vfpv4/project_path
}}}
''project_path'' depends on what you are compiling:
'$ cd $FLAIR_ROOT/flair-build/build_cortexa7thf_neon_vfpv4/project_path'
* ''!FlairLibs/<lib>'': a flair library (for example ''!FlairLibs/FlairCore'')
* ''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
*project_path* depends on what you are compiling:
For Heudiasyc users ''project_path'' can also be the following:
* **FlairLibs/<lib>**: a flair library (for example *FlairLibs/FlairCore*)
* **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
* ''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
For Heudiasyc users *project_path* can also be the following:
== Compile your own project ==
* **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
__NOTE__: this is also works for projects provided in ''flair-src'' and ''flair-hds'' repositories.
# Compile your own project
You can generate your own project where you want, and compile it. Yet, you need to have [wiki:compile_all#CompileFlairlibrariestoolsanddemosalltogether 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!
**NOTE**: this also works for projects provided in *flair-src* and *flair-hds* repositories.
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>''
{{{
$ mkdir -p $FLAIR_ROOT/flair-build/<mywork>/<myproject>
$ cd $FLAIR_ROOT/flair-build/<mywork>/<myproject>
$ $FLAIR_ROOT/flair-src/scripts/cmake_codelite_outofsource.sh $FLAIR_ROOT/<path_to_my_project>
$ cd build
$ make install
}}}
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>*
'$ mkdir -p $FLAIR_ROOT/flair-build/<mywork>/<myproject>'
'$ cd $FLAIR_ROOT/flair-build/<mywork>/<myproject>'
'$ $FLAIR_ROOT/flair-src/scripts/cmake_codelite_outofsource.sh $FLAIR_ROOT/<path_to_my_project>'
'$ cd build'
'$ make install'
It will compile for x86_64 architecture. To compile for a different architecture, go to the corresponding directory, for example:
{{{
$ cd build_armv5te
'$ cd build_armv5te'
or
$ cd build_armv7a_neon
'$ cd build_armv7a_neon'
or
$ cd build_cortexa7thf_neon_vfpv4
}}}
'$ cd build_cortexa7thf_neon_vfpv4'
== Compilation with debug (optional) ==
......
......