-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from bemanproject/preset
Add CMake presets
- Loading branch information
Showing
8 changed files
with
355 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
{ | ||
"version": 6, | ||
"configurePresets": [ | ||
{ | ||
"name": "_root-config", | ||
"hidden": true, | ||
"generator": "Ninja", | ||
"binaryDir": "${sourceDir}/build/${presetName}", | ||
"cacheVariables": { | ||
"CMAKE_CXX_STANDARD": "20" | ||
} | ||
}, | ||
{ | ||
"name": "_debug-base", | ||
"hidden": true, | ||
"cacheVariables": { | ||
"CMAKE_BUILD_TYPE": "Debug", | ||
"BEMAN_BUILDSYS_SANITIZER": "MaxSan" | ||
} | ||
}, | ||
{ | ||
"name": "_release-base", | ||
"hidden": true, | ||
"cacheVariables": { | ||
"CMAKE_BUILD_TYPE": "RelWithDebInfo" | ||
} | ||
}, | ||
{ | ||
"name": "gcc-debug", | ||
"displayName": "GCC Debug Build", | ||
"inherits": [ | ||
"_root-config", | ||
"_debug-base" | ||
], | ||
"cacheVariables": { | ||
"CMAKE_TOOLCHAIN_FILE": "cmake/gnu-toolchain.cmake" | ||
} | ||
}, | ||
{ | ||
"name": "gcc-release", | ||
"displayName": "GCC Release Build", | ||
"inherits": [ | ||
"_root-config", | ||
"_release-base" | ||
], | ||
"cacheVariables": { | ||
"CMAKE_TOOLCHAIN_FILE": "cmake/gnu-toolchain.cmake" | ||
} | ||
} | ||
], | ||
"buildPresets": [ | ||
{ | ||
"name": "gcc-debug", | ||
"configurePreset": "gcc-debug" | ||
}, | ||
{ | ||
"name": "gcc-release", | ||
"configurePreset": "gcc-release" | ||
} | ||
], | ||
"testPresets": [ | ||
{ | ||
"name": "_test_base", | ||
"hidden": true, | ||
"output": { | ||
"outputOnFailure": true | ||
}, | ||
"execution": { | ||
"noTestsAction": "error", | ||
"stopOnFailure": true | ||
} | ||
}, | ||
{ | ||
"name": "gcc-debug", | ||
"inherits": "_test_base", | ||
"configurePreset": "gcc-debug" | ||
}, | ||
{ | ||
"name": "gcc-release", | ||
"inherits": "_test_base", | ||
"configurePreset": "gcc-release" | ||
} | ||
], | ||
"workflowPresets": [ | ||
{ | ||
"name": "gcc-debug", | ||
"steps": [ | ||
{ | ||
"type": "configure", | ||
"name": "gcc-debug" | ||
}, | ||
{ | ||
"type": "build", | ||
"name": "gcc-debug" | ||
}, | ||
{ | ||
"type": "test", | ||
"name": "gcc-debug" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "gcc-release", | ||
"steps": [ | ||
{ | ||
"type": "configure", | ||
"name": "gcc-release" | ||
}, | ||
{ | ||
"type": "build", | ||
"name": "gcc-release" | ||
}, | ||
{ | ||
"type": "test", | ||
"name": "gcc-release" | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
# This toolchain file is not meant to be used directly, | ||
# but to be invoked by CMake preset and GitHub CI. | ||
# | ||
# This toolchain file configures for apple clang family of compiler. | ||
# Note this is different from LLVM toolchain. | ||
# | ||
# BEMAN_BUILDSYS_SANITIZER: | ||
# This optional CMake parameter is not meant for public use and is subject to | ||
# change. | ||
# Possible values: | ||
# - MaxSan: configures clang and clang++ to use all available non-conflicting | ||
# sanitizers. Note that apple clang does not support leak sanitizer. | ||
# - TSan: configures clang and clang++ to enable the use of thread sanitizer. | ||
|
||
include_guard(GLOBAL) | ||
|
||
set(CMAKE_C_COMPILER clang) | ||
set(CMAKE_CXX_COMPILER clang++) | ||
|
||
if(BEMAN_BUILDSYS_SANITIZER STREQUAL "MaxSan") | ||
set(SANITIZER_FLAGS | ||
"-fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined" | ||
) | ||
elseif(BEMAN_BUILDSYS_SANITIZER STREQUAL "TSan") | ||
set(SANITIZER_FLAGS "-fsanitize=thread") | ||
endif() | ||
|
||
set(CMAKE_C_FLAGS_DEBUG_INIT "${SANITIZER_FLAGS}") | ||
set(CMAKE_CXX_FLAGS_DEBUG_INIT "${SANITIZER_FLAGS}") | ||
|
||
set(RELEASE_FLAGS "-O3 ${SANITIZER_FLAGS}") | ||
|
||
set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "${RELEASE_FLAGS}") | ||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "${RELEASE_FLAGS}") | ||
|
||
set(CMAKE_C_FLAGS_RELEASE_INIT "${RELEASE_FLAGS}") | ||
set(CMAKE_CXX_FLAGS_RELEASE_INIT "${RELEASE_FLAGS}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
# This toolchain file is not meant to be used directly, | ||
# but to be invoked by CMake preset and GitHub CI. | ||
# | ||
# This toolchain file configures for GNU family of compiler. | ||
# | ||
# BEMAN_BUILDSYS_SANITIZER: | ||
# This optional CMake parameter is not meant for public use and is subject to | ||
# change. | ||
# Possible values: | ||
# - MaxSan: configures gcc and g++ to use all available non-conflicting | ||
# sanitizers. | ||
# - TSan: configures gcc and g++ to enable the use of thread sanitizer | ||
|
||
include_guard(GLOBAL) | ||
|
||
set(CMAKE_C_COMPILER gcc) | ||
set(CMAKE_CXX_COMPILER g++) | ||
|
||
if(BEMAN_BUILDSYS_SANITIZER STREQUAL "MaxSan") | ||
set(SANITIZER_FLAGS | ||
"-fsanitize=address -fsanitize=leak -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined" | ||
) | ||
elseif(BEMAN_BUILDSYS_SANITIZER STREQUAL "TSan") | ||
set(SANITIZER_FLAGS "-fsanitize=thread") | ||
endif() | ||
|
||
set(CMAKE_C_FLAGS_DEBUG_INIT "${SANITIZER_FLAGS}") | ||
set(CMAKE_CXX_FLAGS_DEBUG_INIT "${SANITIZER_FLAGS}") | ||
|
||
set(RELEASE_FLAGS "-O3 ${SANITIZER_FLAGS}") | ||
|
||
set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "${RELEASE_FLAGS}") | ||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "${RELEASE_FLAGS}") | ||
|
||
set(CMAKE_C_FLAGS_RELEASE_INIT "${RELEASE_FLAGS}") | ||
set(CMAKE_CXX_FLAGS_RELEASE_INIT "${RELEASE_FLAGS}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
# This toolchain file is not meant to be used directly, | ||
# but to be invoked by CMake preset and GitHub CI. | ||
# | ||
# This toolchain file configures for LLVM family of compiler. | ||
# | ||
# BEMAN_BUILDSYS_SANITIZER: | ||
# This optional CMake parameter is not meant for public use and is subject to | ||
# change. | ||
# Possible values: | ||
# - MaxSan: configures clang and clang++ to use all available non-conflicting | ||
# sanitizers. | ||
# - TSan: configures clang and clang++ to enable the use of thread sanitizer. | ||
|
||
include_guard(GLOBAL) | ||
|
||
set(CMAKE_C_COMPILER clang) | ||
set(CMAKE_CXX_COMPILER clang++) | ||
|
||
if(BEMAN_BUILDSYS_SANITIZER STREQUAL "MaxSan") | ||
set(SANITIZER_FLAGS | ||
"-fsanitize=address -fsanitize=leak -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined" | ||
) | ||
elseif(BEMAN_BUILDSYS_SANITIZER STREQUAL "TSan") | ||
set(SANITIZER_FLAGS "-fsanitize=thread") | ||
endif() | ||
|
||
set(CMAKE_C_FLAGS_DEBUG_INIT "${SANITIZER_FLAGS}") | ||
set(CMAKE_CXX_FLAGS_DEBUG_INIT "${SANITIZER_FLAGS}") | ||
|
||
set(RELEASE_FLAGS "-O3 ${SANITIZER_FLAGS}") | ||
|
||
set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "${RELEASE_FLAGS}") | ||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "${RELEASE_FLAGS}") | ||
|
||
set(CMAKE_C_FLAGS_RELEASE_INIT "${RELEASE_FLAGS}") | ||
set(CMAKE_CXX_FLAGS_RELEASE_INIT "${RELEASE_FLAGS}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
# This toolchain file is not meant to be used directly, | ||
# but to be invoked by CMake preset and GitHub CI. | ||
# | ||
# This toolchain file configures for MSVC family of compiler. | ||
# | ||
# BEMAN_BUILDSYS_SANITIZER: | ||
# This optional CMake parameter is not meant for public use and is subject to | ||
# change. | ||
# Possible values: | ||
# - MaxSan: configures cl to use all available non-conflicting sanitizers. | ||
# | ||
# Note that in other toolchain files, TSan is also a possible value for | ||
# BEMAN_BUILDSYS_SANITIZER, however, MSVC does not support thread sanitizer, | ||
# thus this value is omitted. | ||
|
||
include_guard(GLOBAL) | ||
|
||
set(CMAKE_C_COMPILER cl) | ||
set(CMAKE_CXX_COMPILER cl) | ||
|
||
if(BEMAN_BUILDSYS_SANITIZER STREQUAL "MaxSan") | ||
# /Zi flag (add debug symbol) is needed when using address sanitizer | ||
# See C5072: https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-c5072 | ||
set(SANITIZER_FLAGS "/fsanitize=address /Zi") | ||
endif() | ||
|
||
set(CMAKE_CXX_FLAGS_DEBUG_INIT "/EHsc /permissive- ${SANITIZER_FLAGS}") | ||
set(CMAKE_C_FLAGS_DEBUG_INIT "/EHsc /permissive- ${SANITIZER_FLAGS}") | ||
|
||
set(RELEASE_FLAGS "/EHsc /permissive- /O2 ${SANITIZER_FLAGS}") | ||
|
||
set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "${RELEASE_FLAGS}") | ||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "${RELEASE_FLAGS}") | ||
|
||
set(CMAKE_C_FLAGS_RELEASE_INIT "${RELEASE_FLAGS}") | ||
set(CMAKE_CXX_FLAGS_RELEASE_INIT "${RELEASE_FLAGS}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters