Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(swift package as dependency) xcode build with modules enabled breaks CGLM_FORCE_* #424

Open
John-Colvin opened this issue Jul 15, 2024 · 3 comments

Comments

@John-Colvin
Copy link

John-Colvin commented Jul 15, 2024

E.g. if my xcode project - using modules, which is the default now - I have a C file containing the following:

#define CGLM_FORCE_DEPTH_ZERO_TO_ONE 1
#define CGLM_FORCE_LEFT_HANDED 1

#include <cglm/cglm.h>
#include <cglm/cam.h>

and cglm is depended on as a swift package, then those CGLM_FORCE_* macros will do nothing at all.

From the clang docs on modules:

Headers that vend multiple APIs at different times
Some systems have headers that contain a number of different kinds of API definitions, only some of which are made available with a given include. For example, the header may vend size_t only when the macro __need_size_t is defined before that header is included, and also vend wchar_t only when the macro __need_wchar_t is defined. Such headers are often included many times in a single translation unit, and will have no include guards. There is no sane way to map this header to a submodule. One can either eliminate the header (e.g., by splitting it into separate headers, one per actual API) or simply exclude it in the module map.

Given that & how cglm works, I think the simplest thing to do is to delete include/module.modulemap (works for me). But I am no expert on either Xcode, clang modules or cglm internals, so I can't say for sure.

@recp
Copy link
Owner

recp commented Jul 18, 2024

Hi @John-Colvin,

Thanks for the feedback,

I was added:

❗️ IMPORTANT ❗️

It’s a good idea to set up your config macros in build settings like CMake, Xcode, or Visual Studio. This is especially important if you’re using features like Modules in Xcode, where adding macros directly before the cglm headers might not work.

to https://cglm.readthedocs.io/en/latest/opt.html docs and some other place[s] too maybe.

May I ask if it works to add CGLM_FORCE_DEPTH_ZERO_TO_ONE and CGLM_FORCE_LEFT_HANDED in Xcode’s build settings instead of adding them before the headers?

I'll check what can be done asap. if removing module.modulemap we can.

@John-Colvin
Copy link
Author

@recp thanks, adding the flags to the build settings did indeed work.

@recp
Copy link
Owner

recp commented Aug 1, 2024

@John-Colvin many thanks, I'll also check if we really need to the module.modulemap or what can be done, I'm really busy these days, sorry for no estimated time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants