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.
The current version includes everything in the `flecs` namespace, but avoids including anything in the `_` namespace.

Maintainance:
- namespaces that contain symbols to exported must be tagged with FLECS_API_NAMESPACE
- namespaces that should be excluded should be seperate in order to avoid exporting symbols
- static globals must be tagged with `FLECS_STATIC_IN_HEADER`, which becomes `static` in headers, but not in the module
- some rare symbols outside namesapces are necessary for compilation, such as operator new / delete, and must be tagged FLECS_API_DEPENDENCY
  • Loading branch information
Gaspard-- committed Oct 22, 2024
1 parent de8b378 commit 9fe2bf1
Show file tree
Hide file tree
Showing 84 changed files with 810 additions and 482 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 9fe2bf1

Please sign in to comment.