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

Add C++20 module build target #1364

Closed
wants to merge 4 commits into from

Commits on Oct 22, 2024

  1. Add C++20 module build target

    Usage in client cmake:
    ```cmake
    set(FLECS_M0DULE ON CACHE BOOL "Build flecs module" FORCE)
    add_subdirectory(path/to/flecs)
    target_compile_features(flecs-module PUBLIC cxx_std_23)
    target_link_libraries(
      someProjectName
      PRIVATE
      flecs-module
    )
    ```
    
    In the code, it is then possible to use `import flecs;` to import all the flecs symbols.
    
    Still investigating why reflection seems to break, disabled in the module for now.
    
    Maintainance:
    - structs exposed by flecs must be tagged with `FLECS_API_STRUCT`
    - code within the c++ addon tagged with `FLECS_API` are exposed
    - globals must be tagged with `FLECS_API_GLOBAL`, which becomes `static` in headers, and export in the module.
    Gaspard-- committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    1ac8db8 View commit details
    Browse the repository at this point in the history
  2. Expose operator new in flecs c++20 module

    Not having it visible breaks compilation on msvc
    Gaspard-- committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    08e3629 View commit details
    Browse the repository at this point in the history
  3. run bake

    Gaspard-- committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    347bfeb View commit details
    Browse the repository at this point in the history
  4. Make enum reflection work, change define names and add comments

    - Improve define names
    - Split FLECS_GLOBAL_API in two because `export` comes before template delcarations and `static` afterwards
    - Fix enum reflection
    Gaspard-- committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    aaca38d View commit details
    Browse the repository at this point in the history