| From d49e5ea2988b2086c7deaa40d3e077531e449844 Mon Sep 17 00:00:00 2001 |
| From: Xue Liu <liuxuenetmail@gmail.com> |
| Date: Thu, 21 Feb 2019 00:27:42 +0100 |
| Subject: [PATCH 1/3] - add cmake support |
| |
| Signed-off-by: Xue Liu <liuxuenetmail@gmail.com> |
| --- |
| CMakeLists.txt | 77 +++++++++++++++ |
| cmake/loragw-config.cmake | 1 + |
| libloragw/CMakeLists.txt | 150 ++++++++++++++++++++++++++++++ |
| libloragw/loragw.pc.in | 10 ++ |
| libloragw/loragw_config.h.in | 14 +++ |
| util_lbt_test/CMakeLists.txt | 23 +++++ |
| util_pkt_logger/CMakeLists.txt | 29 ++++++ |
| util_spectral_scan/CMakeLists.txt | 23 +++++ |
| util_spi_stress/CMakeLists.txt | 23 +++++ |
| util_tx_continuous/CMakeLists.txt | 23 +++++ |
| util_tx_test/CMakeLists.txt | 23 +++++ |
| 11 files changed, 396 insertions(+) |
| create mode 100644 CMakeLists.txt |
| create mode 100644 cmake/loragw-config.cmake |
| create mode 100644 libloragw/CMakeLists.txt |
| create mode 100644 libloragw/loragw.pc.in |
| create mode 100644 libloragw/loragw_config.h.in |
| create mode 100644 util_lbt_test/CMakeLists.txt |
| create mode 100644 util_pkt_logger/CMakeLists.txt |
| create mode 100644 util_spectral_scan/CMakeLists.txt |
| create mode 100644 util_spi_stress/CMakeLists.txt |
| create mode 100644 util_tx_continuous/CMakeLists.txt |
| create mode 100644 util_tx_test/CMakeLists.txt |
| |
| --- /dev/null |
| +++ b/CMakeLists.txt |
| @@ -0,0 +1,77 @@ |
| +# -- Minimum required version |
| +cmake_minimum_required (VERSION 3.2) |
| + |
| +# -- Project name |
| +project (lora_gateway) |
| + |
| +# -- Various includes |
| +include (CMakePackageConfigHelpers) |
| +include (GNUInstallDirs) |
| +include (CheckFunctionExists) |
| + |
| +# -- set c99 standard default |
| +set(CMAKE_C_STANDARD 99) |
| + |
| +# -- options for shared lib (defaults off) |
| +option(lora_gateway_build_shared_libs "build as a shared library" OFF) |
| +set(BUILD_SHARED_LIBS ${lora_gateway_build_shared_libs}) |
| + |
| +# -- Required to build |
| +set(CMAKE_THREAD_PREFER_PTHREAD TRUE) |
| +set(THREADS_PREFER_PTHREAD_FLAG TRUE) |
| +find_package(Threads REQUIRED) |
| + |
| +# -- Versioning with git tag |
| +if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git) |
| + execute_process( |
| + COMMAND git describe --tags --always |
| + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" |
| + OUTPUT_VARIABLE "lora_gateway_VERSION" |
| + ERROR_QUIET |
| + OUTPUT_STRIP_TRAILING_WHITESPACE) |
| + if(lora_gateway_VERSION STREQUAL "") |
| + set(lora_gateway_VERSION 0) |
| + endif(lora_gateway_VERSION STREQUAL "") |
| + message( STATUS "Git full version: ${lora_gateway_VERSION}" ) |
| + execute_process( |
| + COMMAND /bin/bash -c "git describe --tags --abbrev=0 | cut --delimiter='v' --fields=2" |
| + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" |
| + OUTPUT_VARIABLE "lora_gateway_VERSION_SHORT" |
| + ERROR_QUIET |
| + OUTPUT_STRIP_TRAILING_WHITESPACE) |
| + if(lora_gateway_VERSION_SHORT STREQUAL "") |
| + set(lora_gateway_VERSION_SHORT 0) |
| + endif(lora_gateway_VERSION_SHORT STREQUAL "") |
| + message( STATUS "Git version: ${lora_gateway_VERSION_SHORT}" ) |
| +else(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git) |
| + set(lora_gateway_VERSION_SHORT 0) |
| + set(lora_gateway_VERSION 0) |
| +endif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git) |
| + |
| +# when building, don't use the install RPATH already |
| +# (but later on when installing) |
| +SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) |
| +if (NOT (${CMAKE_INSTALL_PREFIX} STREQUAL "/usr" ) ) |
| + SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") |
| +endif() |
| + |
| +# -- add the core library |
| +add_subdirectory(libloragw) |
| + |
| +# -- add util_lbt_test |
| +add_subdirectory(util_lbt_test) |
| + |
| +# -- add util_pkt_logger |
| +add_subdirectory(util_pkt_logger) |
| + |
| +# -- add util_pkt_logger |
| +add_subdirectory(util_spectral_scan) |
| + |
| +# -- add util_spi_stress |
| +add_subdirectory(util_spi_stress) |
| + |
| +# -- add util_tx_continuous |
| +add_subdirectory(util_tx_continuous) |
| + |
| +# -- add util_tx_test |
| +add_subdirectory(util_tx_test) |
| --- /dev/null |
| +++ b/cmake/loragw-config.cmake |
| @@ -0,0 +1 @@ |
| +include("${CMAKE_CURRENT_LIST_DIR}/loragw-targets.cmake") |
| --- /dev/null |
| +++ b/libloragw/CMakeLists.txt |
| @@ -0,0 +1,150 @@ |
| +set(TARGET loragw) |
| + |
| +add_library(${TARGET} "") |
| + |
| +# -- add additional debug options |
| +# Set the DEBUG_* to 1 to activate debug mode in individual modules. |
| +# Warning: that makes the module *very verbose*, do not use for production |
| +option(DEBUG_AUX "Active debug mode in AUX module" OFF) |
| +option(DEBUG_SPI "Active debug mode in SPI module" OFF) |
| +option(DEBUG_REG "Active debug mode in REG module" OFF) |
| +option(DEBUG_HAL "Active debug mode in HAL module" OFF) |
| +option(DEBUG_GPIO "Active debug mode in GPIO module" OFF) |
| +option(DEBUG_LBT "Active debug mode in LBT module" OFF) |
| +option(DEBUG_GPS "Active debug mode in GPS module" OFF) |
| + |
| +message("-- Build with debug AUX: ${DEBUG_AUX}") |
| +message("-- Build with debug SPI: ${DEBUG_SPI}") |
| +message("-- Build with debug REG: ${DEBUG_REG}") |
| +message("-- Build with debug HAL: ${DEBUG_HAL}") |
| +message("-- Build with debug GPIO: ${DEBUG_GPIO}") |
| +message("-- Build with debug LBT: ${DEBUG_LBT}") |
| +message("-- Build with debug GPS: ${DEBUG_GPS}") |
| + |
| +# -- add the compile options |
| +target_compile_options( |
| + ${TARGET} |
| + PRIVATE |
| + -Werror |
| + -Wall |
| + -Wextra |
| +) |
| + |
| +target_sources(${TARGET} |
| + PRIVATE |
| + ${CMAKE_CURRENT_LIST_DIR}/src/loragw_aux.c |
| + ${CMAKE_CURRENT_LIST_DIR}/src/loragw_fpga.c |
| + ${CMAKE_CURRENT_LIST_DIR}/src/loragw_gps.c |
| + ${CMAKE_CURRENT_LIST_DIR}/src/loragw_hal.c |
| + ${CMAKE_CURRENT_LIST_DIR}/src/loragw_lbt.c |
| + ${CMAKE_CURRENT_LIST_DIR}/src/loragw_radio.c |
| + ${CMAKE_CURRENT_LIST_DIR}/src/loragw_reg.c |
| + ${CMAKE_CURRENT_LIST_DIR}/src/loragw_spi.native.c |
| +) |
| + |
| +# -- add the public headers |
| +set (${TARGET}_PUBLIC_HEADERS |
| + ${CMAKE_CURRENT_LIST_DIR}/inc/loragw_aux.h |
| + ${CMAKE_CURRENT_LIST_DIR}/inc/loragw_fpga.h |
| + ${CMAKE_CURRENT_LIST_DIR}/inc/loragw_gps.h |
| + ${CMAKE_CURRENT_LIST_DIR}/inc/loragw_hal.h |
| + ${CMAKE_CURRENT_LIST_DIR}/inc/loragw_lbt.h |
| + ${CMAKE_CURRENT_LIST_DIR}/inc/loragw_radio.h |
| + ${CMAKE_CURRENT_LIST_DIR}/inc/loragw_reg.h |
| +) |
| + |
| +target_include_directories(${TARGET} |
| + PRIVATE |
| + ${CMAKE_CURRENT_LIST_DIR} |
| + ${CMAKE_CURRENT_LIST_DIR}/inc |
| + PUBLIC |
| + $<INSTALL_INTERFACE:include> |
| + $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}> |
| + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/inc> |
| +) |
| + |
| +configure_file(${CMAKE_CURRENT_LIST_DIR}/${TARGET}_config.h.in "${CMAKE_CURRENT_BINARY_DIR}/config.h" @ONLY) |
| + |
| +target_link_libraries(${TARGET} |
| + PUBLIC |
| + Threads::Threads |
| + m |
| +) |
| + |
| +set_target_properties(${TARGET} PROPERTIES VERSION ${lora_gateway_VERSION_SHORT}) |
| +set_target_properties(${TARGET} PROPERTIES SOVERSION ${lora_gateway_VERSION_SHORT}) |
| +set_target_properties(${TARGET} PROPERTIES PUBLIC_HEADER "${CMAKE_CURRENT_BINARY_DIR}/config.h;${${TARGET}_PUBLIC_HEADERS}") |
| + |
| +# -- add the install targets |
| +install (TARGETS ${TARGET} |
| + EXPORT ${TARGET}_targets |
| + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT shlib |
| + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${TARGET} |
| + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${TARGET} |
| +) |
| + |
| +# -- add pkg config file |
| +configure_file ("${CMAKE_CURRENT_LIST_DIR}/${TARGET}.pc.in" "${PROJECT_BINARY_DIR}/${TARGET}.pc" @ONLY) |
| +install (FILES ${PROJECT_BINARY_DIR}/${TARGET}.pc DESTINATION lib/pkgconfig) |
| + |
| +# -- write cmake package config file |
| +write_basic_package_version_file( |
| + "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}/${TARGET}-config-version.cmake" |
| + VERSION ${lora_gateway_VERSION} |
| + COMPATIBILITY AnyNewerVersion |
| +) |
| + |
| +export(EXPORT ${TARGET}_targets |
| + FILE "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}/${TARGET}-targets.cmake" |
| + NAMESPACE Semtech:: |
| +) |
| + |
| +configure_file(${PROJECT_SOURCE_DIR}/cmake/${TARGET}-config.cmake |
| + "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}/${TARGET}-config.cmake" |
| + COPYONLY |
| +) |
| + |
| +set(ConfigPackageLocation lib/cmake/${TARGET}) |
| + |
| +install(EXPORT ${TARGET}_targets |
| + FILE ${TARGET}-targets.cmake |
| + NAMESPACE Semtech:: |
| + DESTINATION ${ConfigPackageLocation} |
| +) |
| + |
| +install( |
| + FILES ${PROJECT_SOURCE_DIR}/cmake/${TARGET}-config.cmake "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}/${TARGET}-config-version.cmake" |
| + DESTINATION ${ConfigPackageLocation} |
| + COMPONENT Devel |
| +) |
| + |
| +# -- add test programs |
| +foreach(TEST test_loragw_spi test_loragw_gps test_loragw_reg test_loragw_hal test_loragw_cal) |
| + add_executable(${TEST} "") |
| + |
| + target_sources(${TEST} |
| + PRIVATE |
| + ${CMAKE_CURRENT_LIST_DIR}/tst/${TEST}.c |
| + ) |
| + |
| + target_include_directories(${TEST} |
| + PRIVATE |
| + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
| + $<INSTALL_INTERFACE:include> |
| + ${CMAKE_CURRENT_LIST_DIR}/inc |
| + ${CMAKE_CURRENT_BINARY_DIR} |
| + ) |
| + |
| + target_link_libraries(${TEST} |
| + PRIVATE |
| + loragw |
| + ) |
| + |
| + install ( |
| + TARGETS ${TEST} |
| + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} |
| + ) |
| + |
| +endforeach() |
| + |
| --- /dev/null |
| +++ b/libloragw/loragw.pc.in |
| @@ -0,0 +1,10 @@ |
| +prefix=@CMAKE_INSTALL_PREFIX@ |
| +exec_prefix=${prefix}/bin |
| +includedir=${prefix}/include/libloragw |
| +libdir=${prefix}/lib |
| + |
| +Name: LIBLORAGW |
| +Description: BLANK_TEXT |
| +Version: @lora_gateway_VERSION@ |
| +Cflags: -I${includedir} |
| +Libs: -L${libdir} -lloragw |
| --- /dev/null |
| +++ b/libloragw/loragw_config.h.in |
| @@ -0,0 +1,14 @@ |
| +#ifndef _LORAGW_CONFIGURATION_H |
| +#define _LORAGW_CONFIGURATION_H |
| + |
| +#define LIBLORAGW_VERSION "@lora_gateway_VERSION_SHORT@" |
| + |
| +#cmakedefine01 DEBUG_AUX |
| +#cmakedefine01 DEBUG_SPI |
| +#cmakedefine01 DEBUG_REG |
| +#cmakedefine01 DEBUG_HAL |
| +#cmakedefine01 DEBUG_GPS |
| +#cmakedefine01 DEBUG_GPIO |
| +#cmakedefine01 DEBUG_LBT |
| + |
| +#endif |
| --- /dev/null |
| +++ b/util_lbt_test/CMakeLists.txt |
| @@ -0,0 +1,23 @@ |
| + |
| +add_executable(util_lbt_test "") |
| +target_sources(util_lbt_test |
| + PRIVATE |
| + ${CMAKE_CURRENT_LIST_DIR}/src/util_lbt_test.c |
| +) |
| + |
| +target_link_libraries(util_lbt_test |
| + PUBLIC |
| + loragw |
| +) |
| + |
| +set_target_properties(util_lbt_test PROPERTIES |
| + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin |
| +) |
| + |
| +# add the install targets |
| +install ( |
| + TARGETS util_lbt_test |
| + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT shlib |
| + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} |
| +) |
| --- /dev/null |
| +++ b/util_pkt_logger/CMakeLists.txt |
| @@ -0,0 +1,29 @@ |
| + |
| +add_executable(util_pkt_logger "") |
| +target_sources(util_pkt_logger |
| + PRIVATE |
| + ${CMAKE_CURRENT_LIST_DIR}/src/util_pkt_logger.c |
| + ${CMAKE_CURRENT_LIST_DIR}/src/parson.c |
| +) |
| + |
| +target_include_directories(util_pkt_logger |
| + PRIVATE |
| + ${CMAKE_CURRENT_LIST_DIR}/inc |
| +) |
| + |
| +target_link_libraries(util_pkt_logger |
| + PUBLIC |
| + loragw |
| +) |
| + |
| +set_target_properties(util_pkt_logger PROPERTIES |
| + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin |
| +) |
| + |
| +# add the install targets |
| +install ( |
| + TARGETS util_pkt_logger |
| + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT shlib |
| + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} |
| +) |
| --- /dev/null |
| +++ b/util_spectral_scan/CMakeLists.txt |
| @@ -0,0 +1,23 @@ |
| + |
| +add_executable(util_spectral_scan "") |
| +target_sources(util_spectral_scan |
| + PRIVATE |
| + ${CMAKE_CURRENT_LIST_DIR}/src/util_spectral_scan.c |
| +) |
| + |
| +target_link_libraries(util_spectral_scan |
| + PUBLIC |
| + loragw |
| +) |
| + |
| +set_target_properties(util_spectral_scan PROPERTIES |
| + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin |
| +) |
| + |
| +# add the install targets |
| +install ( |
| + TARGETS util_spectral_scan |
| + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT shlib |
| + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} |
| +) |
| --- /dev/null |
| +++ b/util_spi_stress/CMakeLists.txt |
| @@ -0,0 +1,23 @@ |
| + |
| +add_executable(util_spi_stress "") |
| +target_sources(util_spi_stress |
| + PRIVATE |
| + ${CMAKE_CURRENT_LIST_DIR}/src/util_spi_stress.c |
| +) |
| + |
| +target_link_libraries(util_spi_stress |
| + PUBLIC |
| + loragw |
| +) |
| + |
| +set_target_properties(util_spi_stress PROPERTIES |
| + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin |
| +) |
| + |
| +# add the install targets |
| +install ( |
| + TARGETS util_spi_stress |
| + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT shlib |
| + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} |
| +) |
| --- /dev/null |
| +++ b/util_tx_continuous/CMakeLists.txt |
| @@ -0,0 +1,23 @@ |
| + |
| +add_executable(util_tx_continuous "") |
| +target_sources(util_tx_continuous |
| + PRIVATE |
| + ${CMAKE_CURRENT_LIST_DIR}/src/util_tx_continuous.c |
| +) |
| + |
| +target_link_libraries(util_tx_continuous |
| + PUBLIC |
| + loragw |
| +) |
| + |
| +set_target_properties(util_tx_continuous PROPERTIES |
| + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin |
| +) |
| + |
| +# add the install targets |
| +install ( |
| + TARGETS util_tx_continuous |
| + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT shlib |
| + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} |
| +) |
| --- /dev/null |
| +++ b/util_tx_test/CMakeLists.txt |
| @@ -0,0 +1,23 @@ |
| + |
| +add_executable(util_tx_test "") |
| +target_sources(util_tx_test |
| + PRIVATE |
| + ${CMAKE_CURRENT_LIST_DIR}/src/util_tx_test.c |
| +) |
| + |
| +target_link_libraries(util_tx_test |
| + PUBLIC |
| + loragw |
| +) |
| + |
| +set_target_properties(util_tx_test PROPERTIES |
| + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin |
| +) |
| + |
| +# add the install targets |
| +install ( |
| + TARGETS util_tx_test |
| + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT shlib |
| + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} |
| +) |