Skip to content

Commit

Permalink
Add C++20 module build target
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Gaspard-- committed Sep 19, 2024
1 parent 2616e66 commit 3191967
Show file tree
Hide file tree
Showing 32 changed files with 734 additions and 594 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ option(FLECS_STATIC "Build static flecs lib" ON)
option(FLECS_SHARED "Build shared flecs lib" ON)
option(FLECS_PIC "Compile static flecs lib with position independent code (PIC)" ON)
option(FLECS_TESTS "Build flecs tests" OFF)
option(FLECS_M0DULE "Build flecs C++20 module" OFF)

include(cmake/target_default_compile_warnings.cmake)
include(cmake/target_default_compile_options.cmake)
Expand Down Expand Up @@ -75,6 +76,10 @@ if(FLECS_TESTS)
add_subdirectory(test)
endif()

if(FLECS_M0DULE)
add_subdirectory(module)
endif()

message(STATUS "Targets: ${FLECS_TARGETS}")

# define the install steps
Expand Down
Loading

0 comments on commit 3191967

Please sign in to comment.