Skip to content

Commit

Permalink
build: cmake presets use variable-based paths
Browse files Browse the repository at this point in the history
Variable-based paths make results more replicable by users. This commit also sets the preset version to 3, as it's the highest version supported by the build process, which relies on CMake 3.22 from Ubuntu 22.04.
  • Loading branch information
alandefreitas committed Nov 6, 2023
1 parent d5081bc commit 9412a8c
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 35 deletions.
16 changes: 9 additions & 7 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": 5,
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 10,
Expand All @@ -10,8 +10,7 @@
"name": "debug",
"displayName": "Debug-Base",
"description": "Debug Config including tests.",
"binaryDir": "${sourceDir}/build/debug",
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_CXX_STANDARD": "20",
Expand All @@ -23,7 +22,10 @@
},
"vendor": {
"microsoft.com/VisualStudioSettings/CMake/1.0": {
"hostOS": [ "Linux", "macOS" ],
"hostOS": [
"Linux",
"macOS"
],
"intelliSenseMode": "windows-msvc-x64"
}
}
Expand All @@ -33,7 +35,7 @@
"inherits": "debug",
"displayName": "Release-Base",
"description": "Release Config including tests.",
"binaryDir": "${sourceDir}/build/release",
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
Expand All @@ -43,7 +45,7 @@
"inherits": "release",
"displayName": "RelWithDebInfo-Base",
"description": "RelWithDebInfo Config including tests.",
"binaryDir": "${sourceDir}/build/relwithdebinfo",
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
Expand All @@ -53,7 +55,7 @@
"inherits": "release",
"displayName": "Distribution-Base",
"description": "Release Config without Tests.",
"binaryDir": "${sourceDir}/build/dist",
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"MRDOCS_BUILD_TESTS": "OFF"
}
Expand Down
102 changes: 74 additions & 28 deletions CMakeUserPresets.json.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": 5,
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 10,
Expand All @@ -9,14 +9,14 @@
{
"name": "Debug-MSVC",
"inherits": "debug",
"generator": "Visual Studio 17 2022",
"architecture": "x64",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/debug-msvc",
"toolchainFile": "C:\\source\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake",
"toolchainFile": "C:\\Users\\$env{USERNAME}\\Libraries\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake",
"cacheVariables": {
"LLVM_ROOT": "C:\\source\\llvm+clang\\Debug",
"Clang_ROOT": "C:\\source\\llvm+clang\\Debug",
"DUKTAPE_SOURCE_ROOT": "C:\\source\\duktape-2.7.0"
"LLVM_ROOT": "C:\\Users\\$env{USERNAME}\\Libraries\\llvm-project\\llvm\\install\\MSVC\\Debug",
"Clang_ROOT": "C:\\Users\\$env{USERNAME}\\Libraries\\llvm-project\\llvm\\install\\MSVC\\Debug",
"DUKTAPE_SOURCE_ROOT": "C:\\Users\\$env{USERNAME}\\Libraries\\duktape-2.7.0",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
},
"condition": {
"type": "equals",
Expand All @@ -25,7 +25,9 @@
},
"vendor": {
"microsoft.com/VisualStudioSettings/CMake/1.0": {
"hostOS": [ "Windows" ],
"hostOS": [
"Windows"
],
"intelliSenseMode": "windows-msvc-x64"
}
}
Expand All @@ -35,8 +37,8 @@
"inherits": "Debug-MSVC",
"binaryDir": "${sourceDir}/build/debwithopt-msvc",
"cacheVariables": {
"LLVM_ROOT": "C:\\source\\llvm+clang\\DebWithOpt",
"Clang_ROOT": "C:\\source\\llvm+clang\\DebWithOpt"
"LLVM_ROOT": "C:\\Users\\$env{USERNAME}\\Libraries\\llvm-project\\llvm\\install\\MSVC\\DebWithOpt",
"Clang_ROOT": "C:\\Users\\$env{USERNAME}\\Libraries\\llvm-project\\llvm\\install\\MSVC\\DebWithOpt"
}
},
{
Expand All @@ -45,8 +47,8 @@
"binaryDir": "${sourceDir}/build/release-msvc",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"LLVM_ROOT": "C:\\source\\llvm+clang\\Release",
"Clang_ROOT": "C:\\source\\llvm+clang\\Release"
"LLVM_ROOT": "C:\\Users\\$env{USERNAME}\\Libraries\\llvm-project\\llvm\\install\\MSVC\\Release",
"Clang_ROOT": "C:\\Users\\$env{USERNAME}\\Libraries\\llvm-project\\llvm\\install\\MSVC\\Release"
}
},
{
Expand All @@ -55,41 +57,85 @@
"binaryDir": "${sourceDir}/build/relwithdebinfo-msvc",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"LLVM_ROOT": "C:\\source\\llvm+clang\\RelWithDebInfo",
"Clang_ROOT": "C:\\source\\llvm+clang\\RelWithDebInfo"
"LLVM_ROOT": "C:\\Users\\$env{USERNAME}\\Libraries\\llvm-project\\llvm\\install\\MSVC\\RelWithDebInfo",
"Clang_ROOT": "C:\\Users\\$env{USERNAME}\\Libraries\\llvm-project\\llvm\\install\\MSVC\\RelWithDebInfo"
}
},
{
"name": "Debug-GCC",
"inherits": "debug",
"binaryDir": "${sourceDir}/build/debug-gcc",
"toolchainFile": "/home/$env{USER}/vcpkg/scripts/buildsystems/vcpkg.cmake",
"toolchainFile": "/home/$env{USER}/libraries/vcpkg/scripts/buildsystems/vcpkg.cmake",
"cacheVariables": {
"CMAKE_CXX_COMPILER": "g++",
"CMAKE_C_COMPILER": "gcc",
"LLVM_ROOT": "/usr/local/llvm+clang",
"Clang_ROOT": "/usr/local/llvm+clang",
"DUKTAPE_SOURCE_ROOT": "/home/$env{USER}/source/duktape/duktape-2.7.0"
},
"condition": {
"type": "notEquals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
"CMAKE_CXX_COMPILER": "/usr/bin/g++-13",
"CMAKE_C_COMPILER": "/usr/bin/gcc-13",
"LLVM_ROOT": "/home/$env{USER}/libraries/llvm-project/llvm/install/Linux/Release",
"Clang_ROOT": "/home/$env{USER}/libraries/llvm-project/llvm/install/Linux/Release",
"DUKTAPE_SOURCE_ROOT": "/home/$env{USER}/libraries/duktape-2.7.0",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
},
"vendor": {
"microsoft.com/VisualStudioSettings/CMake/1.0": {
"hostOS": ["Linux"],
"hostOS": [
"Linux"
],
"intelliSenseMode": "windows-msvc-x64"
},
"jetbrains.com/clion": {
"toolchain": "WSL GCC"
}
}
},
{
"name": "Debug-GCC-Asan",
"inherits": "Debug-GCC",
"binaryDir": "${sourceDir}/build/debug-gcc-asan",
"cacheVariables": {
"CMAKE_CXX_FLAGS": "-fsanitize=address -fno-omit-frame-pointer -g -O0 -fno-inline-functions"
}
},
{
"name": "DebWithOpt-GCC",
"inherits": "Debug-GCC",
"binaryDir": "${sourceDir}/build/debwithopt-gcc",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"LLVM_ROOT": "/home/$env{USER}/libraries/llvm-project/llvm/install/Linux/Release",
"Clang_ROOT": "/home/$env{USER}/libraries/llvm-project/llvm/install/Linux/Release"
}
},
{
"name": "Release-GCC",
"inherits": "Debug-GCC",
"binaryDir": "${sourceDir}/build/release-gcc",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"LLVM_ROOT": "/home/$env{USER}/libraries/llvm-project/llvm/install/Linux/Release",
"Clang_ROOT": "/home/$env{USER}/libraries/llvm-project/llvm/install/Linux/Release"
}
},
{
"name": "RelWithDebInfo-GCC",
"inherits": "Debug-GCC",
"binaryDir": "${sourceDir}/build/relwithdebinfo-gcc",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"LLVM_ROOT": "/home/$env{USER}/libraries/llvm-project/llvm/install/Linux/Release",
"Clang_ROOT": "/home/$env{USER}/libraries/llvm-project/llvm/install/Linux/Release"
}
},
{
"name": "Debug-Clang",
"inherits": "Debug-GCC",
"binaryDir": "${sourceDir}/build/debug-clang",
"cacheVariables": {
"CMAKE_CXX_COMPILER": "clang++",
"CMAKE_C_COMPILER": "clang"
"CMAKE_CXX_COMPILER": "/usr/bin/clang++-16",
"CMAKE_C_COMPILER": "/usr/bin/clang-16"
},
"vendor": {
"jetbrains.com/clion": {
"toolchain": "WSL Clang"
}
}
}
]
Expand Down

0 comments on commit 9412a8c

Please sign in to comment.