Skip to content

Commit

Permalink
Merge branch 'cmake' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
MaJerle committed Dec 24, 2021
2 parents f0d0c9c + 8eadd0b commit 00daf58
Show file tree
Hide file tree
Showing 6 changed files with 192 additions and 39 deletions.
57 changes: 36 additions & 21 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,31 @@
*.uvoptx
*.__i
*.i
*.txt
!docs/*.txt
!CMakeLists.txt
RTE/

# IAR Settings
**/settings/*.crun
**/settings/*.dbgdt
**/settings/*.cspy
**/settings/*.cspy.*
**/settings/*.xcl
**/settings/*.dni
**/settings/*.wsdt
**/settings/*.wspos

# IAR Debug Exe
**/Exe/*.sim

# IAR Debug Obj
**/Obj/*.pbd
**/Obj/*.pbd.*
**/Obj/*.pbi
**/Obj/*.pbi.*
*debug

# IAR Settings
**/settings/*.crun
**/settings/*.dbgdt
**/settings/*.cspy
**/settings/*.cspy.*
**/settings/*.xcl
**/settings/*.dni
**/settings/*.wsdt
**/settings/*.wspos

# IAR Debug Exe
**/Exe/*.sim

# IAR Debug Obj
**/Obj/*.pbd
**/Obj/*.pbd.*
**/Obj/*.pbi
**/Obj/*.pbi.*

*.TMP
/docs_src/x_Doxyfile.doxy
Expand All @@ -68,13 +72,15 @@ RTE/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
[Dd]ebug*/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
_build/
build/

# Visual Studio 2015/2017 cache/options directory
.vs/
Expand Down Expand Up @@ -273,7 +279,7 @@ ClientBin/
*.publishsettings
orleans.codegen.cs

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

Expand Down Expand Up @@ -369,7 +375,7 @@ __pycache__/
# OpenCover UI analysis results
OpenCover/

# Azure Stream Analytics local run output
# Azure Stream Analytics local run output
ASALocalRun/

# MSBuild Binary and Structured Log
Expand All @@ -382,4 +388,13 @@ log_file.txt
project.ioc
mx.scratch
*.tilen majerle
*.exe


# Altium
Project outputs*
History/
*.SchDocPreview
*.$$$Preview

# VSCode projects
project_vscode_compiled.exe
24 changes: 24 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"version": 4,
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}\\dev\\VisualStudio\\",
"${workspaceFolder}\\lwgps\\src\\include\\"
],
"defines": [
"WIN32",
"_DEBUG",
"UNICODE",
"_UNICODE",
"LWGPS_DEV"
],
"compilerPath": "c:\\msys64\\mingw64\\bin\\gcc.exe",
"cStandard": "gnu17",
"cppStandard": "gnu++14",
"intelliSenseMode": "windows-gcc-x86",
"configurationProvider": "ms-vscode.cmake-tools"
}
]
}
20 changes: 20 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +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": "(Windows) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}\\build\\LwLibPROJECT.exe",
"miDebuggerPath": "c:\\msys64\\mingw64\\bin\\gdb.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"console": "integratedTerminal"
}
]
}
54 changes: 54 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"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": "cmake",
"args": ["--build", "\"build\""],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": ["$gcc"],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"type": "shell",
"label": "Re-build project",
"command": "cmake",
"args": ["--build", "\"build\"", "--clean-first", "-v"],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": ["$gcc"],
},
{
"type": "shell",
"label": "Clean project",
"command": "cmake",
"args": ["--build", "\"build\"", "--target", "clean"],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": []
},
{
"type": "shell",
"label": "Run application",
"command": "${workspaceFolder}\\build\\LwLibPROJECT.exe",
"args": [],
"problemMatcher": [],
},
]
}
55 changes: 38 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,40 @@
################################################################################
# Lightweight GPS (lwgps) CMake support
################################################################################
# The lwgps library can be configured with a lwgps_opts.h file.
# If such a file is used, the user should have the path containing this file
# in the target include directories in an upper CMakeLists.txt
#
# Other than that, only two steps are necessary to compile and link against LWGPS:
# 1. Use add_subdirectory to add the lwgps folder
# 2. Link against lwgps with target_link_libraries
################################################################################
cmake_minimum_required(VERSION 3.13)
cmake_minimum_required(VERSION 3.0.0)

set(LWGPS_LIB_NAME lwgps)
if(NOT (TARGET ${LWGPS_LIB_NAME}))
add_library(${LWGPS_LIB_NAME} INTERFACE)
target_sources(${LWGPS_LIB_NAME} INTERFACE "lwgps/src/lwgps/lwgps.c")
target_include_directories(${LWGPS_LIB_NAME} INTERFACE "lwgps/src/include")
# Setup project
project(LwLibPROJECT)

# -------------------------------------------------
# This CMakeLists.txt is used only if it is a top-level file.
# Purpose of it is to be able to compile project in standalone way only
#
# When library sources are to be included in another project
# user shall use /lwgps/CMakeLists.txt instead
if (NOT PROJECT_IS_TOP_LEVEL)
message(FATAL_ERROR "This CMakeLists.txt can only be used as top-level. Use /lwgps/CMakeLists.txt for library include purpose")
endif()

# Set as executable
add_executable(${PROJECT_NAME})

# Add key executable block
target_sources(${PROJECT_NAME} PUBLIC
${CMAKE_CURRENT_LIST_DIR}/dev/VisualStudio/main.c
${CMAKE_CURRENT_LIST_DIR}/examples/test_code.c
)

# Add key include paths
target_include_directories(${PROJECT_NAME} PUBLIC
${CMAKE_CURRENT_LIST_DIR}/dev/VisualStudio
)

# Compilation definition information
target_compile_definitions(${PROJECT_NAME} PUBLIC
WIN32
_DEBUG
CONSOLE
LWGPS_DEV
)

# Add subdir with lwgps and link to project
add_subdirectory("lwgps" lwgps)
target_link_libraries(${PROJECT_NAME} lwgps)
21 changes: 20 additions & 1 deletion lwgps/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,20 @@
add_subdirectory(src)
cmake_minimum_required(VERSION 3.13)

# Debug message
message("LWGPS: Entering lib source CMakeLists.txt")

# Set library name
set(LWGPS_LIB_NAME "lwgps")

# Register library to the system
add_library(${LWGPS_LIB_NAME} INTERFACE)

# Setup generic source files
target_sources(${LWGPS_LIB_NAME} INTERFACE
${CMAKE_CURRENT_LIST_DIR}/src/lwgps/lwgps.c
)

# Setup include directories
target_include_directories(${LWGPS_LIB_NAME} INTERFACE
${CMAKE_CURRENT_LIST_DIR}/src/include
)

0 comments on commit 00daf58

Please sign in to comment.