From 4bc4e37f4f56f88b3a80abb7a6508b19a244e803 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Thu, 28 Aug 2025 16:21:01 +0200 Subject: [PATCH] Fix Windows CI (#4897) * :construction_worker: fix Windows CI Signed-off-by: Niels Lohmann * :construction_worker: fix Windows CI Signed-off-by: Niels Lohmann * :construction_worker: fix Windows CI Signed-off-by: Niels Lohmann * :construction_worker: fix Windows CI Signed-off-by: Niels Lohmann * :construction_worker: fix Windows CI Signed-off-by: Niels Lohmann * :construction_worker: fix Windows CI Signed-off-by: Niels Lohmann * :construction_worker: fix Windows CI Signed-off-by: Niels Lohmann * :construction_worker: fix Windows CI Signed-off-by: Niels Lohmann * :construction_worker: fix Windows CI Signed-off-by: Niels Lohmann * :construction_worker: fix Windows CI Signed-off-by: Niels Lohmann * :construction_worker: fix Windows CI Signed-off-by: Niels Lohmann * :construction_worker: fix Windows CI Signed-off-by: Niels Lohmann * :construction_worker: fix Windows CI Signed-off-by: Niels Lohmann * :construction_worker: fix Windows CI Signed-off-by: Niels Lohmann --------- Signed-off-by: Niels Lohmann --- .github/workflows/windows.yml | 62 ++++---- .../docs/community/quality_assurance.md | 146 +++++++++--------- tests/cmake_add_subdirectory/CMakeLists.txt | 1 + .../project/CMakeLists.txt | 4 + tests/cmake_add_subdirectory/project/main.cpp | 2 +- tests/cmake_fetch_content/CMakeLists.txt | 1 + .../project/CMakeLists.txt | 4 + tests/cmake_fetch_content/project/main.cpp | 2 +- tests/cmake_fetch_content2/CMakeLists.txt | 1 + .../project/CMakeLists.txt | 4 + tests/cmake_fetch_content2/project/main.cpp | 2 +- tests/cmake_import/CMakeLists.txt | 1 + tests/cmake_import/project/CMakeLists.txt | 5 +- tests/cmake_import/project/main.cpp | 2 +- tests/cmake_import_minver/CMakeLists.txt | 1 + .../project/CMakeLists.txt | 4 + tests/cmake_import_minver/project/main.cpp | 2 +- .../CMakeLists.txt | 1 + .../project/CMakeLists.txt | 6 +- .../project/main.cpp | 2 +- 20 files changed, 142 insertions(+), 111 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 40d8e4864..b4c816cad 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -70,34 +70,34 @@ jobs: - name: Test run: cd build ; ctest -j 10 -C ${{ matrix.build_type }} --output-on-failure -# clang: -# runs-on: windows-2025 -# strategy: -# matrix: -# version: [11, 12, 13, 14, 15] -# -# steps: -# - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 -# - name: Install Clang -# run: curl -fsSL -o LLVM${{ matrix.version }}.exe https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ matrix.version }}.0.0/LLVM-${{ matrix.version }}.0.0-win64.exe ; 7z x LLVM${{ matrix.version }}.exe -y -o"C:/Program Files/LLVM" -# - name: Run CMake -# run: cmake -S . -B build -DCMAKE_CXX_COMPILER="C:/Program Files/LLVM/bin/clang++.exe" -G"MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -# - name: Build -# run: cmake --build build --parallel 10 -# - name: Test -# run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure -# -# clang-cl-12: -# runs-on: windows-2025 -# strategy: -# matrix: -# architecture: [Win32, x64] -# -# steps: -# - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 -# - name: Run CMake -# run: cmake -S . -B build -G "Visual Studio 16 2019" -A ${{ matrix.architecture }} -T ClangCL -DJSON_BuildTests=On -# - name: Build -# run: cmake --build build --config Debug --parallel 10 -# - name: Test -# run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure + clang: + runs-on: windows-2022 + strategy: + matrix: + version: [11.0.1, 12.0.1, 13.0.1, 14.0.6, 15.0.7, 16.0.6, 18.1.8, 19.1.7, 20.1.8] + + steps: + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + - name: Install Clang + run: curl -fsSL -o LLVM${{ matrix.version }}.exe https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ matrix.version }}/LLVM-${{ matrix.version }}-win64.exe ; 7z x LLVM${{ matrix.version }}.exe -y -o"C:/Program Files/LLVM" + - name: Run CMake + run: cmake -S . -B build -DCMAKE_CXX_COMPILER="C:/Program Files/LLVM/bin/clang++.exe" -DCMAKE_CXX_FLAGS="--target=x86_64-w64-mingw32 -stdlib=libstdc++ -pthread" -DCMAKE_EXE_LINKER_FLAGS="-lwinpthread" -G"MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On + - name: Build + run: cmake --build build --parallel 10 + - name: Test + run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure + + clang-cl-12: + runs-on: windows-2022 + strategy: + matrix: + architecture: [Win32, x64] + + steps: + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + - name: Run CMake + run: cmake -S . -B build -G "Visual Studio 17 2022" -A ${{ matrix.architecture }} -T ClangCL -DJSON_BuildTests=On + - name: Build + run: cmake --build build --config Debug --parallel 10 + - name: Test + run: cd build ; ctest -j 10 -C Debug --exclude-regex "test-unicode" --output-on-failure diff --git a/docs/mkdocs/docs/community/quality_assurance.md b/docs/mkdocs/docs/community/quality_assurance.md index 5b09b12fe..a57cb41a9 100644 --- a/docs/mkdocs/docs/community/quality_assurance.md +++ b/docs/mkdocs/docs/community/quality_assurance.md @@ -15,82 +15,84 @@ violations will result in a failed build. ??? abstract "Compilers used in continuous integration" - | Compiler | Architecture | Operating System | CI | - |----------------------------------------------|--------------|--------------------------|-----------| - | AppleClang 14.0.0.14000029; Xcode 14.1 | x86_64 | macOS 13.7.2 (Ventura) | GitHub | - | AppleClang 14.0.0.14000029; Xcode 14.2 | x86_64 | macOS 13.7.2 (Ventura) | GitHub | - | AppleClang 14.0.3.14030022; Xcode 14.3.1 | x86_64 | macOS 13.7.2 (Ventura) | GitHub | - | AppleClang 15.0.0.15000040; Xcode 15.0.1 | x86_64 | macOS 13.7.2 (Ventura) | GitHub | - | AppleClang 15.0.0.15000100; Xcode 15.1 | x86_64 | macOS 13.7.2 (Ventura) | GitHub | - | AppleClang 15.0.0.15000100; Xcode 15.2 | x86_64 | macOS 13.7.2 (Ventura) | GitHub | - | AppleClang 15.0.0.15000309; Xcode 15.3 | arm64 | macOS 14.7.2 (Sonoma) | GitHub | - | AppleClang 15.0.0.15000309; Xcode 15.4 | arm64 | macOS 14.7.2 (Sonoma) | GitHub | - | AppleClang 16.0.0.16000026; Xcode 16 | arm64 | macOS 15.2 (Sequoia) | GitHub | - | AppleClang 16.0.0.16000026; Xcode 16.1 | arm64 | macOS 15.2 (Sequoia) | GitHub | - | AppleClang 16.0.0.16000026; Xcode 16.2 | arm64 | macOS 15.2 (Sequoia) | GitHub | - | AppleClang 17.0.0.17000013; Xcode 16.3 | arm64 | macOS 15.5 (Sequoia) | GitHub | - | Clang 3.5.2 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | Clang 3.6.2 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | Clang 3.7.1 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | Clang 3.8.1 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | Clang 3.9.1 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | Clang 4.0.1 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | Clang 5.0.2 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | Clang 6.0.1 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | Clang 7.1.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | Clang 8.0.1 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | Clang 9.0.1 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | Clang 10.0.1 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | Clang 11.0.0 with GNU-like command-line | x86_64 | Windows 10 (Build 17763) | GitHub | - | Clang 11.1.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | Clang 12.0.0 with GNU-like command-line | x86_64 | Windows 10 (Build 17763) | GitHub | - | Clang 12.0.0 with MSVC-like command-line | x86_64 | Windows 10 (Build 17763) | GitHub | - | Clang 12.0.1 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | Clang 13.0.0 with GNU-like command-line | x86_64 | Windows 10 (Build 17763) | GitHub | - | Clang 13.0.1 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | Clang 14.0.0 with GNU-like command-line | x86_64 | Windows 10 (Build 17763) | GitHub | - | Clang 14.0.6 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | Clang 15.0.0 with GNU-like command-line | x86_64 | Windows 10 (Build 17763) | GitHub | - | Clang 15.0.7 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | Clang 16.0.6 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | Clang 17.0.6 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | Clang 18.1.8 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | Clang 19.1.7 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | Clang 20.1.1 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | Clang 21.0.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | Emscripten 4.0.6 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | GNU 4.8.5 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | GNU 4.9.3 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | GNU 5.5.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | GNU 6.4.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | GNU 7.5.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | GNU 8.5.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | GNU 9.3.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | GNU 9.4.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | GNU 9.5.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | GNU 10.5.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | GNU 11.4.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | GNU 11.5.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | GNU 12.2.0 (MinGW-W64 i686-ucrt-posix-dwarf) | x86_64 | Windows 10 (Build 17763) | GitHub | - | GNU 12.2.0 (MinGW-W64 x86_64-ucrt-posix-seh) | x86_64 | Windows 10 (Build 17763) | GitHub | - | GNU 12.4.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | GNU 13.3.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | GNU 14.2.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | GNU 14.2.0 | arm64 | Linux 6.1.100 | Cirrus CI | - | GNU 15.1.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | - | icpc (ICC) 2021.5.0 20211109 | x86_64 | Ubuntu 20.04.3 LTS | GitHub | - | MSVC 19.0.24241.7 | x86 | Windows 8.1 | AppVeyor | - | MSVC 19.16.27035.0 | x86 | Windows-10 (Build 14393) | AppVeyor | - | MSVC 19.29.30157.0 | x86 | Windows 10 (Build 17763) | GitHub | - | MSVC 19.29.30157.0 | x86_64 | Windows 10 (Build 17763) | GitHub | - | MSVC 19.29.30157.0 | x86 | Windows-10 (Build 17763) | AppVeyor | - | MSVC 19.42.34435.0 | x86 | Windows 10 (Build 20348) | GitHub | - | MSVC 19.42.34435.0 | x86_64 | Windows 10 (Build 20348) | GitHub | + | Compiler | Architecture | Operating System | CI | + |----------------------------------------------|--------------|-----------------------------------|-----------| + | AppleClang 14.0.0.14000029; Xcode 14.1 | x86_64 | macOS 13.7.2 (Ventura) | GitHub | + | AppleClang 14.0.0.14000029; Xcode 14.2 | x86_64 | macOS 13.7.2 (Ventura) | GitHub | + | AppleClang 14.0.3.14030022; Xcode 14.3.1 | x86_64 | macOS 13.7.2 (Ventura) | GitHub | + | AppleClang 15.0.0.15000040; Xcode 15.0.1 | x86_64 | macOS 13.7.2 (Ventura) | GitHub | + | AppleClang 15.0.0.15000100; Xcode 15.1 | x86_64 | macOS 13.7.2 (Ventura) | GitHub | + | AppleClang 15.0.0.15000100; Xcode 15.2 | x86_64 | macOS 13.7.2 (Ventura) | GitHub | + | AppleClang 15.0.0.15000309; Xcode 15.3 | arm64 | macOS 14.7.2 (Sonoma) | GitHub | + | AppleClang 15.0.0.15000309; Xcode 15.4 | arm64 | macOS 14.7.2 (Sonoma) | GitHub | + | AppleClang 16.0.0.16000026; Xcode 16 | arm64 | macOS 15.2 (Sequoia) | GitHub | + | AppleClang 16.0.0.16000026; Xcode 16.1 | arm64 | macOS 15.2 (Sequoia) | GitHub | + | AppleClang 16.0.0.16000026; Xcode 16.2 | arm64 | macOS 15.2 (Sequoia) | GitHub | + | AppleClang 17.0.0.17000013; Xcode 16.3 | arm64 | macOS 15.5 (Sequoia) | GitHub | + | Clang 3.5.2 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | Clang 3.6.2 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | Clang 3.7.1 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | Clang 3.8.1 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | Clang 3.9.1 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | Clang 4.0.1 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | Clang 5.0.2 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | Clang 6.0.1 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | Clang 7.1.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | Clang 8.0.1 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | Clang 9.0.1 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | Clang 10.0.1 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | Clang 11.0.1 with GNU-like command-line | x86_64 | Windows Server 2022 (Build 20348) | GitHub | + | Clang 11.1.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | Clang 12.0.1 with GNU-like command-line | x86_64 | Windows Server 2022 (Build 20348) | GitHub | + | Clang 12.0.1 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | Clang 13.0.1 with GNU-like command-line | x86_64 | Windows Server 2022 (Build 20348) | GitHub | + | Clang 13.0.1 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | Clang 14.0.6 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | Clang 14.0.6 with GNU-like command-line | x86_64 | Windows Server 2022 (Build 20348) | GitHub | + | Clang 15.0.7 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | Clang 15.0.7 with GNU-like command-line | x86_64 | Windows Server 2022 (Build 20348) | GitHub | + | Clang 16.0.6 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | Clang 16.0.6 with GNU-like command-line | x86_64 | Windows Server 2022 (Build 20348) | GitHub | + | Clang 17.0.6 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | Clang 18.1.8 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | Clang 18.1.8 with GNU-like command-line | x86_64 | Windows Server 2022 (Build 20348) | GitHub | + | Clang 19.1.5 with MSVC-like command-line | x86_64 | Windows Server 2022 (Build 20348) | GitHub | + | Clang 19.1.7 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | Clang 19.1.7 with GNU-like command-line | x86_64 | Windows Server 2022 (Build 20348) | GitHub | + | Clang 20.1.1 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | Clang 20.1.8 with GNU-like command-line | x86_64 | Windows Server 2022 (Build 20348) | GitHub | + | Clang 21.0.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | Emscripten 4.0.6 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | GNU 4.8.5 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | GNU 4.9.3 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | GNU 5.5.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | GNU 6.4.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | GNU 7.5.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | GNU 8.5.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | GNU 9.3.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | GNU 9.4.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | GNU 9.5.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | GNU 10.5.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | GNU 11.4.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | GNU 11.5.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | GNU 12.2.0 (MinGW-W64 i686-ucrt-posix-dwarf) | x86_64 | Windows Server 2022 (Build 20348) | GitHub | + | GNU 12.2.0 (MinGW-W64 x86_64-ucrt-posix-seh) | x86_64 | Windows Server 2022 (Build 20348) | GitHub | + | GNU 12.4.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | GNU 13.3.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | GNU 14.2.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | GNU 14.2.0 | arm64 | Linux 6.1.100 | Cirrus CI | + | GNU 15.1.0 | x86_64 | Ubuntu 22.04.1 LTS | GitHub | + | icpc (ICC) 2021.5.0 20211109 | x86_64 | Ubuntu 20.04.3 LTS | GitHub | + | MSVC 19.0.24241.7 | x86 | Windows 8.1 | AppVeyor | + | MSVC 19.16.27035.0 | x86 | Windows-10 (Build 14393) | AppVeyor | + | MSVC 19.29.30157.0 | x86 | Windows-10 (Build 17763) | AppVeyor | + | MSVC 19.44.35214.0 | x86 | Windows Server 2022 (Build 20348) | GitHub | + | MSVC 19.44.35214.0 | x86_64 | Windows Server 2022 (Build 20348) | GitHub | - [x] The library is compiled with all C++ language revisions (C++11, C++14, C++17, C++20, C++23, and C++26) to detect and fix language deprecations early. - [x] The library is checked for compiler warnings: - - On Clang, `-Weverything` is used with 7 exceptions. + - On Clang, `-Weverything` is used with 8 exceptions. ??? abstract "Clang warnings" diff --git a/tests/cmake_add_subdirectory/CMakeLists.txt b/tests/cmake_add_subdirectory/CMakeLists.txt index 21c736a7b..7bb661075 100644 --- a/tests/cmake_add_subdirectory/CMakeLists.txt +++ b/tests/cmake_add_subdirectory/CMakeLists.txt @@ -2,6 +2,7 @@ add_test(NAME cmake_add_subdirectory_configure COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} -Dnlohmann_json_source=${PROJECT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/project ) diff --git a/tests/cmake_add_subdirectory/project/CMakeLists.txt b/tests/cmake_add_subdirectory/project/CMakeLists.txt index 775933e3f..ff8838e6d 100644 --- a/tests/cmake_add_subdirectory/project/CMakeLists.txt +++ b/tests/cmake_add_subdirectory/project/CMakeLists.txt @@ -2,6 +2,10 @@ cmake_minimum_required(VERSION 3.5...3.14) project(DummyImport CXX) +if(MSVC) + add_compile_options(/EHsc) +endif() + set(JSON_BuildTests OFF CACHE INTERNAL "") add_subdirectory(${nlohmann_json_source} ${CMAKE_CURRENT_BINARY_DIR}/nlohmann_json) diff --git a/tests/cmake_add_subdirectory/project/main.cpp b/tests/cmake_add_subdirectory/project/main.cpp index 30bfbaf5a..a2aab2c5f 100644 --- a/tests/cmake_add_subdirectory/project/main.cpp +++ b/tests/cmake_add_subdirectory/project/main.cpp @@ -8,7 +8,7 @@ #include -int main(int argc, char** argv) +int main() { nlohmann::json j; diff --git a/tests/cmake_fetch_content/CMakeLists.txt b/tests/cmake_fetch_content/CMakeLists.txt index 7df00865e..211a49cee 100644 --- a/tests/cmake_fetch_content/CMakeLists.txt +++ b/tests/cmake_fetch_content/CMakeLists.txt @@ -3,6 +3,7 @@ if (${CMAKE_VERSION} VERSION_GREATER "3.11.0") COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} -Dnlohmann_json_source=${PROJECT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/project ) diff --git a/tests/cmake_fetch_content/project/CMakeLists.txt b/tests/cmake_fetch_content/project/CMakeLists.txt index b64af9ea5..9f7488157 100644 --- a/tests/cmake_fetch_content/project/CMakeLists.txt +++ b/tests/cmake_fetch_content/project/CMakeLists.txt @@ -13,6 +13,10 @@ if(NOT json_POPULATED) add_subdirectory(${json_SOURCE_DIR} ${json_BINARY_DIR} EXCLUDE_FROM_ALL) endif() +if(MSVC) + add_compile_options(/EHsc) +endif() + add_executable(with_namespace_target main.cpp) target_link_libraries(with_namespace_target nlohmann_json::nlohmann_json) diff --git a/tests/cmake_fetch_content/project/main.cpp b/tests/cmake_fetch_content/project/main.cpp index 30bfbaf5a..a2aab2c5f 100644 --- a/tests/cmake_fetch_content/project/main.cpp +++ b/tests/cmake_fetch_content/project/main.cpp @@ -8,7 +8,7 @@ #include -int main(int argc, char** argv) +int main() { nlohmann::json j; diff --git a/tests/cmake_fetch_content2/CMakeLists.txt b/tests/cmake_fetch_content2/CMakeLists.txt index 40e75e832..b35f93cfd 100644 --- a/tests/cmake_fetch_content2/CMakeLists.txt +++ b/tests/cmake_fetch_content2/CMakeLists.txt @@ -3,6 +3,7 @@ if (${CMAKE_VERSION} VERSION_GREATER "3.14.0") COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} -Dnlohmann_json_source=${PROJECT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/project ) diff --git a/tests/cmake_fetch_content2/project/CMakeLists.txt b/tests/cmake_fetch_content2/project/CMakeLists.txt index 734b9cc0e..5a2f722e6 100644 --- a/tests/cmake_fetch_content2/project/CMakeLists.txt +++ b/tests/cmake_fetch_content2/project/CMakeLists.txt @@ -8,6 +8,10 @@ get_filename_component(GIT_REPOSITORY_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../. FetchContent_Declare(json GIT_REPOSITORY ${GIT_REPOSITORY_DIRECTORY} GIT_TAG HEAD) FetchContent_MakeAvailable(json) +if(MSVC) + add_compile_options(/EHsc) +endif() + add_executable(with_namespace_target main.cpp) target_link_libraries(with_namespace_target nlohmann_json::nlohmann_json) diff --git a/tests/cmake_fetch_content2/project/main.cpp b/tests/cmake_fetch_content2/project/main.cpp index 30bfbaf5a..a2aab2c5f 100644 --- a/tests/cmake_fetch_content2/project/main.cpp +++ b/tests/cmake_fetch_content2/project/main.cpp @@ -8,7 +8,7 @@ #include -int main(int argc, char** argv) +int main() { nlohmann::json j; diff --git a/tests/cmake_import/CMakeLists.txt b/tests/cmake_import/CMakeLists.txt index 13290b2e3..eec526389 100644 --- a/tests/cmake_import/CMakeLists.txt +++ b/tests/cmake_import/CMakeLists.txt @@ -3,6 +3,7 @@ add_test(NAME cmake_import_configure -G "${CMAKE_GENERATOR}" -A "${CMAKE_GENERATOR_PLATFORM}" -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} -Dnlohmann_json_DIR=${PROJECT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/project ) diff --git a/tests/cmake_import/project/CMakeLists.txt b/tests/cmake_import/project/CMakeLists.txt index 32bff796d..181040c62 100644 --- a/tests/cmake_import/project/CMakeLists.txt +++ b/tests/cmake_import/project/CMakeLists.txt @@ -4,9 +4,12 @@ project(DummyImport CXX) find_package(nlohmann_json REQUIRED) +if(MSVC) + add_compile_options(/EHsc) +endif() + add_executable(with_namespace_target main.cpp) target_link_libraries(with_namespace_target nlohmann_json::nlohmann_json) add_executable(without_namespace_target main.cpp) target_link_libraries(without_namespace_target nlohmann_json) - diff --git a/tests/cmake_import/project/main.cpp b/tests/cmake_import/project/main.cpp index 30bfbaf5a..a2aab2c5f 100644 --- a/tests/cmake_import/project/main.cpp +++ b/tests/cmake_import/project/main.cpp @@ -8,7 +8,7 @@ #include -int main(int argc, char** argv) +int main() { nlohmann::json j; diff --git a/tests/cmake_import_minver/CMakeLists.txt b/tests/cmake_import_minver/CMakeLists.txt index 6d8db4399..42e3ff3e4 100644 --- a/tests/cmake_import_minver/CMakeLists.txt +++ b/tests/cmake_import_minver/CMakeLists.txt @@ -3,6 +3,7 @@ add_test(NAME cmake_import_minver_configure -G "${CMAKE_GENERATOR}" -A "${CMAKE_GENERATOR_PLATFORM}" -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} -Dnlohmann_json_DIR=${PROJECT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/project ) diff --git a/tests/cmake_import_minver/project/CMakeLists.txt b/tests/cmake_import_minver/project/CMakeLists.txt index 2e1af05db..0b8c90b25 100644 --- a/tests/cmake_import_minver/project/CMakeLists.txt +++ b/tests/cmake_import_minver/project/CMakeLists.txt @@ -4,5 +4,9 @@ project(DummyImportMinVer CXX) find_package(nlohmann_json 3.2.0 REQUIRED) +if(MSVC) + add_compile_options(/EHsc) +endif() + add_executable(with_namespace_target main.cpp) target_link_libraries(with_namespace_target nlohmann_json::nlohmann_json) diff --git a/tests/cmake_import_minver/project/main.cpp b/tests/cmake_import_minver/project/main.cpp index 30bfbaf5a..a2aab2c5f 100644 --- a/tests/cmake_import_minver/project/main.cpp +++ b/tests/cmake_import_minver/project/main.cpp @@ -8,7 +8,7 @@ #include -int main(int argc, char** argv) +int main() { nlohmann::json j; diff --git a/tests/cmake_target_include_directories/CMakeLists.txt b/tests/cmake_target_include_directories/CMakeLists.txt index 0a324cb92..86fea3a5a 100644 --- a/tests/cmake_target_include_directories/CMakeLists.txt +++ b/tests/cmake_target_include_directories/CMakeLists.txt @@ -2,6 +2,7 @@ add_test(NAME cmake_target_include_directories_configure COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} -Dnlohmann_json_source=${PROJECT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/project ) diff --git a/tests/cmake_target_include_directories/project/CMakeLists.txt b/tests/cmake_target_include_directories/project/CMakeLists.txt index c5317cf76..815cf52f5 100644 --- a/tests/cmake_target_include_directories/project/CMakeLists.txt +++ b/tests/cmake_target_include_directories/project/CMakeLists.txt @@ -2,12 +2,16 @@ cmake_minimum_required(VERSION 3.5...3.14) project(DummyImport CXX) +if(MSVC) + add_compile_options(/EHsc) +endif() + add_executable(with_private_target main.cpp) target_include_directories(with_private_target PRIVATE ${nlohmann_json_source}/include) set_target_properties(with_private_target PROPERTIES CXX_STANDARD 11) add_executable(with_private_system_target main.cpp) -target_include_directories(with_private_system_target PRIVATE SYSTEM ${nlohmann_json_source}/include) +target_include_directories(with_private_system_target SYSTEM PRIVATE ${nlohmann_json_source}/include) set_target_properties(with_private_system_target PROPERTIES CXX_STANDARD 11) # regression from https://github.com/nlohmann/json/discussions/2281 diff --git a/tests/cmake_target_include_directories/project/main.cpp b/tests/cmake_target_include_directories/project/main.cpp index 30bfbaf5a..a2aab2c5f 100644 --- a/tests/cmake_target_include_directories/project/main.cpp +++ b/tests/cmake_target_include_directories/project/main.cpp @@ -8,7 +8,7 @@ #include -int main(int argc, char** argv) +int main() { nlohmann::json j;