build CHANGE detect libyang version
... and refuse to compile with an old one.
@@ -45,6 +45,7 @@ set(SYSREPO_SOVERSION ${SYSREPO_MAJOR_SOVERSION})
# Version of libyang library that this sysrepo depends on
set(LIBYANG_DEP_VERSION 1.0.119)
+set(LIBYANG_DEP_SOVERSION 1.5.14)
# options
if((CMAKE_BUILD_TYPE_LOWER STREQUAL debug) OR (CMAKE_BUILD_TYPE_LOWER STREQUAL package))
@@ -194,11 +195,20 @@ if(HAVE_ATOMIC)
target_link_libraries(sysrepo atomic)
endif()
-# libyang
+# libyang, check version
find_package(YANG REQUIRED)
target_link_libraries(sysrepo ${LIBYANG_LIBRARIES})
include_directories(${LIBYANG_INCLUDE_DIRS})
+find_path(LY_HEADER_PATH "libyang/libyang.h")
+file(READ "${LY_HEADER_PATH}/libyang/libyang.h" LY_HEADER)
+string(REGEX MATCH "#define LY_VERSION \"[0-9]+\\.[0-9]+\\.[0-9]+\"" LY_VERSION_MACRO "${LY_HEADER}")
+string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" LY_VERSION "${LY_VERSION_MACRO}")
+message(STATUS "Libyang SO version ${LY_VERSION} found")
+if(LY_VERSION VERSION_LESS LIBYANG_DEP_SOVERSION)
+ message(FATAL_ERROR "Libyang version too old, please update to at least ${LIBYANG_DEP_VERSION} (SO ${LIBYANG_DEP_SOVERSION})")
+endif()
+
# pthread
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package(Threads REQUIRED)
