Skip to content

Commit

Permalink
Add VScode + CMake support
Browse files Browse the repository at this point in the history
  • Loading branch information
MaJerle committed Dec 12, 2021
1 parent 29d10d9 commit 20a714a
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 45 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*.i
*.txt
!docs/*.txt
!CMakeLists.txt
RTE/

*debug
Expand Down Expand Up @@ -79,6 +80,7 @@ bld/
[Oo]bj/
[Ll]og/
_build/
build/

# Visual Studio 2015/2017 cache/options directory
.vs/
Expand Down
39 changes: 16 additions & 23 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

{
"name": "Debug program",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}\\project_vscode_compiled.exe",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "c:\\msys64\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "Build project"
}
{
"name": "(Windows) Launch",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}\\build\\LwPRINTF.exe",
"miDebuggerPath": "c:\\msys64\\mingw64\\bin\\gdb.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"console": "integratedTerminal"
}
]
}
}
49 changes: 27 additions & 22 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,21 @@
{
"version": "2.0.0",

/* For this builds, you need
*
* - Ninja build system
* - MSYS2 compiler with ninja support
* - C/C++ extension for VSCode
* - CMake-Tools extension for VSCode
*/
"tasks": [
{
"type": "cppbuild",
"label": "Build project",
"command": "gcc",
"command": "cmake",
"args": [
// Precompiled headers
"-DWIN32",
"-D_DEBUG",
"-DUNICODE",
"-D_UNICODE",
"-DLWPRINTF_DEV",

// Source files
"-g",
"${workspaceFolder}\\dev\\VisualStudio\\main.c",
"${workspaceFolder}\\lwprintf\\src\\lwprintf\\lwprintf.c",
"${workspaceFolder}\\lwprintf\\src\\system\\lwprintf_sys_win32.c",

// Include paths
"-I${workspaceFolder}\\dev\\VisualStudio\\",
"-I${workspaceFolder}\\lwprintf\\src\\include\\",

// Output object
"-o",
"${workspaceFolder}\\project_vscode_compiled.exe"
"--build",
"\"build\""
],
"options": {
"cwd": "${workspaceFolder}"
Expand All @@ -38,10 +28,25 @@
"isDefault": true
}
},
{
"type": "shell",
"label": "Clean project",
"command": "cmake",
"args": [
"--build",
"\"build\"",
"--target",
"clean"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": []
},
{
"type": "shell",
"label": "Run application",
"command": "${workspaceFolder}\\project_vscode_compiled.exe",
"command": "${workspaceFolder}\\build\\LwPRINTF.exe",
"args": [],
"problemMatcher": [],
},
Expand Down
27 changes: 27 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
cmake_minimum_required(VERSION 3.0.0)
project(LwPRINTF VERSION 0.1.0)

include(CTest)
enable_testing()

add_executable(${PROJECT_NAME}
lwprintf/src/lwprintf/lwprintf.c
lwprintf/src/system/lwprintf_sys_win32.c
dev/VisualStudio/main.c
)

target_include_directories(${PROJECT_NAME} PRIVATE
dev/VisualStudio
lwprintf/src/include
)

target_compile_definitions(${PROJECT_NAME} PRIVATE
WIN32
_DEBUG
CONSOLE
TEST_CONSOLE_123
)

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)

0 comments on commit 20a714a

Please sign in to comment.