From e50aefc7d195d16239dc440c161215bc64374d3d Mon Sep 17 00:00:00 2001 From: Florian Albrechtskirchinger Date: Sun, 26 Jun 2022 18:41:15 +0200 Subject: [PATCH 1/3] Move CI warning flags to separate file --- cmake/ci.cmake | 325 +---------------------------------------- cmake/wflags.cmake | 350 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 351 insertions(+), 324 deletions(-) create mode 100644 cmake/wflags.cmake diff --git a/cmake/ci.cmake b/cmake/ci.cmake index 4fcff86aa..578d43dae 100644 --- a/cmake/ci.cmake +++ b/cmake/ci.cmake @@ -88,330 +88,7 @@ file(GLOB_RECURSE SRC_FILES ${PROJECT_SOURCE_DIR}/include/nlohmann/*.hpp) # Thorough check with recent compilers ############################################################################### -# Ignored Clang warnings: -# -Wno-c++98-compat The library targets C++11. -# -Wno-c++98-compat-pedantic The library targets C++11. -# -Wno-deprecated-declarations The library contains annotations for deprecated functions. -# -Wno-extra-semi-stmt The library uses std::assert which triggers this warning. -# -Wno-padded We do not care about padding warnings. -# -Wno-covered-switch-default All switches list all cases and a default case. -# -Wno-weak-vtables The library is header-only. -# -Wreserved-identifier See https://github.com/onqtam/doctest/issues/536. - -set(CLANG_CXXFLAGS - -Werror - -Weverything - -Wno-c++98-compat - -Wno-c++98-compat-pedantic - -Wno-deprecated-declarations - -Wno-extra-semi-stmt - -Wno-padded - -Wno-covered-switch-default - -Wno-weak-vtables - -Wno-reserved-identifier -) - -# Warning flags determined for GCC 13.0 (experimental) with https://github.com/nlohmann/gcc_flags: -# Ignored GCC warnings: -# -Wno-abi-tag We do not care about ABI tags. -# -Wno-aggregate-return The library uses aggregate returns. -# -Wno-long-long The library uses the long long type to interface with system functions. -# -Wno-namespaces The library uses namespaces. -# -Wno-padded We do not care about padding warnings. -# -Wno-system-headers We do not care about warnings in system headers. -# -Wno-templates The library uses templates. - -set(GCC_CXXFLAGS - -pedantic - -Werror - --all-warnings - --extra-warnings - -W - -WNSObject-attribute - -Wno-abi-tag - -Waddress - -Waddress-of-packed-member - -Wno-aggregate-return - -Waggressive-loop-optimizations - -Waligned-new=all - -Wall - -Walloc-zero - -Walloca - -Wanalyzer-double-fclose - -Wanalyzer-double-free - -Wanalyzer-exposure-through-output-file - -Wanalyzer-file-leak - -Wanalyzer-free-of-non-heap - -Wanalyzer-malloc-leak - -Wanalyzer-mismatching-deallocation - -Wanalyzer-null-argument - -Wanalyzer-null-dereference - -Wanalyzer-possible-null-argument - -Wanalyzer-possible-null-dereference - -Wanalyzer-shift-count-negative - -Wanalyzer-shift-count-overflow - -Wanalyzer-stale-setjmp-buffer - -Wanalyzer-tainted-allocation-size - -Wanalyzer-tainted-array-index - -Wanalyzer-tainted-divisor - -Wanalyzer-tainted-offset - -Wanalyzer-tainted-size - -Wanalyzer-too-complex - -Wanalyzer-unsafe-call-within-signal-handler - -Wanalyzer-use-after-free - -Wanalyzer-use-of-pointer-in-stale-stack-frame - -Wanalyzer-use-of-uninitialized-value - -Wanalyzer-va-arg-type-mismatch - -Wanalyzer-va-list-exhausted - -Wanalyzer-va-list-leak - -Wanalyzer-va-list-use-after-va-end - -Wanalyzer-write-to-const - -Wanalyzer-write-to-string-literal - -Warith-conversion - -Warray-bounds=2 - -Warray-compare - -Warray-parameter=2 - -Wattribute-alias=2 - -Wattribute-warning - -Wattributes - -Wbool-compare - -Wbool-operation - -Wbuiltin-declaration-mismatch - -Wbuiltin-macro-redefined - -Wc++0x-compat - -Wc++11-compat - -Wc++11-extensions - -Wc++14-compat - -Wc++14-extensions - -Wc++17-compat - -Wc++17-extensions - -Wc++1z-compat - -Wc++20-compat - -Wc++20-extensions - -Wc++23-extensions - -Wc++2a-compat - -Wcannot-profile - -Wcast-align - -Wcast-align=strict - -Wcast-function-type - -Wcast-qual - -Wcatch-value=3 - -Wchar-subscripts - -Wclass-conversion - -Wclass-memaccess - -Wclobbered - -Wcomma-subscript - -Wcomment - -Wcomments - -Wconditionally-supported - -Wconversion - -Wconversion-null - -Wcoverage-invalid-line-number - -Wcoverage-mismatch - -Wcpp - -Wctad-maybe-unsupported - -Wctor-dtor-privacy - -Wdangling-else - -Wdangling-pointer=2 - -Wdate-time - -Wdelete-incomplete - -Wdelete-non-virtual-dtor - -Wdeprecated - -Wdeprecated-copy - -Wdeprecated-copy-dtor - -Wdeprecated-declarations - -Wdeprecated-enum-enum-conversion - -Wdeprecated-enum-float-conversion - -Wdisabled-optimization - -Wdiv-by-zero - -Wdouble-promotion - -Wduplicated-branches - -Wduplicated-cond - -Weffc++ - -Wempty-body - -Wendif-labels - -Wenum-compare - -Wenum-conversion - -Wexceptions - -Wexpansion-to-defined - -Wextra - -Wextra-semi - -Wfloat-conversion - -Wfloat-equal - -Wformat-diag - -Wformat-overflow=2 - -Wformat-signedness - -Wformat-truncation=2 - -Wformat=2 - -Wframe-address - -Wfree-nonheap-object - -Whsa - -Wif-not-aligned - -Wignored-attributes - -Wignored-qualifiers - -Wimplicit-fallthrough=5 - -Winaccessible-base - -Winfinite-recursion - -Winherited-variadic-ctor - -Winit-list-lifetime - -Winit-self - -Winline - -Wint-in-bool-context - -Wint-to-pointer-cast - -Winterference-size - -Winvalid-imported-macros - -Winvalid-memory-model - -Winvalid-offsetof - -Winvalid-pch - -Wliteral-suffix - -Wlogical-not-parentheses - -Wlogical-op - -Wno-long-long - -Wlto-type-mismatch - -Wmain - -Wmaybe-uninitialized - -Wmemset-elt-size - -Wmemset-transposed-args - -Wmisleading-indentation - -Wmismatched-dealloc - -Wmismatched-new-delete - -Wmismatched-tags - -Wmissing-attributes - -Wmissing-braces - -Wmissing-declarations - -Wmissing-field-initializers - -Wmissing-include-dirs - -Wmissing-profile - -Wmissing-requires - -Wmissing-template-keyword - -Wmultichar - -Wmultiple-inheritance - -Wmultistatement-macros - -Wno-namespaces - -Wnarrowing - -Wnoexcept - -Wnoexcept-type - -Wnon-template-friend - -Wnon-virtual-dtor - -Wnonnull - -Wnonnull-compare - -Wnormalized=nfkc - -Wnull-dereference - -Wodr - -Wold-style-cast - -Wopenacc-parallelism - -Wopenmp-simd - -Woverflow - -Woverlength-strings - -Woverloaded-virtual - -Wpacked - -Wpacked-bitfield-compat - -Wpacked-not-aligned - -Wno-padded - -Wparentheses - -Wpedantic - -Wpessimizing-move - -Wplacement-new=2 - -Wpmf-conversions - -Wpointer-arith - -Wpointer-compare - -Wpragmas - -Wprio-ctor-dtor - -Wpsabi - -Wrange-loop-construct - -Wredundant-decls - -Wredundant-move - -Wredundant-tags - -Wregister - -Wreorder - -Wrestrict - -Wreturn-local-addr - -Wreturn-type - -Wscalar-storage-order - -Wsequence-point - -Wshadow=compatible-local - -Wshadow=global - -Wshadow=local - -Wshift-count-negative - -Wshift-count-overflow - -Wshift-negative-value - -Wshift-overflow=2 - -Wsign-compare - -Wsign-conversion - -Wsign-promo - -Wsized-deallocation - -Wsizeof-array-argument - -Wsizeof-array-div - -Wsizeof-pointer-div - -Wsizeof-pointer-memaccess - -Wstack-protector - -Wstrict-aliasing=3 - -Wstrict-null-sentinel - -Wno-strict-overflow - -Wstring-compare - -Wstringop-overflow=4 - -Wstringop-overread - -Wstringop-truncation - -Wsubobject-linkage - -Wsuggest-attribute=cold - -Wsuggest-attribute=const - -Wsuggest-attribute=format - -Wsuggest-attribute=malloc - -Wsuggest-attribute=noreturn - -Wsuggest-attribute=pure - -Wsuggest-final-methods - -Wsuggest-final-types - -Wsuggest-override - -Wswitch - -Wswitch-bool - -Wswitch-default - -Wswitch-enum - -Wswitch-outside-range - -Wswitch-unreachable - -Wsync-nand - -Wsynth - -Wno-system-headers - -Wtautological-compare - -Wno-templates - -Wterminate - -Wtrampolines - -Wtrigraphs - -Wtrivial-auto-var-init - -Wtsan - -Wtype-limits - -Wundef - -Wuninitialized - -Wunknown-pragmas - -Wunreachable-code - -Wunsafe-loop-optimizations - -Wunused - -Wunused-but-set-parameter - -Wunused-but-set-variable - -Wunused-const-variable=2 - -Wunused-function - -Wunused-label - -Wunused-local-typedefs - -Wunused-macros - -Wunused-parameter - -Wunused-result - -Wunused-value - -Wunused-variable - -Wuse-after-free=3 - -Wuseless-cast - -Wvarargs - -Wvariadic-macros - -Wvector-operation-performance - -Wvexing-parse - -Wvirtual-inheritance - -Wvirtual-move-assign - -Wvla - -Wvla-parameter - -Wvolatile - -Wvolatile-register-var - -Wwrite-strings - -Wzero-as-null-pointer-constant - -Wzero-length-bounds -) +include(wflags) add_custom_target(ci_test_gcc COMMAND CXX=${GCC_TOOL} CXXFLAGS="${GCC_CXXFLAGS}" ${CMAKE_COMMAND} diff --git a/cmake/wflags.cmake b/cmake/wflags.cmake new file mode 100644 index 000000000..dd37ed5d5 --- /dev/null +++ b/cmake/wflags.cmake @@ -0,0 +1,350 @@ +# Ignored Clang warnings: +# -Wno-c++98-compat The library targets C++11. +# -Wno-c++98-compat-pedantic The library targets C++11. +# -Wno-deprecated-declarations The library contains annotations for deprecated functions. +# -Wno-extra-semi-stmt The library uses std::assert which triggers this warning. +# -Wno-padded We do not care about padding warnings. +# -Wno-covered-switch-default All switches list all cases and a default case. +# -Wno-weak-vtables The library is header-only. +# -Wreserved-identifier See https://github.com/onqtam/doctest/issues/536. + +set(CLANG_CXXFLAGS + -Werror + -Weverything + -Wno-c++98-compat + -Wno-c++98-compat-pedantic + -Wno-deprecated-declarations + -Wno-extra-semi-stmt + -Wno-padded + -Wno-covered-switch-default + -Wno-weak-vtables + -Wno-reserved-identifier +) + +# Warning flags determined for GCC 13.0 (experimental) with https://github.com/nlohmann/gcc_flags: +# Use the following oneliner to flatten GCC flags: +# awk 'BEGIN { x=0 } /GCC_CXXFLAGS/ { x=1 } /\)/ { x=0 } \ +# /^\s*-/ { gsub(/ /, "", $0); if(x==1) print }' wflags.cmake | sort +# Ignored GCC warnings: +# -Wno-abi-tag We do not care about ABI tags. +# -Wno-aggregate-return The library uses aggregate returns. +# -Wno-long-long The library uses the long long type to interface with system functions. +# -Wno-namespaces The library uses namespaces. +# -Wno-padded We do not care about padding warnings. +# -Wno-system-headers We do not care about warnings in system headers. +# -Wno-templates The library uses templates. + +set(GCC_CXXFLAGS + -pedantic + -Werror + -Wno-abi-tag + -Waddress + -Wno-aggregate-return + -Waggressive-loop-optimizations + -Waligned-new=all + -Wall + -Walloc-zero + -Walloca + -Warray-bounds=2 + -Wattributes + -Wbool-compare + -Wbool-operation + -Wbuiltin-declaration-mismatch + -Wbuiltin-macro-redefined + -Wc++0x-compat + -Wc++11-compat + -Wc++14-compat + -Wc++17-compat + -Wc++1z-compat + -Wcast-align + -Wcast-align=strict + -Wcast-function-type + -Wcast-qual + -Wcatch-value=3 + -Wchar-subscripts + -Wclass-memaccess + -Wclobbered + -Wcomment + -Wcomments + -Wconditionally-supported + -Wconversion + -Wconversion-null + -Wcoverage-mismatch + -Wcpp + -Wctor-dtor-privacy + -Wdangling-else + -Wdate-time + -Wdelete-incomplete + -Wdelete-non-virtual-dtor + -Wdeprecated + -Wdeprecated-declarations + -Wdisabled-optimization + -Wdiv-by-zero + -Wdouble-promotion + -Wduplicated-branches + -Wduplicated-cond + -Weffc++ + -Wempty-body + -Wendif-labels + -Wenum-compare + -Wexpansion-to-defined + -Wextra + -Wextra-semi + -Wfloat-conversion + -Wfloat-equal + -Wformat-overflow=2 + -Wformat-signedness + -Wformat-truncation=2 + -Wformat=2 + -Wframe-address + -Wfree-nonheap-object + -Whsa + -Wif-not-aligned + -Wignored-attributes + -Wignored-qualifiers + -Wimplicit-fallthrough=5 + -Winherited-variadic-ctor + -Winit-self + -Winline + -Wint-in-bool-context + -Wint-to-pointer-cast + -Winvalid-memory-model + -Winvalid-offsetof + -Winvalid-pch + -Wliteral-suffix + -Wlogical-not-parentheses + -Wlogical-op + -Wno-long-long + -Wlto-type-mismatch + -Wmain + -Wmaybe-uninitialized + -Wmemset-elt-size + -Wmemset-transposed-args + -Wmisleading-indentation + -Wmissing-attributes + -Wmissing-braces + -Wmissing-declarations + -Wmissing-field-initializers + -Wmissing-include-dirs + -Wmultichar + -Wmultiple-inheritance + -Wmultistatement-macros + -Wno-namespaces + -Wnarrowing + -Wnoexcept + -Wnoexcept-type + -Wnon-template-friend + -Wnon-virtual-dtor + -Wnonnull + -Wnonnull-compare + -Wnormalized=nfkc + -Wnull-dereference + -Wodr + -Wold-style-cast + -Wopenmp-simd + -Woverflow + -Woverlength-strings + -Woverloaded-virtual + -Wpacked + -Wpacked-bitfield-compat + -Wpacked-not-aligned + -Wno-padded + -Wparentheses + -Wpedantic + -Wplacement-new=2 + -Wpmf-conversions + -Wpointer-arith + -Wpointer-compare + -Wpragmas + -Wpsabi + -Wredundant-decls + -Wregister + -Wreorder + -Wrestrict + -Wreturn-local-addr + -Wreturn-type + -Wscalar-storage-order + -Wsequence-point + -Wshadow=compatible-local + -Wshadow=global + -Wshadow=local + -Wshift-count-negative + -Wshift-count-overflow + -Wshift-negative-value + -Wshift-overflow=2 + -Wsign-compare + -Wsign-conversion + -Wsign-promo + -Wsized-deallocation + -Wsizeof-array-argument + -Wsizeof-pointer-div + -Wsizeof-pointer-memaccess + -Wstack-protector + -Wstrict-aliasing=3 + -Wstrict-null-sentinel + -Wno-strict-overflow + -Wstringop-overflow=4 + -Wstringop-truncation + -Wsubobject-linkage + -Wsuggest-attribute=cold + -Wsuggest-attribute=const + -Wsuggest-attribute=format + -Wsuggest-attribute=malloc + -Wsuggest-attribute=noreturn + -Wsuggest-attribute=pure + -Wsuggest-final-methods + -Wsuggest-final-types + -Wsuggest-override + -Wswitch + -Wswitch-bool + -Wswitch-default + -Wswitch-enum + -Wswitch-unreachable + -Wsync-nand + -Wsynth + -Wno-system-headers + -Wtautological-compare + -Wno-templates + -Wterminate + -Wtrampolines + -Wtrigraphs + -Wtype-limits + -Wundef + -Wuninitialized + -Wunknown-pragmas + -Wunreachable-code + -Wunsafe-loop-optimizations + -Wunused + -Wunused-but-set-parameter + -Wunused-but-set-variable + -Wunused-const-variable=2 + -Wunused-function + -Wunused-label + -Wunused-local-typedefs + -Wunused-parameter + -Wunused-result + -Wunused-value + -Wunused-variable + -Wuseless-cast + -Wvarargs + -Wvariadic-macros + -Wvector-operation-performance + -Wvirtual-inheritance + -Wvirtual-move-assign + -Wvla + -Wvolatile-register-var + -Wwrite-strings + -Wzero-as-null-pointer-constant +) + +if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9.0.0) + list(APPEND GCC_CXXFLAGS + -Waddress-of-packed-member + -Wattribute-alias=2 + -Wattribute-warning + -Wcannot-profile + -Wclass-conversion + -Wdeprecated-copy + -Wdeprecated-copy-dtor + -Winit-list-lifetime + -Wmissing-profile + -Wpessimizing-move + -Wprio-ctor-dtor + -Wredundant-move + ) +endif() + +if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 10.0.0) + list(APPEND GCC_CXXFLAGS + -Wanalyzer-double-fclose + -Wanalyzer-double-free + -Wanalyzer-exposure-through-output-file + -Wanalyzer-file-leak + -Wanalyzer-free-of-non-heap + -Wanalyzer-malloc-leak + -Wanalyzer-null-argument + -Wanalyzer-null-dereference + -Wanalyzer-possible-null-argument + -Wanalyzer-possible-null-dereference + -Wanalyzer-stale-setjmp-buffer + -Wanalyzer-tainted-array-index + -Wanalyzer-too-complex + -Wanalyzer-unsafe-call-within-signal-handler + -Wanalyzer-use-after-free + -Wanalyzer-use-of-pointer-in-stale-stack-frame + -Warith-conversion + -Wc++20-compat + -Wc++2a-compat + -Wcomma-subscript + -Wformat-diag + -Winaccessible-base + -Wmismatched-tags + -Wredundant-tags + -Wstring-compare + -Wswitch-outside-range + # available earlier but generates a lot more warnings before GCC 10 + -Wunused-macros + -Wvolatile + -Wzero-length-bounds + ) +endif() + +if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 11.0.0) + list(APPEND GCC_CXXFLAGS + -WNSObject-attribute + -Wanalyzer-mismatching-deallocation + -Wanalyzer-shift-count-negative + -Wanalyzer-shift-count-overflow + -Wanalyzer-write-to-const + -Wanalyzer-write-to-string-literal + -Warray-parameter=2 + -Wctad-maybe-unsupported + -Wdeprecated-enum-enum-conversion + -Wdeprecated-enum-float-conversion + -Wexceptions + -Wenum-conversion + -Winvalid-imported-macros + -Wmismatched-dealloc + -Wmismatched-new-delete + -Wrange-loop-construct + -Wsizeof-array-div + -Wstringop-overread + -Wtsan + -Wvexing-parse + -Wvla-parameter + ) +endif() + +if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 12.0.0) + list(APPEND GCC_CXXFLAGS + -Wanalyzer-tainted-allocation-size + -Wanalyzer-tainted-divisor + -Wanalyzer-tainted-offset + -Wanalyzer-tainted-size + -Wanalyzer-use-of-uninitialized-value + -Warray-compare + -Wc++11-extensions + -Wc++14-extensions + -Wc++17-extensions + -Wc++20-extensions + -Wc++23-extensions + -Wcoverage-invalid-line-number + -Wdangling-pointer=2 + -Winfinite-recursion + -Winterference-size + -Wmissing-requires + -Wmissing-template-keyword + -Wopenacc-parallelism + -Wtrivial-auto-var-init + -Wuse-after-free=3 + ) +endif() + +if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.0.0) + list(APPEND GCC_CXXFLAGS + -Wanalyzer-va-arg-type-mismatch + -Wanalyzer-va-list-exhausted + -Wanalyzer-va-list-leak + -Wanalyzer-va-list-use-after-va-end + ) +endif() From 6a038d21508da42207fa9e3a490427055cbf8027 Mon Sep 17 00:00:00 2001 From: Florian Albrechtskirchinger Date: Thu, 23 Jun 2022 17:41:26 +0200 Subject: [PATCH 2/3] Add CMake presets --- .gitignore | 2 + CMakePresets.json | 114 ++++++++++++++++++++++++++++++++++++++ cmake/preset-wflags.cmake | 7 +++ 3 files changed, 123 insertions(+) create mode 100644 CMakePresets.json create mode 100644 cmake/preset-wflags.cmake diff --git a/.gitignore b/.gitignore index 72eb2c225..cea69bb55 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,8 @@ /tests/parse_*_fuzzer /tests/corpus_* +CMakeUserPresets.json + /docs/mkdocs/docs/examples/ /docs/mkdocs/docs/__pycache__/ /docs/mkdocs/site/ diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 000000000..006a8d7d2 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,114 @@ +{ + "version": 4, + "configurePresets": [ + { + "name": "common", + "hidden": true, + "cacheVariables": { + "CMAKE_PROJECT_nlohmann_json_INCLUDE": "${sourceDir}/cmake/preset-wflags.cmake", + "JSON_TestDataDirectory": "$env{JSON_TEST_DATA_DIR}" + } + }, + { + "name": "default", + "displayName": "Default config", + "binaryDir": "${sourceDir}/build", + "inherits": "common" + }, + { + "name": "gcc", + "displayName": "GCC config", + "binaryDir": "${sourceDir}/build-gcc", + "inherits": "common", + "cacheVariables": { + "CMAKE_CXX_COMPILER": "g++" + } + }, + { + "name": "clang", + "displayName": "Clang config", + "binaryDir": "${sourceDir}/build-clang", + "inherits": "common", + "cacheVariables": { + "CMAKE_CXX_COMPILER": "clang++" + } + }, + { + "name": "gcc-tidy", + "displayName": "GCC config (with clang-tidy)", + "inherits": "gcc", + "cacheVariables": { + "CMAKE_CXX_CLANG_TIDY": "clang-tidy" + } + }, + { + "name": "clang-tidy", + "displayName": "Clang config (with clang-tidy)", + "inherits": "clang", + "cacheVariables": { + "CMAKE_CXX_CLANG_TIDY": "clang-tidy" + } + } + ], + "buildPresets": [ + { + "name": "common", + "hidden": true, + "jobs": 8 + }, + { + "name": "default", + "inherits": "common", + "configurePreset": "default" + }, + { + "name": "gcc", + "inherits": "common", + "configurePreset": "gcc" + }, + { + "name": "clang", + "inherits": "common", + "configurePreset": "clang" + }, + { + "name": "gcc-tidy", + "inherits": "common", + "configurePreset": "gcc-tidy" + }, + { + "name": "clang-tidy", + "inherits": "common", + "configurePreset": "clang-tidy" + } + ], + "testPresets": [ + { + "name": "common", + "hidden": true, + "output": { + "outputOnFailure": true + }, + "execution": { + "jobs": 8, + "noTestsAction": "error", + "stopOnFailure": true + } + }, + { + "name": "default", + "inherits": "common", + "configurePreset": "default" + }, + { + "name": "gcc", + "inherits": "common", + "configurePreset": "gcc" + }, + { + "name": "clang", + "inherits": "common", + "configurePreset": "clang" + } + ] +} diff --git a/cmake/preset-wflags.cmake b/cmake/preset-wflags.cmake new file mode 100644 index 000000000..f44cbfdca --- /dev/null +++ b/cmake/preset-wflags.cmake @@ -0,0 +1,7 @@ +include("${CMAKE_CURRENT_LIST_DIR}/wflags.cmake") + +if(CMAKE_CXX_COMPILER_ID STREQUAL Clang) + add_compile_options(${CLANG_CXXFLAGS}) +elseif(CMAKE_CXX_COMPILER_ID STREQUAL GNU) + add_compile_options(${GCC_CXXFLAGS}) +endif() From 0c05433e2fd6f70c3d9cfeed2ff2477d4119b3d9 Mon Sep 17 00:00:00 2001 From: Florian Albrechtskirchinger Date: Sun, 26 Jun 2022 18:40:01 +0200 Subject: [PATCH 3/3] CMake: Fix (potentially) invalid expression --- cmake/test.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/test.cmake b/cmake/test.cmake index b8b1250fb..5a5ce02ff 100644 --- a/cmake/test.cmake +++ b/cmake/test.cmake @@ -228,7 +228,7 @@ function(json_test_should_build_32bit_test build_32bit_var build_32bit_only_var # check if compiler is targeting 32bit by default include(CheckTypeSize) check_type_size("size_t" sizeof_size_t LANGUAGE CXX) - if(sizeof_size_t AND ${sizeof_size_t} EQUAL 4) + if(sizeof_size_t AND sizeof_size_t EQUAL 4) message(STATUS "Auto-enabling 32bit unit test.") set(${build_32bit_var} ON) else()