Skip to content

Commit

Permalink
Merge pull request #5 from SergeyLadanov/presets
Browse files Browse the repository at this point in the history
Presets
  • Loading branch information
SergeyLadanov authored Jun 25, 2024
2 parents b859a83 + 2f7fe88 commit bb4b4db
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 68 deletions.
1 change: 0 additions & 1 deletion .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"${default}",
"${workspaceFolder}/**"
],
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu17",
"cppStandard": "gnu++14",
"intelliSenseMode": "linux-gcc-x64",
Expand Down
13 changes: 13 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"recommendations": [
"ms-python.debugpy",
"akiramiyakoda.cppincludeguard",
"ms-python.python",
"ms-python.vscode-pylance",
"ms-vscode.cmake-tools",
"ms-vscode.cpptools",
"ms-vscode.cpptools-extension-pack",
"ms-vscode.cpptools-themes",
"twxs.cmake"
]
}
6 changes: 3 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"name": "g++.exe - Сборка и отладка активного файла",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/Template",
"program": "${command:cmake.launchTargetPath}",
"args": [],
"stopAtEntry": false,
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
Expand All @@ -23,7 +23,7 @@
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: Сборка проекта"
"preLaunchTask": "Build active preset"
}
]
}
119 changes: 55 additions & 64 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,103 +1,94 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "cmake",
"label": "Build active preset",
"command": "build",
"targets": [
"all"
],
"preset": "${command:cmake.activeBuildPresetName}",
"group": {
"kind": "build",
"isDefault": false
},
"problemMatcher": [],
"detail": "CMake template build task",
},
{
"type": "shell",
"label": "C/C++: Сборка проекта",
"label": "Конфигурация Debug",
"command": "",
"args": [
"cmake",
"--build",
"./build",
"-j4"
"--preset",
"Debug"
],
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Компилятор: \"g++.exe\""
},
{
"type": "shell",
"label": "Конфигурация Debug",
"label": "Конфигурация Release",
"command": "",
"windows":{
"args": [
"cmake",
".",
"-G",
"MinGW Makefiles",
"-B",
"build",
"-D",
"CMAKE_BUILD_TYPE=DEBUG"
],
},

"linux":{
"args": [
"cmake",
".",
"-G",
"Unix Makefiles",
"-B",
"build",
"-D",
"CMAKE_BUILD_TYPE=DEBUG"
],
},
"args": [
"cmake",
"--preset",
"Release",
],

"problemMatcher": [
"$gcc"
],
"detail": "Компилятор: \"g++.exe\""
},

{
"type": "shell",
"label": "Конфигурация Release",
"label": "C/C++: Сборка Debug",
"command": "",
"windows":{
"args": [
"cmake",
".",
"-G",
"MinGW Makefiles",
"-B",
"build",
"-D",
"CMAKE_BUILD_TYPE=RELEASE"
],
},

"linux":{
"args": [
"cmake",
".",
"-G",
"Unix Makefiles",
"-B",
"build",
"-D",
"CMAKE_BUILD_TYPE=RELEASE"
],
},

"args": [
"cmake",
"--build",
"--preset",
"Debug",
"-j4"
],
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Компилятор: \"g++.exe\""
},
{
"type": "cmake",
"label": "Clean active preset",
"command": "build",
"targets": [
"clean"
],
"preset": "${command:cmake.activeBuildPresetName}",
"group": {
"kind": "build",
},
"problemMatcher": [],
"detail": "CMake template build task",
},
{
"type": "shell",
"label": "C/C++: Clean",
"label": "C/C++: Clean Debug",
"command": "",
"args": [
"cmake",
"--build",
"./build",
"--preset",
"Debug",
"--target",
"clean"

Expand All @@ -109,4 +100,4 @@
"detail": "Очистка выходных файлов"
}
]
}
}
41 changes: 41 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"version": 3,
"configurePresets": [
{
"name": "default",
"hidden": true,
"description": "Using compilers: C = gcc, CXX = g++",
"generator": "Unix Makefiles",
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"CMAKE_C_COMPILER": "gcc",
"CMAKE_CXX_COMPILER": "g++",
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "Debug",
"inherits": "default",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "Release",
"inherits": "default",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
}
],
"buildPresets": [
{
"name": "Debug",
"configurePreset": "Debug"
},
{
"name": "Release",
"configurePreset": "Release"
}
]
}
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Cmake_Template
Шаблон проекта C/C++ для Cmake

# Установка компонентов
1. CMake: https://cmake.org/;
2. make
```
winget install ezwinports.make
```
3. Компилятор: https://github.com/niXman/mingw-builds-binaries/releases

# Описание
Шаблон предоставляет возможность организовать модульную структуру проекта C/C++. Весь функционал для организации модульной структуры содержится в файле common-tools.cmake. В папку Components необходимо добавить файлы библиотек/модулей (с отдельным файлом CMakeLists.txt), заголовочные файлы которых будут доступны в главном приложении, сами библиотеки/модули будут собираться независимо. Между компонентами есть возможность выстраивать зависимости (задействовать заголовочные файлы из указанного компонента) с помощью директивы Depends_On в файле СMakeLists.txt компонента:

Expand Down

0 comments on commit bb4b4db

Please sign in to comment.