[c][cpp] Use CMake presets and Ninja as the default generator

This commit is contained in:
Mario Zechner 2025-07-15 11:34:11 +02:00
parent 557465ed01
commit 84a541b098
5 changed files with 74 additions and 8 deletions

View File

@ -34,8 +34,6 @@ target_include_directories(spine-c PUBLIC
../spine-cpp/spine-cpp/include ../spine-cpp/spine-cpp/include
) )
# Export compile commands for better IDE support
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Create test executable only if this is the top-level project # Create test executable only if this is the top-level project
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)

35
spine-c/CMakePresets.json Normal file
View File

@ -0,0 +1,35 @@
{
"version": 3,
"configurePresets": [
{
"name": "debug",
"displayName": "Debug Config",
"description": "Debug build using Ninja generator",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
}
},
{
"name": "release",
"inherits": "debug",
"displayName": "Release Config",
"description": "Release build using Ninja generator",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
}
],
"buildPresets": [
{
"name": "debug",
"configurePreset": "debug"
},
{
"name": "release",
"configurePreset": "release"
}
]
}

View File

@ -15,6 +15,5 @@ if [ "$1" = "clean" ]; then
fi fi
# Always build # Always build
mkdir -p build && cd build cmake --preset=debug .
[ -f CMakeCache.txt ] || cmake .. -DCMAKE_BUILD_TYPE=Debug cmake --build --preset=debug
make -j$(sysctl -n hw.ncpu 2>/dev/null || nproc 2>/dev/null || echo 4)

View File

@ -0,0 +1,35 @@
{
"version": 3,
"configurePresets": [
{
"name": "debug",
"displayName": "Debug Config",
"description": "Debug build using Ninja generator",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
}
},
{
"name": "release",
"inherits": "debug",
"displayName": "Release Config",
"description": "Release build using Ninja generator",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
}
],
"buildPresets": [
{
"name": "debug",
"configurePreset": "debug"
},
{
"name": "release",
"configurePreset": "release"
}
]
}

View File

@ -9,6 +9,5 @@ if [ "$1" = "clean" ]; then
fi fi
# Always build # Always build
mkdir -p build && cd build cmake --preset=debug .
[ -f CMakeCache.txt ] || cmake .. -DCMAKE_BUILD_TYPE=Debug cmake --build --preset=debug
make -j$(sysctl -n hw.ncpu 2>/dev/null || nproc 2>/dev/null || echo 4)