Repository navigation
feat: Add C++ modules support #1729
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| cmake_minimum_required(VERSION 3.28) | ||
|
|
||
| add_library(jsoncpp_module) | ||
|
|
||
| target_sources(jsoncpp_module | ||
| PUBLIC | ||
| FILE_SET CXX_MODULES FILES | ||
| jsoncpp.cppm | ||
| ) | ||
|
|
||
| target_compile_features(jsoncpp_module PUBLIC cxx_std_20) | ||
|
|
||
| if(BUILD_SHARED_LIBS) | ||
| target_link_libraries(jsoncpp_module PUBLIC jsoncpp_lib) | ||
| elseif(BUILD_STATIC_LIBS) | ||
| target_link_libraries(jsoncpp_module PUBLIC jsoncpp_static) | ||
| endif() | ||
|
|
||
| target_include_directories(jsoncpp_module PUBLIC | ||
| $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> | ||
| $<INSTALL_INTERFACE:include> | ||
| ) | ||
|
|
||
| add_library(jsoncpp::module ALIAS jsoncpp_module) | ||
|
|
||
| # Installation | ||
| if(JSONCPP_WITH_CMAKE_PACKAGE) | ||
| set(MODULE_INSTALL_EXPORT EXPORT jsoncpp) | ||
| else() | ||
| set(MODULE_INSTALL_EXPORT) | ||
| endif() | ||
|
|
||
| if(JSONCPP_WITH_INSTALL) | ||
| 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 | ||
|
Comment on lines
+34
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This installs the module source, but the existing Knowledge Base Used: Consumer package integration |
||
| ) | ||
| endif() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| // Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors | ||
| // Distributed under MIT license, or public domain if desired and | ||
| // recognized in your jurisdiction. | ||
| // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE | ||
|
|
||
| module; | ||
|
|
||
| #include <json/json.h> | ||
|
|
||
| export module jsoncpp; | ||
|
|
||
| export namespace Json { | ||
| // writer.h | ||
| using Json::StreamWriter; | ||
| using Json::StreamWriterBuilder; | ||
| using Json::Writer; | ||
| using Json::FastWriter; | ||
| using Json::StyledWriter; | ||
| using Json::StyledStreamWriter; | ||
| using Json::valueToString; | ||
| using Json::valueToQuotedString; | ||
| using Json::operator<<; | ||
|
|
||
| // reader.h | ||
| using Json::Reader; | ||
| using Json::CharReader; | ||
| using Json::CharReaderBuilder; | ||
| using Json::parseFromStream; | ||
| using Json::operator>>; | ||
|
|
||
| // json_features.h | ||
| using Json::Features; | ||
|
|
||
| // value.h | ||
| using Json::ArrayIndex; | ||
| using Json::StaticString; | ||
| using Json::Path; | ||
| using Json::PathArgument; | ||
| using Json::Value; | ||
| using Json::ValueIteratorBase; | ||
| using Json::ValueIterator; | ||
| using Json::ValueConstIterator; | ||
| using Json::ValueMembersView; | ||
| using Json::ValueConstMembersView; | ||
|
|
||
| // config.h | ||
| using Json::version; | ||
| using Json::Int; | ||
| using Json::UInt; | ||
| #ifdef JSON_HAS_INT64 | ||
| using Json::Int64; | ||
| using Json::UInt64; | ||
|
greptile-apps[bot] marked this conversation as resolved.
Resolved
|
||
| #endif | ||
| using Json::LargestInt; | ||
| using Json::LargestUInt; | ||
| using Json::Allocator; | ||
| using Json::String; | ||
| using Json::IStringStream; | ||
| using Json::OStringStream; | ||
| using Json::IStream; | ||
| using Json::OStream; | ||
|
|
||
| // allocator.h | ||
| using Json::SecureAllocator; | ||
| using Json::operator==; | ||
| using Json::operator!=; | ||
|
|
||
| // value.h | ||
| #if JSON_USE_EXCEPTION | ||
| using Json::Exception; | ||
| using Json::RuntimeError; | ||
| using Json::LogicError; | ||
| #endif | ||
| using Json::ValueType; | ||
| using Json::CommentPlacement; | ||
| using Json::PrecisionType; | ||
|
greptile-apps[bot] marked this conversation as resolved.
Resolved
|
||
| using Json::MemberProxy; | ||
| using Json::ConstMemberProxy; | ||
| using Json::nullValue; | ||
| using Json::intValue; | ||
| using Json::uintValue; | ||
| using Json::realValue; | ||
| using Json::stringValue; | ||
| using Json::booleanValue; | ||
| using Json::arrayValue; | ||
| using Json::objectValue; | ||
| using Json::commentBefore; | ||
| using Json::commentAfterOnSameLine; | ||
| using Json::commentAfter; | ||
| using Json::numberOfCommentPlacement; | ||
| using Json::significantDigits; | ||
| using Json::decimalPlaces; | ||
| using Json::swap; | ||
| using Json::writeString; | ||
| } // namespace Json | ||
Uh oh!
There was an error while loading. Please reload this page.