-
Notifications
You must be signed in to change notification settings - Fork 44
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
Support C++20 module with optional standard library module. #61
Conversation
…LTF_USE_STD_MODULE macro).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is FASTGLTF_USE_STD_MODULE
expected to be defined? How does this work together with CMake? Can we add anything to the CI to test for these changes?
Also, this doesn't include the changes from #49.
Though thank you for this change, appreciate it!
I created the test repository with latest Clang CI (runs on ubuntu and macOS). For now, it has dependency of my another repository for using |
Would it perhaps make sense to have this auto-defined when using a supported compiler? Or could that break things?
I guess I'll just add CI runners for the modules later when that releases. Right now, I don't think I want to convoluted the CMake codebase for that. |
The macro can be replaced with My suggestion is: Use |
This reverts commit 1bc136f.
I've tested my CMake changes locally and they seem to work just fine on Clang 18 and VS 17.9. It also compiles on GCC 14.1 but it takes forever to link. I've just added a warning for now about the |
This is to reduce the amount of boilerplate code in the module file
Well, CI builds failed in my case. stripe2933/fastgltf-module-test@69a28f5 My
In my previous approach, I did not declare Another reason I worried about is: will package managers like vcpkg maintain module target? For same case, the library Of course there is no general rule for it. As module user population grow up, many CMake based project will expose the module target, so the choice is up to you. Anyway, could you share me your local module build project? I'm curious how |
I just used your
|
Just tested locally with a CMake 3.30 nightly release, and using cmake_minimum_required(VERSION 3.29.20240513)
# Needs to happen before the project declaration, or C++ language support.
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "0e5b6991-d74f-4b3d-a41c-cf096e0b2508")
project(fastgltf-module-test LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_MODULE_STD 1) # Required for 'import std'
option(FASTGLTF_USE_STD_MODULE "" ON)
add_subdirectory("E:/git/spnda/fastgltf/" fastgltf)
add_executable(fastgltf-module-test main.cpp)
target_link_libraries(fastgltf-module-test PRIVATE fastgltf::module) |
Ok, my library is just a stopgap implementation for CMake 3.30's feature, so it may result incorrect behavior. I'll investigate it. It looks like Clang does not accept (+) Moving |
@stripe2933 Thank you very much for proposing this and the initial changes, and the last fixes. I've merged this now. |
This PR adds C++20 module feature with optional standard library module (can be enabled via
FASTGLTF_USE_STD_MODULE
macro).fastgltf.cppm
module file exports symbols. Note that helper classes/functions frombase64.hpp
,util.hpp
are not exported and therefore invisible to the end user.FASTGLTF_USE_STD_MODULE
macro defined, and use std module instead. This can dramatically reduce the compile time.