1

I have a set of C++ packages resolved with the Swift Package Manager and another Package Manager (let's call it PMX).

PMX cannot resolve one of the dependencies, but I have to run CI on it. Is it possible to somehow check that the package is being compiled with the SPM system and include the appropriate imports and if it's not using SPM, then just not include those headers?

Example:

#if defined(_WIN32) || defined(_WIN64) || defined(__APPLE__)
#include <MyFile.h>
#endif

I'd like to have something similar to this:

#if defined(_WIN32) || defined(_WIN64) || (defined(__APPLE__) && defined(SWIFT_PACKAGE_MANAGER))
#include <MyFile.h>
#endif

Is something like this possible?

Richard Topchii
  • 7,075
  • 8
  • 48
  • 115

1 Answers1

1

Found a solution, this flag exists and it's called SWIFT_PACKAGE

This solution has worked perfectly for me:

#if defined(_WIN32) || defined(_WIN64) || (defined(__APPLE__) && defined(SWIFT_PACKAGE))
#include <MyFile.h>
#endif

Blog post mentioning the issue

Richard Topchii
  • 7,075
  • 8
  • 48
  • 115