Skip to content

Commit

Permalink
Merge pull request MaJerle#20 from rmspacefish/mueller/added-cmake-su…
Browse files Browse the repository at this point in the history
…pport

Added CMake support
  • Loading branch information
MaJerle committed Mar 5, 2021
2 parents 6fbcf34 + d276f97 commit 3dbfe39
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 3 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
*.uvoptx
*.__i
*.i
*.txt
!docs/*.txt
RTE/

Expand Down
39 changes: 39 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
################################################################################
# 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 set the LWGPS_CONFIG_PATH path variable where
# the configuration file is located so that is is included properly.
#
# 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)

set(LIB_LWGPS_NAME lwgps)

add_library(${LIB_LWGPS_NAME})

add_subdirectory(${LIB_LWGPS_NAME})
add_subdirectory(examples)

# The project CMakeLists can set a LWGPS_CONFIG_PATH path including the lwgps_opts.h file
# and add it.
if(NOT LWGPS_CONFIG_PATH)
message(STATUS "Lightweight GPS configuration path not set.")
endif()

# Extract the absolute path of the provided configuration path
if(IS_ABSOLUTE ${LWGPS_CONFIG_PATH})
set(LWGPS_CONFIG_PATH_ABSOLUTE ${LWGPS_CONFIG_PATH})
else()
get_filename_component(LWGPS_CONFIG_PATH_ABSOLUTE
${LWGPS_CONFIG_PATH} REALPATH BASE_DIR ${CMAKE_SOURCE_DIR}
)
endif()

target_include_directories(${LIB_LWGPS_NAME} PRIVATE
${LWGPS_CONFIG_PATH_ABSOLUTE}
)

18 changes: 16 additions & 2 deletions docs/get-started/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ Update cloned to latest version
This is preferred option to use when you want to evaluate library and run prepared examples.
Repository consists of multiple submodules which can be automatically downloaded when cloning and pulling changes from root repository.

Add library to project
^^^^^^^^^^^^^^^^^^^^^^

Add library to project - Generic
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

At this point it is assumed that you have successfully download library, either cloned it or from releases page.

Expand All @@ -56,6 +57,19 @@ At this point it is assumed that you have successfully download library, either
* Copy ``lwgps/src/include/lwgps/lwgps_opts_template.h`` to project folder and rename it to ``lwgps_opts.h``
* Build the project

Add library to project - CMake
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Including the library with CMake is very easy.

* Add the ``lwgps`` folder with ``add_subdirectory``
* Copy ``lwgps/src/include/lwgps/lwgps_opts_template.h`` to the project folder and rename it
to ``lwgps_opts.h``
* Set the ``LWGPS_CONFIG_PATH`` path variable containing the ``lwgps_opts.h`` file
in the project ``CMakeLists.txt``
* Link your project against the ``lwgps`` library with ``target_link_libraries``
* The include directory should be set automatically by CMake

Configuration file
^^^^^^^^^^^^^^^^^^

Expand Down
Empty file added examples/CMakeLists.txt
Empty file.
1 change: 1 addition & 0 deletions lwgps/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(src)
3 changes: 3 additions & 0 deletions lwgps/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
add_subdirectory(include)
add_subdirectory(lwgps)

7 changes: 7 additions & 0 deletions lwgps/src/include/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
target_include_directories(${LIB_LWGPS_NAME} INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}
)

target_include_directories(${LIB_LWGPS_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
)
3 changes: 3 additions & 0 deletions lwgps/src/include/lwgps/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
target_sources(${LIB_LWGPS_NAME} PRIVATE
lwgps.c
)
3 changes: 3 additions & 0 deletions lwgps/src/lwgps/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
target_sources(${LIB_LWGPS_NAME} PRIVATE
lwgps.c
)

0 comments on commit 3dbfe39

Please sign in to comment.