Define the cmake macro generate_test_export_header()
ClosedPublic

Authored by abrahams on Aug 18 2015, 1:47 AM.

Details

Summary

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.

Diff Detail

Repository
R37 Krita
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
abrahams updated this revision to Diff 564.Aug 18 2015, 1:47 AM
abrahams retitled this revision from to Define the cmake macro generate_test_export_header().
abrahams updated this object.
abrahams edited the test plan for this revision. (Show Details)
abrahams added reviewers: kossebau, staniek, rempt.
kossebau edited edge metadata.Aug 31 2015, 12:00 PM

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.

staniek edited edge metadata.Aug 31 2015, 12:04 PM
In D249#5320, @kossebau wrote:

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.

Yes, both the macro and the filename.

abrahams added a comment.EditedAug 31 2015, 8:11 PM
In D249#5320, @kossebau wrote:

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:

  1. use "generate_export_header" to generate a header with the normal macros:
generate_export_header(kofoo EXPORT_FILE_NAME kofoo_export_p.h)
  1. have a wrapper header in the sources:
#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?

rempt accepted this revision.Sep 16 2015, 6:45 AM
rempt edited edge metadata.

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.

This revision is now accepted and ready to land.Sep 16 2015, 6:45 AM
abrahams updated this revision to Diff 2284.Feb 11 2016, 7:48 PM
abrahams edited edge metadata.

Rebase onto Krita repo

I can pop this into the Krita repo for future use, since the tests are becoming re-enabled.

rempt added a comment.Feb 12 2016, 4:43 PM

please go ahead.

This revision was automatically updated to reflect the committed changes.