Skip to content

Commit 00956bd

Browse files
committed
Add Cmake support
1 parent 8fc29a0 commit 00956bd

File tree

6 files changed

+167
-21
lines changed

6 files changed

+167
-21
lines changed

.gitignore

+35-20
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,29 @@
2424
*.i
2525
*.txt
2626
!docs/*.txt
27+
!CMakeLists.txt
2728
RTE/
2829

29-
# IAR Settings
30-
**/settings/*.crun
31-
**/settings/*.dbgdt
32-
**/settings/*.cspy
33-
**/settings/*.cspy.*
34-
**/settings/*.xcl
35-
**/settings/*.dni
36-
**/settings/*.wsdt
37-
**/settings/*.wspos
38-
39-
# IAR Debug Exe
40-
**/Exe/*.sim
41-
42-
# IAR Debug Obj
43-
**/Obj/*.pbd
44-
**/Obj/*.pbd.*
45-
**/Obj/*.pbi
46-
**/Obj/*.pbi.*
30+
*debug
31+
32+
# IAR Settings
33+
**/settings/*.crun
34+
**/settings/*.dbgdt
35+
**/settings/*.cspy
36+
**/settings/*.cspy.*
37+
**/settings/*.xcl
38+
**/settings/*.dni
39+
**/settings/*.wsdt
40+
**/settings/*.wspos
41+
42+
# IAR Debug Exe
43+
**/Exe/*.sim
44+
45+
# IAR Debug Obj
46+
**/Obj/*.pbd
47+
**/Obj/*.pbd.*
48+
**/Obj/*.pbi
49+
**/Obj/*.pbi.*
4750

4851
*.TMP
4952
/docs_src/x_Doxyfile.doxy
@@ -69,13 +72,15 @@ RTE/
6972
[Dd]ebugPublic/
7073
[Rr]elease/
7174
[Rr]eleases/
75+
[Dd]ebug*/
7276
x64/
7377
x86/
7478
bld/
7579
[Bb]in/
7680
[Oo]bj/
7781
[Ll]og/
7882
_build/
83+
build/
7984

8085
# Visual Studio 2015/2017 cache/options directory
8186
.vs/
@@ -274,7 +279,7 @@ ClientBin/
274279
*.publishsettings
275280
orleans.codegen.cs
276281

277-
# Including strong name files can present a security risk
282+
# Including strong name files can present a security risk
278283
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
279284
#*.snk
280285

@@ -370,7 +375,7 @@ __pycache__/
370375
# OpenCover UI analysis results
371376
OpenCover/
372377

373-
# Azure Stream Analytics local run output
378+
# Azure Stream Analytics local run output
374379
ASALocalRun/
375380

376381
# MSBuild Binary and Structured Log
@@ -383,3 +388,13 @@ log_file.txt
383388
project.ioc
384389
mx.scratch
385390
*.tilen majerle
391+
392+
393+
# Altium
394+
Project outputs*
395+
History/
396+
*.SchDocPreview
397+
*.$$$Preview
398+
399+
# VSCode projects
400+
project_vscode_compiled.exe

.vscode/c_cpp_properties.json

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"version": 4,
3+
"configurations": [
4+
{
5+
"name": "Win32",
6+
"includePath": [
7+
"${workspaceFolder}\\dev\\VisualStudio\\",
8+
"${workspaceFolder}\\lwmem\\src\\include\\"
9+
],
10+
"defines": [
11+
"WIN32",
12+
"_DEBUG",
13+
"UNICODE",
14+
"_UNICODE",
15+
"LWMEM_DEV"
16+
],
17+
"compilerPath": "c:\\msys64\\mingw64\\bin\\gcc.exe",
18+
"cStandard": "gnu17",
19+
"cppStandard": "gnu++14",
20+
"intelliSenseMode": "windows-gcc-x86",
21+
"configurationProvider": "ms-vscode.cmake-tools"
22+
}
23+
]
24+
}

.vscode/launch.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "(Windows) Launch",
9+
"type": "cppvsdbg",
10+
"request": "launch",
11+
"program": "${workspaceFolder}\\build\\LwPRINTF.exe",
12+
"miDebuggerPath": "c:\\msys64\\mingw64\\bin\\gdb.exe",
13+
"args": [],
14+
"stopAtEntry": false,
15+
"cwd": "${fileDirname}",
16+
"environment": [],
17+
"console": "integratedTerminal"
18+
}
19+
]
20+
}

.vscode/tasks.json

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"version": "2.0.0",
3+
4+
/* For this builds, you need
5+
*
6+
* - Ninja build system
7+
* - MSYS2 compiler with ninja support
8+
* - C/C++ extension for VSCode
9+
* - CMake-Tools extension for VSCode
10+
*/
11+
"tasks": [
12+
{
13+
"type": "cppbuild",
14+
"label": "Build project",
15+
"command": "cmake",
16+
"args": [
17+
"--build",
18+
"\"build\""
19+
],
20+
"options": {
21+
"cwd": "${workspaceFolder}"
22+
},
23+
"problemMatcher": [
24+
"$gcc"
25+
],
26+
"group": {
27+
"kind": "build",
28+
"isDefault": true
29+
}
30+
},
31+
{
32+
"type": "shell",
33+
"label": "Clean project",
34+
"command": "cmake",
35+
"args": [
36+
"--build",
37+
"\"build\"",
38+
"--target",
39+
"clean"
40+
],
41+
"options": {
42+
"cwd": "${workspaceFolder}"
43+
},
44+
"problemMatcher": []
45+
},
46+
{
47+
"type": "shell",
48+
"label": "Run application",
49+
"command": "${workspaceFolder}\\build\\LwMEM.exe",
50+
"args": [],
51+
"problemMatcher": [],
52+
},
53+
]
54+
}

CMakeLists.txt

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
cmake_minimum_required(VERSION 3.0.0)
2+
project(LwMEM VERSION 0.1.0)
3+
4+
include(CTest)
5+
enable_testing()
6+
7+
add_executable(${PROJECT_NAME}
8+
lwmem/src/lwmem/lwmem.c
9+
lwmem/src/system/lwmem_sys_win32.c
10+
tests/lwmem_test.c
11+
dev/VisualStudio/main.c
12+
)
13+
14+
target_include_directories(${PROJECT_NAME} PRIVATE
15+
dev/VisualStudio
16+
lwmem/src/include
17+
)
18+
19+
target_compile_definitions(${PROJECT_NAME} PRIVATE
20+
WIN32
21+
_DEBUG
22+
CONSOLE
23+
LWMEM_DEV
24+
)
25+
26+
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
27+
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
28+
include(CPack)

tests/lwmem_test.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "lwmem/lwmem.h"
2+
#include <stdio.h>
23

34
/* Assert check */
45
#define ASSERT(x) do { \
@@ -11,7 +12,11 @@
1112

1213
/********************************************/
1314
/* Test case helpers */
14-
#define IS_ALLOC_IN_REGION(ptr, region) ASSERT((unsigned char *)(ptr) >= (region)->start_addr && (unsigned char *)(ptr) < ((unsigned char *)(region)->start_addr + (region)->size))
15+
#define UINT_PTR_CAST(x) ((uintptr_t)(x))
16+
#define IS_ALLOC_IN_REGION(ptr, region) ASSERT( \
17+
UINT_PTR_CAST(ptr) >= UINT_PTR_CAST((region)->start_addr) \
18+
&& UINT_PTR_CAST(ptr) < (UINT_PTR_CAST((region)->start_addr) + (region)->size) \
19+
)
1520

1621
/********************************************/
1722
/* Configuration for default lwmem instance */

0 commit comments

Comments
 (0)