From 6ceda2a4de64ace87866e99e335c838dcd713127 Mon Sep 17 00:00:00 2001 From: Paul Sutton Date: Fri, 13 Nov 2015 16:08:36 +0000 Subject: [PATCH] Added basic versioning --- CMakeLists.txt | 5 +- ...rsLTEPackage.cmake => SRSLTEPackage.cmake} | 0 cmake/modules/SRSLTEVersion.cmake | 24 +++++++++ srslte/CMakeLists.txt | 4 +- srslte/include/CMakeLists.txt | 25 ++++++++++ srslte/include/srslte/CMakeLists.txt | 28 +++++++++++ srslte/include/srslte/srslte.h | 4 +- srslte/include/srslte/version.h.in | 41 +++++++++++++++ srslte/lib/CMakeLists.txt | 1 - srslte/lib/version/src/version.c | 50 +++++++++++++++++++ 10 files changed, 174 insertions(+), 8 deletions(-) rename cmake/modules/{srsLTEPackage.cmake => SRSLTEPackage.cmake} (100%) create mode 100644 cmake/modules/SRSLTEVersion.cmake create mode 100644 srslte/include/CMakeLists.txt create mode 100644 srslte/include/srslte/CMakeLists.txt create mode 100644 srslte/include/srslte/version.h.in create mode 100644 srslte/lib/version/src/version.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 570de918a..823d69b0e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,8 +34,8 @@ CMAKE_MINIMUM_REQUIRED (VERSION 2.6) PROJECT (SRSLTE) LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules") - -INCLUDE(srsLTEPackage) #setup cpack +INCLUDE(SRSLTEVersion) #sets version information +INCLUDE(SRSLTEPackage) #setup cpack INCLUDE(BuildMex) include(CTest) @@ -153,6 +153,7 @@ MESSAGE(STATUS "Building for version: ${VERSION}") ######################################################################## # Add general includes and dependencies ######################################################################## +include_directories(${PROJECT_BINARY_DIR}/srslte/include/) INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/srslte/include/) INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/mex/include) diff --git a/cmake/modules/srsLTEPackage.cmake b/cmake/modules/SRSLTEPackage.cmake similarity index 100% rename from cmake/modules/srsLTEPackage.cmake rename to cmake/modules/SRSLTEPackage.cmake diff --git a/cmake/modules/SRSLTEVersion.cmake b/cmake/modules/SRSLTEVersion.cmake new file mode 100644 index 000000000..6a26644d2 --- /dev/null +++ b/cmake/modules/SRSLTEVersion.cmake @@ -0,0 +1,24 @@ +# +# Copyright 2013-2015 Software Radio Systems Limited +# +# This file is part of the srsLTE library. +# +# srsLTE is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# srsLTE is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# A copy of the GNU Affero General Public License can be found in +# the LICENSE file in the top-level directory of this distribution +# and at http://www.gnu.org/licenses/. +# + +SET(SRSLTE_VERSION_MAJOR 001) +SET(SRSLTE_VERSION_MINOR 000) +SET(SRSLTE_VERSION_PATCH 000) +SET(SRSLTE_VERSION "${SRSLTE_VERSION_MAJOR}.${SRSLTE_VERSION_MINOR}.${SRSLTE_VERSION_PATCH}") diff --git a/srslte/CMakeLists.txt b/srslte/CMakeLists.txt index 3b7fa93f1..53f0412f9 100644 --- a/srslte/CMakeLists.txt +++ b/srslte/CMakeLists.txt @@ -23,8 +23,7 @@ ######################################################################## INSTALL(DIRECTORY include/ DESTINATION "${INCLUDE_DIR}" - FILES_MATCHING PATTERN "*.h" - PATTERN ".svn" EXCLUDE + FILES_MATCHING PATTERN "*.h" ) ######################################################################## @@ -49,4 +48,5 @@ FIND_PACKAGE(UHD) # Add subdirectories ######################################################################## ADD_SUBDIRECTORY(lib) +ADD_SUBDIRECTORY(include) ADD_SUBDIRECTORY(examples) diff --git a/srslte/include/CMakeLists.txt b/srslte/include/CMakeLists.txt new file mode 100644 index 000000000..66657af2d --- /dev/null +++ b/srslte/include/CMakeLists.txt @@ -0,0 +1,25 @@ +# +# Copyright 2013-2015 Software Radio Systems Limited +# +# This file is part of the srsLTE library. +# +# srsLTE is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# srsLTE is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# A copy of the GNU Affero General Public License can be found in +# the LICENSE file in the top-level directory of this distribution +# and at http://www.gnu.org/licenses/. +# + +######################################################################## +# Add subdirectories +######################################################################## +ADD_SUBDIRECTORY(srslte) + diff --git a/srslte/include/srslte/CMakeLists.txt b/srslte/include/srslte/CMakeLists.txt new file mode 100644 index 000000000..3fe2e0ac9 --- /dev/null +++ b/srslte/include/srslte/CMakeLists.txt @@ -0,0 +1,28 @@ +# +# Copyright 2013-2015 Software Radio Systems Limited +# +# This file is part of the srsLTE library. +# +# srsLTE is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# srsLTE is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# A copy of the GNU Affero General Public License can be found in +# the LICENSE file in the top-level directory of this distribution +# and at http://www.gnu.org/licenses/. +# + +CONFIGURE_FILE( + ${CMAKE_CURRENT_SOURCE_DIR}/version.h.in + ${CMAKE_CURRENT_BINARY_DIR}/version.h +) + +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/version.h + DESTINATION "${INCLUDE_DIR}/srslte" +) diff --git a/srslte/include/srslte/srslte.h b/srslte/include/srslte/srslte.h index 81128ccd1..5438c741c 100644 --- a/srslte/include/srslte/srslte.h +++ b/srslte/include/srslte/srslte.h @@ -31,14 +31,12 @@ #ifdef __cplusplus extern "C" { #endif - -#define SRSLTE_VERSION_MAJOR 1 -#define SRSLTE_VERSION_MINOR 0 #include #include #include "srslte/config.h" +#include "srslte/version.h" #include "srslte/utils/bit.h" #include "srslte/utils/convolution.h" diff --git a/srslte/include/srslte/version.h.in b/srslte/include/srslte/version.h.in new file mode 100644 index 000000000..a5962870c --- /dev/null +++ b/srslte/include/srslte/version.h.in @@ -0,0 +1,41 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2015 Software Radio Systems Limited + * + * \section LICENSE + * + * This file is part of the srsLTE library. + * + * srsLTE is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * srsLTE is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * A copy of the GNU Affero General Public License can be found in + * the LICENSE file in the top-level directory of this distribution + * and at http://www.gnu.org/licenses/. + * + */ + +#ifndef VERSION_ +#define VERSION_ + +// the configured options and settings for SRSLTE +#define SRSLTE_VERSION_MAJOR @SRSLTE_VERSION_MAJOR@ +#define SRSLTE_VERSION_MINOR @SRSLTE_VERSION_MINOR@ +#define SRSLTE_VERSION_PATCH @SRSLTE_VERSION_PATCH@ +#define SRSLTE_VERSION @SRSLTE_VERSION@ + +SRSLTE_API char* srslte_get_version(); +SRSLTE_API int srslte_get_version_major(); +SRSLTE_API int srslte_get_version_minor(); +SRSLTE_API int srslte_get_version_patch(); + +#endif // VERSION_ diff --git a/srslte/lib/CMakeLists.txt b/srslte/lib/CMakeLists.txt index b944597bd..eb3f2dc06 100644 --- a/srslte/lib/CMakeLists.txt +++ b/srslte/lib/CMakeLists.txt @@ -52,7 +52,6 @@ IF(SRSGUI_FOUND) LINK_DIRECTORIES(${SRSGUI_LIBRARY_DIRS}) ENDIF(SRSGUI_FOUND) - ######################################################################## # Recurse subdirectories and compile all source files into the same lib ######################################################################## diff --git a/srslte/lib/version/src/version.c b/srslte/lib/version/src/version.c new file mode 100644 index 000000000..dcb8e3f41 --- /dev/null +++ b/srslte/lib/version/src/version.c @@ -0,0 +1,50 @@ +/** + * + * \section COPYRIGHT + * + * Copyright 2013-2015 Software Radio Systems Limited + * + * \section LICENSE + * + * This file is part of the srsLTE library. + * + * srsLTE is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * srsLTE is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * A copy of the GNU Affero General Public License can be found in + * the LICENSE file in the top-level directory of this distribution + * and at http://www.gnu.org/licenses/. + * + */ + +#define STRINGIFY(x) #x +#define TOSTRING(x) STRINGIFY(x) + +#include "srslte/version.h" +#include + +char* srslte_get_version_string() { + char buf[32]; + sprintf(buf, "%s.%s.%s", + TOSTRING(SRSLTE_VERSION_MAJOR), + TOSTRING(SRSLTE_VERSION_MINOR), + TOSTRING(SRSLTE_VERSION_PATCH)); + return buf; +} + +int srslte_get_version_major() { + return SRSLTE_VERSION_MAJOR; +} +int srslte_get_version_minor() { + return SRSLTE_VERSION_MINOR; +} +int srslte_get_version_patch() { + return SRSLTE_VERSION_PATCH; +}