Add CMake presets

This commit is contained in:
Florian Albrechtskirchinger 2022-06-23 17:41:26 +02:00
parent e50aefc7d1
commit 6a038d2150
No known key found for this signature in database
GPG Key ID: 19618CE9B2D4BE6D
3 changed files with 123 additions and 0 deletions

2
.gitignore vendored
View File

@ -23,6 +23,8 @@
/tests/parse_*_fuzzer
/tests/corpus_*
CMakeUserPresets.json
/docs/mkdocs/docs/examples/
/docs/mkdocs/docs/__pycache__/
/docs/mkdocs/site/

114
CMakePresets.json Normal file
View File

@ -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"
}
]
}

View File

@ -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()