diff --git a/CMakeLists.txt b/CMakeLists.txt index c340134..f3f59f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 @@ -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 + $ + $) + +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}) #------------------------------------------------------------------------------- \ No newline at end of file diff --git a/README.md b/README.md index fa117b3..6a74695 100644 --- a/README.md +++ b/README.md @@ -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.