diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 9d4bdbdb9..eec63c110 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -23,7 +23,7 @@ jobs: steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Get latest CMake and ninja - uses: lukka/get-cmake@56d043d188c3612951d8755da8f4b709ec951ad6 # v3.31.6 + uses: lukka/get-cmake@28983e0d3955dba2bb0a6810caae0c6cf268ec0c # v4.0.0 - name: Run CMake run: cmake -S . -B build -DJSON_CI=On - name: Build @@ -54,7 +54,7 @@ jobs: run: sudo apt-get update ; sudo apt-get install -y valgrind - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Get latest CMake and ninja - uses: lukka/get-cmake@56d043d188c3612951d8755da8f4b709ec951ad6 # v3.31.6 + uses: lukka/get-cmake@28983e0d3955dba2bb0a6810caae0c6cf268ec0c # v4.0.0 - name: Run CMake run: cmake -S . -B build -DJSON_CI=On - name: Build @@ -71,7 +71,7 @@ jobs: run: apt-get update ; apt-get install -y git clang-tools iwyu unzip - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Get latest CMake and ninja - uses: lukka/get-cmake@56d043d188c3612951d8755da8f4b709ec951ad6 # v3.31.6 + uses: lukka/get-cmake@28983e0d3955dba2bb0a6810caae0c6cf268ec0c # v4.0.0 - name: Run CMake run: cmake -S . -B build -DJSON_CI=On - name: Build @@ -85,10 +85,10 @@ jobs: target: [ci_cmake_flags, ci_test_diagnostics, ci_test_diagnostic_positions, ci_test_noexceptions, ci_test_noimplicitconversions, ci_test_legacycomparison, ci_test_noglobaludls] steps: - name: Install build-essential - run: apt-get update ; apt-get install -y build-essential unzip wget git + run: apt-get update ; apt-get install -y build-essential unzip wget git libssl-dev - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Get latest CMake and ninja - uses: lukka/get-cmake@56d043d188c3612951d8755da8f4b709ec951ad6 # v3.31.6 + uses: lukka/get-cmake@28983e0d3955dba2bb0a6810caae0c6cf268ec0c # v4.0.0 - name: Run CMake run: cmake -S . -B build -DJSON_CI=On - name: Build @@ -148,7 +148,7 @@ jobs: steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Get latest CMake and ninja - uses: lukka/get-cmake@56d043d188c3612951d8755da8f4b709ec951ad6 # v3.31.6 + uses: lukka/get-cmake@28983e0d3955dba2bb0a6810caae0c6cf268ec0c # v4.0.0 - name: Run CMake run: cmake -S . -B build -DJSON_CI=On - name: Build @@ -165,7 +165,7 @@ jobs: run: apt-get update ; apt-get install -y unzip git - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Get latest CMake and ninja - uses: lukka/get-cmake@56d043d188c3612951d8755da8f4b709ec951ad6 # v3.31.6 + uses: lukka/get-cmake@28983e0d3955dba2bb0a6810caae0c6cf268ec0c # v4.0.0 - name: Set env FORCE_STDCPPFS_FLAG for clang 7 / 8 / 9 / 10 run: echo "JSON_FORCED_GLOBAL_COMPILE_OPTIONS=-DJSON_HAS_FILESYSTEM=0;-DJSON_HAS_EXPERIMENTAL_FILESYSTEM=0" >> "$GITHUB_ENV" if: ${{ matrix.compiler == '7' || matrix.compiler == '8' || matrix.compiler == '9' || matrix.compiler == '10' }} @@ -183,7 +183,7 @@ jobs: steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Get latest CMake and ninja - uses: lukka/get-cmake@56d043d188c3612951d8755da8f4b709ec951ad6 # v3.31.6 + uses: lukka/get-cmake@28983e0d3955dba2bb0a6810caae0c6cf268ec0c # v4.0.0 - name: Run CMake run: cmake -S . -B build -DJSON_CI=On - name: Build @@ -201,7 +201,7 @@ jobs: run: apt-get update ; apt-get install -y git unzip - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Get latest CMake and ninja - uses: lukka/get-cmake@56d043d188c3612951d8755da8f4b709ec951ad6 # v3.31.6 + uses: lukka/get-cmake@28983e0d3955dba2bb0a6810caae0c6cf268ec0c # v4.0.0 - name: Run CMake run: cmake -S . -B build -DJSON_CI=On - name: Build with libc++ diff --git a/CMakeLists.txt b/CMakeLists.txt index 25ae28707..b17afac19 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1...3.14) +cmake_minimum_required(VERSION 3.5...4.0) ## ## PROJECT diff --git a/README.md b/README.md index dbb3e0b1b..207c81ca0 100644 --- a/README.md +++ b/README.md @@ -1144,7 +1144,7 @@ The library is used in multiple projects, applications, operating systems, etc. Though it's 2025 already, the support for C++11 is still a bit sparse. Currently, the following compilers are known to work: - GCC 4.8 - 14.2 (and possibly later) -- Clang 3.4 - 20.0 (and possibly later) +- Clang 3.4 - 21.0 (and possibly later) - Apple Clang 9.1 - 16.0 (and possibly later) - Intel C++ Compiler 17.0.2 (and possibly later) - Nvidia CUDA Compiler 11.0.221 (and possibly later) diff --git a/cmake/ci.cmake b/cmake/ci.cmake index 2ece5b3d1..ef4c257b1 100644 --- a/cmake/ci.cmake +++ b/cmake/ci.cmake @@ -541,6 +541,11 @@ add_custom_target(ci_benchmarks # CMake flags ############################################################################### +# we test the project with different CMake versions: +# - CMake 3.5 (the earliest supported) +# - CMake 3.31.6 (the latest 3.x release) +# - CMake 4.0.0 (the latest release) + function(ci_get_cmake version var) set(${var} ${PROJECT_BINARY_DIR}/cmake-${version}/bin/cmake) add_custom_command( @@ -548,26 +553,30 @@ function(ci_get_cmake version var) COMMAND wget -nc https://github.com/Kitware/CMake/releases/download/v${version}/cmake-${version}.tar.gz COMMAND tar xfz cmake-${version}.tar.gz COMMAND rm cmake-${version}.tar.gz - COMMAND ${CMAKE_COMMAND} -S cmake-${version} -B cmake-${version} - COMMAND ${CMAKE_COMMAND} --build cmake-${version} --parallel 10 + # -DCMAKE_POLICY_VERSION_MINIMUM=3.5 required to compile older CMake versions with CMake 4.0.0 + COMMAND cmake -S cmake-${version} -B cmake-${version} -DCMAKE_POLICY_VERSION_MINIMUM=3.5 + COMMAND cmake --build cmake-${version} --parallel 10 WORKING_DIRECTORY ${PROJECT_BINARY_DIR} COMMENT "Download CMake ${version}" ) set(${var} ${${var}} PARENT_SCOPE) endfunction() -ci_get_cmake(3.1.0 CMAKE_3_1_0_BINARY) -ci_get_cmake(3.13.0 CMAKE_3_13_0_BINARY) +ci_get_cmake(3.5.0 CMAKE_3_5_0_BINARY) +ci_get_cmake(3.31.6 CMAKE_3_31_6_BINARY) +ci_get_cmake(4.0.0 CMAKE_4_0_0_BINARY) -set(JSON_CMAKE_FLAGS_3_1_0 JSON_Diagnostics JSON_Diagnostic_Positions JSON_GlobalUDLs JSON_ImplicitConversions JSON_DisableEnumSerialization +# the tests require CMake 3.13 or later, so they are excluded for CMake 3.5.0 +set(JSON_CMAKE_FLAGS_3_5_0 JSON_Diagnostics JSON_Diagnostic_Positions JSON_GlobalUDLs JSON_ImplicitConversions JSON_DisableEnumSerialization JSON_LegacyDiscardedValueComparison JSON_Install JSON_MultipleHeaders JSON_SystemInclude JSON_Valgrind) -set(JSON_CMAKE_FLAGS_3_13_0 JSON_BuildTests) +set(JSON_CMAKE_FLAGS_3_31_6 JSON_BuildTests ${JSON_CMAKE_FLAGS_3_31_6}) +set(JSON_CMAKE_FLAGS_4_0_0 JSON_BuildTests ${JSON_CMAKE_FLAGS_3_5_0}) function(ci_add_cmake_flags_targets flag min_version) string(TOLOWER "ci_cmake_flag_${flag}" flag_target) string(REPLACE . _ min_version_var ${min_version}) set(cmake_binary ${CMAKE_${min_version_var}_BINARY}) - add_custom_target(${flag_target} + add_custom_target(${flag_target}_${min_version}_2 COMMENT "Check CMake flag ${flag} (CMake ${CMAKE_VERSION})" COMMAND ${CMAKE_COMMAND} -Werror=dev @@ -587,12 +596,16 @@ function(ci_add_cmake_flags_targets flag min_version) set(JSON_CMAKE_FLAG_BUILD_DIRS ${JSON_CMAKE_FLAG_BUILD_DIRS} PARENT_SCOPE) endfunction() -foreach(JSON_CMAKE_FLAG ${JSON_CMAKE_FLAGS_3_1_0}) - ci_add_cmake_flags_targets(${JSON_CMAKE_FLAG} 3.1.0) +foreach(JSON_CMAKE_FLAG ${JSON_CMAKE_FLAGS_3_5_0}) + ci_add_cmake_flags_targets(${JSON_CMAKE_FLAG} 3.5.0) endforeach() -foreach(JSON_CMAKE_FLAG ${JSON_CMAKE_FLAGS_3_13_0}) - ci_add_cmake_flags_targets(${JSON_CMAKE_FLAG} 3.13.0) +foreach(JSON_CMAKE_FLAG ${JSON_CMAKE_FLAGS_3_31_6}) + ci_add_cmake_flags_targets(${JSON_CMAKE_FLAG} 3.31.6) +endforeach() + +foreach(JSON_CMAKE_FLAG ${JSON_CMAKE_FLAGS_4_0_0}) + ci_add_cmake_flags_targets(${JSON_CMAKE_FLAG} 4.0.0) endforeach() add_custom_target(ci_cmake_flags @@ -695,6 +708,6 @@ add_custom_target(ci_test_build_documentation ############################################################################### add_custom_target(ci_clean - COMMAND rm -fr ${PROJECT_BINARY_DIR}/build_* cmake-3.1.0-Darwin64 ${JSON_CMAKE_FLAG_BUILD_DIRS} ${single_binaries} + COMMAND rm -fr ${PROJECT_BINARY_DIR}/build_* cmake-3.5.0-Darwin64 ${JSON_CMAKE_FLAG_BUILD_DIRS} ${single_binaries} COMMENT "Clean generated directories" ) diff --git a/docs/mkdocs/docs/community/quality_assurance.md b/docs/mkdocs/docs/community/quality_assurance.md index 63c003c0e..6f5bae565 100644 --- a/docs/mkdocs/docs/community/quality_assurance.md +++ b/docs/mkdocs/docs/community/quality_assurance.md @@ -208,4 +208,7 @@ violations will result in a failed build. All library functions are exposed and usable by CMake. - [x] All library options are exposed as [CMake options](https://json.nlohmann.me/integration/cmake/) and tested. -- [x] The library is tested against the earliest supported CMake version. +- [x] The library is tested against relevant CMake versions: + - CMake 3.5 (the earliest supported) + - CMake 3.31.6 (the latest 3.x release) + - CMake 4.0.0 (a very recent release) diff --git a/docs/mkdocs/docs/home/customers.md b/docs/mkdocs/docs/home/customers.md index 54151ad5c..6a157bf1a 100644 --- a/docs/mkdocs/docs/home/customers.md +++ b/docs/mkdocs/docs/home/customers.md @@ -111,6 +111,7 @@ the result of an internet search. If you know further customers of the library, - [**Autodesk Desktop**](https://damassets.autodesk.net/content/dam/autodesk/www/Company/legal-notices-trademarks/autodesk-desktop-platform-components/internal-autodesk-components-web-page-2023.pdf), a software platform developed by Autodesk for creating and managing desktop applications and services - [**Check Point**](https://www.checkpoint.com/about-us/copyright-and-trademarks/): a cybersecurity company specializing in threat prevention and network security solutions, offering a range of products designed to protect enterprises from cyber threats and ensure data integrity - [**Microsoft Office for Mac**](https://officecdnmac.microsoft.com/pr/legal/mac/OfficeforMacAttributions.html), a suite of productivity applications developed by Microsoft for macOS, including tools for word processing, spreadsheets, and presentations +- [**Microsoft Teams**](https://www.microsoft.com/microsoft-teams/), a team collaboration application offering workspace chat and video conferencing, file storage, and integration of proprietary and third-party applications and services - [**Nexthink Infinity**](https://docs.nexthink.com/legal/services-terms/experience-open-source-software-licenses/infinity-2022.8-software-licenses): a digital employee experience management platform for monitoring and improving IT performance - [**Sophos Connect Client**](https://docs.sophos.com/nsg/licenses/SophosConnect/SophosConnectAttribution.html): a secure VPN client from Sophos that allows remote users to connect to their corporate network, ensuring secure access to resources and data - [**Stonebranch**](https://stonebranchdocs.atlassian.net/wiki/spaces/UA77/pages/799545647/Licenses+for+Third-Party+Libraries): a cloud-based cybersecurity solution that integrates backup, disaster recovery, and cybersecurity features to protect data and ensure business continuity for organizations diff --git a/docs/mkdocs/docs/images/customers.png b/docs/mkdocs/docs/images/customers.png index 3422d388b..acba03498 100644 Binary files a/docs/mkdocs/docs/images/customers.png and b/docs/mkdocs/docs/images/customers.png differ diff --git a/docs/mkdocs/docs/integration/cmake.md b/docs/mkdocs/docs/integration/cmake.md index 69c8030f1..5574167ef 100644 --- a/docs/mkdocs/docs/integration/cmake.md +++ b/docs/mkdocs/docs/integration/cmake.md @@ -15,7 +15,7 @@ and use the namespaced imported target from the generated package configuration: !!! example ```cmake title="CMakeLists.txt" - cmake_minimum_required(VERSION 3.1) + cmake_minimum_required(VERSION 3.5) project(ExampleProject LANGUAGES CXX) find_package(nlohmann_json 3.11.3 REQUIRED) @@ -35,7 +35,7 @@ To embed the library directly into an existing CMake project, place the entire s !!! example ```cmake title="CMakeLists.txt" - cmake_minimum_required(VERSION 3.1) + cmake_minimum_required(VERSION 3.5) project(ExampleProject LANGUAGES CXX) # If you only include this third party in PRIVATE source files, you do not need to install it diff --git a/tests/cmake_add_subdirectory/project/CMakeLists.txt b/tests/cmake_add_subdirectory/project/CMakeLists.txt index 0695305ff..775933e3f 100644 --- a/tests/cmake_add_subdirectory/project/CMakeLists.txt +++ b/tests/cmake_add_subdirectory/project/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1...3.14) +cmake_minimum_required(VERSION 3.5...3.14) project(DummyImport CXX) diff --git a/tests/cmake_import/project/CMakeLists.txt b/tests/cmake_import/project/CMakeLists.txt index 585f34cef..32bff796d 100644 --- a/tests/cmake_import/project/CMakeLists.txt +++ b/tests/cmake_import/project/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1...3.14) +cmake_minimum_required(VERSION 3.5...3.14) project(DummyImport CXX) diff --git a/tests/cmake_import_minver/project/CMakeLists.txt b/tests/cmake_import_minver/project/CMakeLists.txt index 25e40bfac..2e1af05db 100644 --- a/tests/cmake_import_minver/project/CMakeLists.txt +++ b/tests/cmake_import_minver/project/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1...3.14) +cmake_minimum_required(VERSION 3.5...3.14) project(DummyImportMinVer CXX) diff --git a/tests/cmake_target_include_directories/project/CMakeLists.txt b/tests/cmake_target_include_directories/project/CMakeLists.txt index 26b55cd89..c5317cf76 100644 --- a/tests/cmake_target_include_directories/project/CMakeLists.txt +++ b/tests/cmake_target_include_directories/project/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1...3.14) +cmake_minimum_required(VERSION 3.5...3.14) project(DummyImport CXX)