Request for Changes-59: Build support for msvc 2015 with OTB xdk
- Author: Rashad Kanavath
- Submitted on 07.09.2016
- Proposed target release : 5.8
- Adopted : +3 from Victor, Guillaume, Rémi
- Merged : a3a002778bc337dd674b15f2d52f65304e48ec45
This RFC add support for MSVC 2015 with shared library builds. For long time, shared build on otb is not possible due to ITK having no support for this type on windows msvc. It requires cmake version 3.3 or higher which comes with a feature to make shared library (dlls ) without having to add __declspec macro in every classes.
Initially for support for shared build with mingw, we were using ITK_ABI_EXPORT to export a classes and method when making dll. As a part of modularized build in OTB, cmake will generates <MODULE_NAME>Export.h file for every module which is explicitly marked ENABLE_SHARED. this export header defined <MODULE_NAME>_EXPORT macro that is set to __declspec(export) or __declspec(import) depending on if we are using the dll or creating dll. Refer to MSDN docs to __declspec and dllimport
Most of the fix for dll export macro which can be seen in the PR. https://github.com/orfeotoolbox/OTB/pull/9/files
New OTB classes created must use <MODULE_NAME>_EXPORT macro and not use ITK_EXPORT or ITK_ABI_EXPORT
A new target called OTB_DEPENDS was added. This will build all otb dependencies based on cmake configuration.
Classes and files
SuperBuild has to be patched to add geos-3.5.0 (cmake build was not working on msvc), ossim build has been patched to work with msvc 2015 FindOpenCV.cmake was added to easily find opencv on windows and other platforms https://github.com/orfeotoolbox/OTB/pull/9/files#diff-501f02a14f0638913e1a2b3e2ee62a56R1
It needs some fix for failing test on OTBWavelet module: https://github.com/orfeotoolbox/OTB/pull/9/files#diff-2db190fa8f957bd050368d846b3758fdR40
otbImageFileWriter for extracting bbox value was wrong. I had fixed this with lexical_cast wrapper from otbStringUtils: https://github.com/orfeotoolbox/OTB/pull/9/files#diff-5c1755d96f0053d71c1d8837a1177e82R497
OTB_USE_LIBKML is off due issues with shared build. (need to use a different upstream)