Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/cmake easier ext inclusion #53

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ endforeach()
# message(STATUS ${HEADERS})

add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS})
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})

#----------------
# Compiler flags
Expand All @@ -101,15 +102,35 @@ if(MSVC OR WIN32)
endif()
endif()

set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${VERSION})
set_target_properties(${PROJECT_NAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${DIST_PATH}/${CMAKE_BUILD_TYPE})
set_target_properties(${PROJECT_NAME} PROPERTIES
VERSION ${VERSION}
EXPORT_NAME ${PROJECT_NAME}
OUTPUT_NAME ${PROJECT_NAME}
ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${DIST_PATH}/${CMAKE_BUILD_TYPE})
message(STATUS "Output Dir: ${PROJECT_BINARY_DIR}/${DIST_PATH}/${CMAKE_BUILD_TYPE}")

# Configure include directories
target_include_directories(${PROJECT_NAME} INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set_property(TARGET ${PROJECT_NAME} PROPERTY INSTALL_RPATH $ORIGIN)
elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR CMAKE_SYSTEM_NAME STREQUAL "iOS")
set_property(TARGET ${PROJECT_NAME} PROPERTY INSTALL_RPATH @loader_path)
endif()

#----------------
# Install
#----------------

message(STATUS "CMAKE_INSTALL_PREFIX='${CMAKE_INSTALL_PREFIX}'")
install(TARGETS ${PROJECT_NAME} DESTINATION ${DIST_PATH}/${CMAKE_BUILD_TYPE})
install(TARGETS ${PROJECT_NAME} DESTINATION "${PROJECT_BINARY_DIR}/${DIST_PATH}/${CMAKE_BUILD_TYPE}")

install(
TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

#-------------------------------------------------------------------------------
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ dist/

```

### CMake
For cross-platform inclusion of this SDK via cmake just clone thie repository and include the folder as a subdirectory to the parent project and apply the appropriate target links similar to below:
```
# Adds Metawear SDK as a dependency
message(STATUS "Device: Adding Metawear SDK Support")
add_subdirectory(MetaWear-SDK-Cpp)
target_include_directories(${PROJECT_NAME} PRIVATE MetaWear-SDK-Cpp/src)
target_link_libraries(${PROJECT_NAME} PUBLIC metawear metawear::metawear)
```

## Testing
Unit tests for the library are written in Python (min v3.4.1) and can be invoked by calling the test target.

Expand Down