Request for Changes-92: Build remote modules as standalone cmake projects
- Author: Julien Michel (CNES)
- Additional Contributors Manuel Grizonnet (CNES), Emmanuelle Sarrazin (CNES)
- Submitted on 30.05.2017
- Proposed target release : 6.2
- Adopted (+3)
- Merged : https://git.orfeo-toolbox.org/otb.git/commit/94e0509487b892fbd4167b270bbb01d1b5798ddc
This RFC proposes a change of the OTB CMake (public and installed) API so as to allow for the build of remote modules as standalone CMake projects outside of OTB build tree, even with an installed OTB. Note that the previous behavior is preserved (more on this later).
The two important changes introduced by this RFC is that :
- OTB_DIR can now be an installed OTB
- A new CMake option is automatically added : OTB_BUILD_MODULE_AS_STANDALONE, OFF by default.
If OTB_BUILD_MODULE_AS_STANDALONE is OFF, the previous behavior prevails.
If it is ON, the remote module will be built as a standalone CMake project, which means :
- All files in include folder will be installed in CMAKE_INSTALL_PREFIX/include
- All targets in lib/ will be built and installed in CMAKE_INSTALL_PREFIX/lib
- All applications in aps will be built and installed in CMAKE_INSTALL_PREFIX/lib/otb/applications
- If BUILD_TESTING is set to ON, all tests will be built and available for testing
Building remote modules without rebuilding the whole OTB is tricky :
- It requires the OTB build tree
- It installs files in the OTB install directory
On servers with shared installation of Orfeo ToolBox, it is thus very difficult to test remote modules without rebuilding your own Orfeo ToolBox from scratch. This RFC provides a new way to build remote modules completely outside OTB, and solves this issue.
This is the minimal set of macros required to build a module as a standalone project.
The main entry point is the redefinition of otb_module_impl(), which reads the otb-module.cmake files and builds a standard CMake project. The remaining macros are there so as to make this work.
This file handles the previous behaviour. It contains the switch with option OTB_BUILD_MODULE_AS_STANDALONE which conditionally includes OTBStandaloneModuleMacros.cmake.
OTBStandaloneModuleMacros.cmake and OTBModuleExternal.cmake are now installed in OTB install directory.
New behavior is documented in Software Guide and Remote Module template.
Note that :
- CMAKE_INSTALL_PREFIX can be set wherever you like (no need to set the same folder as OTB installation)
- If the remote module declares dependencies to other OTB modules that are not available in the OTB installation, the CMake configuration will abort with a nice "Missing module XXX" message
- For that reason, the standalone mode can not and will not track dependencies to other remote modules (if they are not installed within OTB). It will report a missing module message.