Skip to content

Commit

Permalink
Read libnabo version from package.xml, instead of the header of nabo.h
Browse files Browse the repository at this point in the history
  • Loading branch information
boxanm committed May 7, 2024
1 parent 68a0dc9 commit 22868e8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
16 changes: 11 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,17 @@ project("lib${LIB_NAME}")

set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})

# Extract version from header
file(READ "nabo/nabo.h" NABO_HEADER_CONTENT)
string(REGEX MATCH "#define NABO_VERSION \"([0-9]+\.[0-9]+\.[0-9]+)\"" _ ${NABO_HEADER_CONTENT})
set(PROJECT_VERSION ${CMAKE_MATCH_1})
message(STATUS ${PROJECT_VERSION})
## Extract version from package.xml
file(READ "package.xml" PACKAGE_XML_CONTENT)
string(REGEX MATCH "<version>([^<]+)</version>" VERSION_MATCH ${PACKAGE_XML_CONTENT})
# Extract the matched version from the captured group
if(VERSION_MATCH)
# CMake variable ${CMAKE_MATCH_1} contains the matched version
set(PROJECT_VERSION ${CMAKE_MATCH_1})
message(STATUS "Found package version: ${PROJECT_VERSION}")
else()
message(WARNING "Package version not found in package.xml")
endif()

if (NOT CMAKE_BUILD_TYPE)
message("-- No build type specified; defaulting to CMAKE_BUILD_TYPE=Release.")
Expand Down
8 changes: 1 addition & 7 deletions nabo/nabo.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,7 @@ libnabo differs from \ref ANN on the following points:
//! Namespace for Nabo
namespace Nabo
{
//! \defgroup public public interface
//@{

//! version of the Nabo library as string
#define NABO_VERSION "1.0.7"
//! version of the Nabo library as an int
#define NABO_VERSION_INT 10007
//! \defgroup public public interface

// TODO (c++14) Convert invalidIndex, invalidValue to constexpr templated variables.
template <typename IndexType>
Expand Down

0 comments on commit 22868e8

Please sign in to comment.