Repository navigation
feat: Add C++ modules support - #1729
mikomikotaishi wants to merge 2 commits into
Conversation
[Medium impact] The PR adds an optional module path for CMake users. The installed package needs module export information before this is safe to merge. Findings
|
Coverage Report for CI Build 40347579800Coverage remained the same at 89.926%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
6964742 to
574a961
Compare
574a961 to
6278bc1
Compare
| install(TARGETS jsoncpp_module | ||
| ${MODULE_INSTALL_EXPORT} | ||
| LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
| ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
| RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
| FILE_SET CXX_MODULES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/jsoncpp/modules |
There was a problem hiding this comment.
This installs the module source, but the existing install(EXPORT jsoncpp ...) call does not write the information CMake needs to connect import jsoncpp to that source. A separate project can find and link jsoncpp::module but cannot compile code that imports it. Add CXX_MODULES_DIRECTORY to the package export when modules are enabled.
Knowledge Base Used: Consumer package integration
This PR adds support for C++20 modules, which can be enabled if the version of C++ is at least C++20 (and is opt-in, therefore not raising the minimum C++ version). It is enabled using
JSONCPP_WITH_MODULEand creates a modulejsoncpp.