mirror of
https://github.com/nlohmann/json.git
synced 2026-03-11 03:31:24 +00:00
Add proper C++20 module support (#4799)
This commit is contained in:
27
src/modules/CMakeLists.txt
Normal file
27
src/modules/CMakeLists.txt
Normal file
@@ -0,0 +1,27 @@
|
||||
cmake_minimum_required(VERSION 3.28)
|
||||
|
||||
add_library(nlohmann_json_modules)
|
||||
|
||||
set(NLOHMANN_JSON_MODULES
|
||||
json.cppm
|
||||
)
|
||||
|
||||
if(NOT COMMAND configure_cpp_module_target)
|
||||
function(configure_cpp_module_target target)
|
||||
target_sources(${target} PUBLIC FILE_SET CXX_MODULES FILES ${NLOHMANN_JSON_MODULES})
|
||||
endfunction()
|
||||
endif()
|
||||
|
||||
configure_cpp_module_target(nlohmann_json_modules)
|
||||
|
||||
target_link_libraries(nlohmann_json_modules
|
||||
PUBLIC
|
||||
nlohmann_json::nlohmann_json
|
||||
)
|
||||
|
||||
target_include_directories(nlohmann_json_modules
|
||||
PRIVATE
|
||||
${PROJECT_SOURCE_DIR}/include
|
||||
)
|
||||
|
||||
target_compile_features(nlohmann_json_modules PUBLIC cxx_std_20)
|
||||
22
src/modules/json.cppm
Normal file
22
src/modules/json.cppm
Normal file
@@ -0,0 +1,22 @@
|
||||
module;
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
export module nlohmann.json;
|
||||
|
||||
export namespace nlohmann {
|
||||
template <typename T = void, typename SFINAE = void>
|
||||
using adl_serializer = ::nlohmann::adl_serializer<T, SFINAE>;
|
||||
|
||||
using basic_json = ::nlohmann::basic_json<>;
|
||||
|
||||
using json = ::nlohmann::json;
|
||||
|
||||
template <typename RefStringType>
|
||||
using json_pointer = ::nlohmann::json_pointer<RefStringType>;
|
||||
|
||||
using ::nlohmann::ordered_json;
|
||||
|
||||
template <class Key, class T, class IgnoredLess, class Allocator>
|
||||
using ordered_map = ::nlohmann::ordered_map<Key, T, IgnoredLess, Allocator>;
|
||||
} // namespace nlohmann
|
||||
Reference in New Issue
Block a user