Skip to content

Commit

Permalink
Merge pull request #21 from robamu/mueller/simplified-cmake
Browse files Browse the repository at this point in the history
Simplified CMake handling
  • Loading branch information
MaJerle committed Aug 23, 2021
2 parents 7cbb544 + 52999dd commit 58b49aa
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 43 deletions.
34 changes: 7 additions & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,18 @@
# 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.
# 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)

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.")
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")
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}
)

3 changes: 0 additions & 3 deletions lwgps/src/CMakeLists.txt

This file was deleted.

7 changes: 0 additions & 7 deletions lwgps/src/include/CMakeLists.txt

This file was deleted.

3 changes: 0 additions & 3 deletions lwgps/src/include/lwgps/CMakeLists.txt

This file was deleted.

3 changes: 0 additions & 3 deletions lwgps/src/lwgps/CMakeLists.txt

This file was deleted.

0 comments on commit 58b49aa

Please sign in to comment.