Make management of decl export/import easier on Windows
|As a||CEP developer]|
|I would like to||have a hassle free development time on windows|
|So that||I can spend more time prototyping|
This is a merge between
- a feature request submitted on the old bugzilla by Céline on 2016-01-18, and titled "The wizard should create a API.h file when an action depends on a local CEP component"
- a story suggested on the old icescrum by myself on 2013-01-15, and titled "simplification of declspec export etc..."
- a story suggested on the old icescrum by Céline on 2014-06-04, and titled "Inclure les decl_export dans le Wizard"
cepgenerator and wizard
On windows you need to declare that you "export" the symbols when you are compiling a library and "import" the symbol when you are linking to the library. That means that you have to modify your code for these two phases. This is generally done by using a macro (defined as export and import when MSVC is used or as nothing for other compiler).
This feature requests ask for automatic management of this not obvious behaviour.
This can be done by:
- use a specific macro that (with the combination of
Q_DECL_IMPORTor the basic
- automatically include all symbols thanks to CMake WINDOWS_EXPORT_ALL_SYMBOLS property
- smoothly integrated this in the wizard/cepgenerator (see below)
The wizard should create a API.h file when an action depends on a local CEP component
Create a new CEP with the wizard, containing a new Component (e.g. Albert's Component). Then create an action extension (e.g. Albert's Action) which depends on Albert's Component. The wizard adds a
NEEDS_COMPONENT_EXTENSION albertscomponentsin the action extension
CMakeLists.txt, which is really great as the user do not have to look at the CMakeLists.txt anymore.
However, if the user is on Windows (which do not really know how to make real dynamic libraries), he/she will need a file name AlbertsComponentAPI.h in his/her Albert's Component extension, a
DEFINES COMPILE_ALBERTSCOMPONENTS_APIin Component's extension CMakeList and a
class ALBERTSCOMPONENTAPI AlbertsComponentdeclaration in its .h file...
- old doc: https://gitlab.kitware.com/cmake/community/wikis/doc/tutorials/BuildingWinDLL
- old doc: https://cmake.org/cmake/help/v2.8.10/cmake.html#module:GenerateExportHeader