mirror of
https://github.com/nlohmann/json.git
synced 2025-11-23 19:34:10 +08:00
Add proper C++20 module support (#4799)
This commit is contained in:
@@ -2,11 +2,18 @@ cmake_minimum_required(VERSION 3.28)
|
||||
|
||||
project(json_test CXX)
|
||||
|
||||
add_executable(json_test)
|
||||
set(NLOHMANN_JSON_BUILD_MODULES ON CACHE BOOL "Enable nlohmann.json module support")
|
||||
|
||||
target_sources(json_test
|
||||
PRIVATE main.cpp
|
||||
PUBLIC FILE_SET cxx_modules TYPE CXX_MODULES FILES json.cpp)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../.. ${CMAKE_CURRENT_BINARY_DIR}/tests)
|
||||
|
||||
add_executable(json_test main.cpp)
|
||||
target_link_libraries(json_test
|
||||
PRIVATE
|
||||
nlohmann_json_modules
|
||||
)
|
||||
|
||||
target_compile_definitions(json_test
|
||||
PRIVATE NLOHMANN_JSON_BUILD_MODULES
|
||||
)
|
||||
|
||||
target_compile_features(json_test PUBLIC cxx_std_20)
|
||||
target_include_directories(json_test PRIVATE ../../include)
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
module;
|
||||
#include <nlohmann/json.hpp>
|
||||
export module json;
|
||||
|
||||
export namespace nlohmann
|
||||
{
|
||||
using ::nlohmann::adl_serializer;
|
||||
|
||||
using ::nlohmann::basic_json;
|
||||
using ::nlohmann::json_pointer;
|
||||
|
||||
using ::nlohmann::json;
|
||||
using ::nlohmann::ordered_json;
|
||||
using ::nlohmann::ordered_map;
|
||||
|
||||
using ::nlohmann::json_pointer;
|
||||
} // namespace nlohmann
|
||||
@@ -1,4 +1,4 @@
|
||||
import json;
|
||||
import nlohmann.json;
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user