This creates a new cmake macro to export a header with testing symbols.
If the symbol COMPILING_TESTS is defined, it defines a symbol like ${BASE_NAME}_TEST_EXPORT.
The build system does not implement this new macro.
This creates a new cmake macro to export a header with testing symbols.
If the symbol COMPILING_TESTS is defined, it defines a symbol like ${BASE_NAME}_TEST_EXPORT.
The build system does not implement this new macro.
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
Only had a quick look for now, guess that might be a usable solution.
One issue in any case: the macro needs some "calligra" namespacing, to protect against collisions.
Have you checked with cmake devs how they would propose to solve our problem? Ideally this would be solved for any projects, Calligra might not be the only one with symbols exported only in test-enabled builds.
Perhaps even our whole approach with symbols being inly exported in test-enabled builds is no longer best practise. I could not find any other KDE project so far which does that.
Going to ask on the kde-core-devel mailinglist for some input on this.
I think that's a good idea. I don't understand the rationale behind test-only symbols myself, I was just trying to maintain the existing system without breaking anything. Let me know what you want to do.
Here is what other KDE developers recommended so far to do when I asked about our problem:
http://thread.gmane.org/gmane.comp.kde.devel.core/87506
IMHO the wrapper export header might be the easiest solution for now, the one propose here:
http://article.gmane.org/gmane.comp.kde.devel.buildsystem/9558
I would like to avoid to fork the original "generate_export_header" macro as proposed in this diff (for the usual reasons against forks), and instead have us somehow wrap around the original macro and inject what we need. And hope one day upstream offers the needed feature directly.
So as immediate solution I would propose to use the wrapper export header approach:
generate_export_header(kofoo EXPORT_FILE_NAME kofoo_export_p.h)
#ifndef KOFOO_EXPORT_H #define KOFOO_EXPORT_H #include "kofoo_export_p.h" #ifdef COMPILING_TESTS # ifndef KOFOO_TESTS_EXPORT # define KOFOO_TESTS_EXPORT KOFOO_EXPORT # endif #else /* not compiling tests */ # define KOFOO_TESTS_EXPORT #endif #endif
That should allow to get rid of includes for kdemacros.h now.
In the meantime somebody could sketch a cmake macro that would somehow inject our needed export macro definitions into the generated file (like done with grantlee, see the linked email thread). Hm, perhaps we should even start right away with sketching such a macro. Anyone already in their editor and hacking away? ;)
What do you think?
I'm fine with it -- I did have to remove, hopefully temporarily, the TEST_EXPORT things to make everything work, but I'd like to see them back.
I can pop this into the Krita repo for future use, since the tests are becoming re-enabled.