diff --git a/CMakeLists.txt b/CMakeLists.txt index 8529ab641..6415b3838 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,10 +27,10 @@ option(NLOHMANN_JSON_BUILD_MODULES "Build C++ modules support" OFF) if(NLOHMANN_JSON_BUILD_MODULES) if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.28) - message(STATUS "Building nlohmann-json C++ modules (CMake ${CMAKE_VERSION} supports modules)") - add_subdirectory(modules) + message(STATUS "Building nlohmann.json C++ module") + add_subdirectory(src/modules) else() - message(WARNING "Skipping nlohmann-json C++ modules (requires CMake 3.28+, found ${CMAKE_VERSION})") + message(WARNING "Skipping nlohmann.json C++ module (requires CMake 3.28+, found ${CMAKE_VERSION})") endif() endif() diff --git a/docs/mkdocs/docs/features/modules.md b/docs/mkdocs/docs/features/modules.md index 826fc2d75..884e9b07a 100644 --- a/docs/mkdocs/docs/features/modules.md +++ b/docs/mkdocs/docs/features/modules.md @@ -1,6 +1,8 @@ # Modules -This library supports C++ modules, introduced in C++20. The library can be imported by writing `import nlohmann.json;` instead of `#include `. +This library has experimental support for C++ modules, introduced in C++20. The library can be imported by writing `import nlohmann.json;` instead of `#include `. + +Please be aware that the module is experimental and a full test is outstanding, and the exported symbols are subject to change. ## Requirements The `nlohmann.json` module requires that the build system is configured to build and resolve modules when imported. Obviously, as modules were introduced in C++20, this feature can only be used in C++20 and subsequent versions. diff --git a/modules/CMakeLists.txt b/src/modules/CMakeLists.txt similarity index 100% rename from modules/CMakeLists.txt rename to src/modules/CMakeLists.txt diff --git a/modules/json.cppm b/src/modules/json.cppm similarity index 100% rename from modules/json.cppm rename to src/modules/json.cppm diff --git a/tests/module_cpp20/CMakeLists.txt b/tests/module_cpp20/CMakeLists.txt index 0ee3e0cc8..18c656ccf 100644 --- a/tests/module_cpp20/CMakeLists.txt +++ b/tests/module_cpp20/CMakeLists.txt @@ -2,11 +2,11 @@ cmake_minimum_required(VERSION 3.28) project(json_test CXX) -set(nlohmann_json_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../build/modules) +set(nlohmann_json_DIR ${CMAKE_BINARY_DIR}/modules) -set(NLOHMANN_JSON_BUILD_MODULES ON CACHE BOOL "Enable nlohmann-json module support") +set(NLOHMANN_JSON_BUILD_MODULES ON CACHE BOOL "Enable nlohmann.json module support") -add_subdirectory(../.. build) +add_subdirectory(${CMAKE_SOURCE_DIR}/../.. ${CMAKE_BINARY_DIR}/tests) add_executable(json_test main.cpp) target_link_libraries(json_test