Adding upstream version 2.0.24.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
e508fcfeb9
commit
afb0a8fea7
118 changed files with 45084 additions and 0 deletions
66
CMakeModules/ABICheck.cmake
Normal file
66
CMakeModules/ABICheck.cmake
Normal file
|
@ -0,0 +1,66 @@
|
|||
# generate API/ABI report
|
||||
macro(LIB_ABI_CHECK LIB_TARGET LIB_HEADERS LIB_SOVERSION_FULL ABI_BASE_HASH)
|
||||
# get short hash
|
||||
string(SUBSTRING "${ABI_BASE_HASH}" 0 8 ABI_BASE_HASH_SHORT)
|
||||
|
||||
# find abi-dumper
|
||||
find_program(ABI_DUMPER abi-dumper)
|
||||
find_package_handle_standard_args(abi-dumper DEFAULT_MSG ABI_DUMPER)
|
||||
if(NOT ABI_DUMPER)
|
||||
message(FATAL_ERROR "Program abi-dumper not found!")
|
||||
endif()
|
||||
|
||||
# find abi-checker
|
||||
find_program(ABI_CHECKER abi-compliance-checker)
|
||||
find_package_handle_standard_args(abi-compliance-checker DEFAULT_MSG ABI_CHECKER)
|
||||
if(NOT ABI_CHECKER)
|
||||
message(FATAL_ERROR "Program abi-compliance-checker not found!")
|
||||
endif()
|
||||
|
||||
# abi-dump target - generating an ABI dump
|
||||
set(PUBLIC_HEADERS ${LIB_HEADERS})
|
||||
string(PREPEND PUBLIC_HEADERS "${CMAKE_SOURCE_DIR}/")
|
||||
string(REPLACE ";" "\n${CMAKE_SOURCE_DIR}/" PUBLIC_HEADERS "${PUBLIC_HEADERS}")
|
||||
file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/public_headers CONTENT "${PUBLIC_HEADERS}")
|
||||
add_custom_target(abi-dump
|
||||
COMMAND ${ABI_DUMPER} ./lib${LIB_TARGET}${CMAKE_SHARED_LIBRARY_SUFFIX}
|
||||
-o lib${LIB_TARGET}.${LIB_SOVERSION_FULL}.dump
|
||||
-lver ${LIB_SOVERSION_FULL} -public-headers ${CMAKE_BINARY_DIR}/public_headers
|
||||
DEPENDS ${LIB_TARGET}
|
||||
BYPRODUCTS ${CMAKE_BINARY_DIR}/lib${LIB_TARGET}.${LIB_SOVERSION_FULL}.dump
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMENT "Dumping ABI information of version ${LIB_SOVERSION_FULL} for abi-check")
|
||||
|
||||
# get URL for fetching origin
|
||||
execute_process(COMMAND git remote get-url origin OUTPUT_VARIABLE ORIGIN_URL OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
# generate script for generating the base ABI dump
|
||||
file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/abibase.sh CONTENT "#!/bin/sh
|
||||
if [ ! -d abibase ]; then mkdir abibase; fi
|
||||
cd abibase
|
||||
if [ ! -f build/lib${LIB_TARGET}.*.dump ]; then
|
||||
if [ -d .git ] && [ \"${ABI_BASE_HASH}\" != \"`git log --pretty=oneline | cut -d' ' -f1`\" ]; then rm -rf .* 2> /dev/null; fi
|
||||
if [ ! -d .git ]; then
|
||||
git init --initial-branch=master
|
||||
git remote add origin ${ORIGIN_URL}
|
||||
git fetch origin --depth 1 ${ABI_BASE_HASH}
|
||||
git reset --hard FETCH_HEAD
|
||||
fi
|
||||
if [ ! -d build ]; then mkdir build; fi
|
||||
cd build
|
||||
cmake -DCMAKE_BUILD_TYPE=ABICheck ..
|
||||
make abi-dump
|
||||
fi
|
||||
")
|
||||
|
||||
# abi-check target - check ABI compatibility of current version and the base hash version
|
||||
add_custom_target(abi-check
|
||||
COMMAND bash ./abibase.sh
|
||||
COMMAND ${ABI_CHECKER} -l lib${LIB_TARGET}${CMAKE_SHARED_LIBRARY_SUFFIX}
|
||||
-old abibase/build/lib${LIB_TARGET}.*.dump
|
||||
-new ./lib${LIB_TARGET}.${LIB_SOVERSION_FULL}.dump -s
|
||||
DEPENDS ${LIB_TARGET} abi-dump
|
||||
BYPRODUCTS ${CMAKE_BINARY_DIR}/compat_reports/lib${LIB_TARGET}${CMAKE_SHARED_LIBRARY_SUFFIX}/*_to_${LIB_SOVERSION_FULL}/compat_report.html
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMENT "Checking ABI compatibility of version ${LIB_SOVERSION_FULL} and revision ${ABI_BASE_HASH_SHORT}")
|
||||
endmacro()
|
49
CMakeModules/FindCMocka.cmake
Normal file
49
CMakeModules/FindCMocka.cmake
Normal file
|
@ -0,0 +1,49 @@
|
|||
# - Try to find CMocka
|
||||
# Once done this will define
|
||||
#
|
||||
# CMOCKA_ROOT_DIR - Set this variable to the root installation of CMocka
|
||||
#
|
||||
# Read-Only variables:
|
||||
# CMOCKA_FOUND - system has CMocka
|
||||
# CMOCKA_INCLUDE_DIR - the CMocka include directory
|
||||
# CMOCKA_LIBRARIES - Link these to use CMocka
|
||||
# CMOCKA_DEFINITIONS - Compiler switches required for using CMocka
|
||||
#
|
||||
#=============================================================================
|
||||
# Copyright (c) 2011-2012 Andreas Schneider <asn@cryptomilk.org>
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
#
|
||||
|
||||
find_path(CMOCKA_INCLUDE_DIR
|
||||
NAMES
|
||||
cmocka.h
|
||||
PATHS
|
||||
${CMOCKA_ROOT_DIR}/include
|
||||
)
|
||||
|
||||
find_library(CMOCKA_LIBRARY
|
||||
NAMES
|
||||
cmocka
|
||||
PATHS
|
||||
${CMOCKA_ROOT_DIR}/include
|
||||
)
|
||||
|
||||
if(CMOCKA_LIBRARY)
|
||||
set(CMOCKA_LIBRARIES
|
||||
${CMOCKA_LIBRARIES}
|
||||
${CMOCKA_LIBRARY}
|
||||
)
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(CMocka DEFAULT_MSG CMOCKA_LIBRARIES CMOCKA_INCLUDE_DIR)
|
||||
|
||||
# show the CMOCKA_INCLUDE_DIR and CMOCKA_LIBRARIES variables only in the advanced view
|
||||
mark_as_advanced(CMOCKA_INCLUDE_DIR CMOCKA_LIBRARIES)
|
117
CMakeModules/FindLibSSH.cmake
Normal file
117
CMakeModules/FindLibSSH.cmake
Normal file
|
@ -0,0 +1,117 @@
|
|||
# - Try to find LibSSH
|
||||
# Once done this will define
|
||||
#
|
||||
# LIBSSH_FOUND - system has LibSSH
|
||||
# LIBSSH_INCLUDE_DIRS - the LibSSH include directory
|
||||
# LIBSSH_LIBRARIES - link these to use LibSSH
|
||||
# LIBSSH_VERSION -
|
||||
#
|
||||
# Author Michal Vasko <mvasko@cesnet.cz>
|
||||
# Copyright (c) 2020 CESNET, z.s.p.o.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of the author may not be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
if(LIBSSH_LIBRARIES AND LIBSSH_INCLUDE_DIRS)
|
||||
# in cache already
|
||||
set(LIBSSH_FOUND TRUE)
|
||||
else()
|
||||
find_path(LIBSSH_INCLUDE_DIR
|
||||
NAMES
|
||||
libssh/libssh.h
|
||||
PATHS
|
||||
/usr/include
|
||||
/usr/local/include
|
||||
/opt/local/include
|
||||
/sw/include
|
||||
${CMAKE_INCLUDE_PATH}
|
||||
${CMAKE_INSTALL_PREFIX}/include
|
||||
)
|
||||
|
||||
find_library(LIBSSH_LIBRARY
|
||||
NAMES
|
||||
ssh.so
|
||||
libssh.so
|
||||
libssh.dylib
|
||||
PATHS
|
||||
/usr/lib
|
||||
/usr/local/lib
|
||||
/opt/local/lib
|
||||
/sw/lib
|
||||
${CMAKE_LIBRARY_PATH}
|
||||
${CMAKE_INSTALL_PREFIX}/lib
|
||||
)
|
||||
|
||||
if(LIBSSH_INCLUDE_DIR AND LIBSSH_LIBRARY)
|
||||
# learn libssh version
|
||||
if(EXISTS ${LIBSSH_INCLUDE_DIR}/libssh/libssh_version.h)
|
||||
set(LIBSSH_HEADER_PATH ${LIBSSH_INCLUDE_DIR}/libssh/libssh_version.h)
|
||||
else()
|
||||
set(LIBSSH_HEADER_PATH ${LIBSSH_INCLUDE_DIR}/libssh/libssh.h)
|
||||
endif()
|
||||
file(STRINGS ${LIBSSH_HEADER_PATH} LIBSSH_VERSION_MAJOR
|
||||
REGEX "#define[ ]+LIBSSH_VERSION_MAJOR[ ]+[0-9]+")
|
||||
if(NOT LIBSSH_VERSION_MAJOR)
|
||||
message(STATUS "LIBSSH_VERSION_MAJOR not found, assuming libssh is too old and cannot be used!")
|
||||
set(LIBSSH_INCLUDE_DIR "LIBSSH_INCLUDE_DIR-NOTFOUND")
|
||||
set(LIBSSH_LIBRARY "LIBSSH_LIBRARY-NOTFOUND")
|
||||
else()
|
||||
string(REGEX MATCH "[0-9]+" LIBSSH_VERSION_MAJOR ${LIBSSH_VERSION_MAJOR})
|
||||
file(STRINGS ${LIBSSH_HEADER_PATH} LIBSSH_VERSION_MINOR
|
||||
REGEX "#define[ ]+LIBSSH_VERSION_MINOR[ ]+[0-9]+")
|
||||
string(REGEX MATCH "[0-9]+" LIBSSH_VERSION_MINOR ${LIBSSH_VERSION_MINOR})
|
||||
file(STRINGS ${LIBSSH_HEADER_PATH} LIBSSH_VERSION_PATCH
|
||||
REGEX "#define[ ]+LIBSSH_VERSION_MICRO[ ]+[0-9]+")
|
||||
string(REGEX MATCH "[0-9]+" LIBSSH_VERSION_PATCH ${LIBSSH_VERSION_PATCH})
|
||||
|
||||
set(LIBSSH_VERSION ${LIBSSH_VERSION_MAJOR}.${LIBSSH_VERSION_MINOR}.${LIBSSH_VERSION_PATCH})
|
||||
|
||||
if(LIBSSH_VERSION VERSION_LESS 0.8.0)
|
||||
# libssh_threads also needs to be linked for these versions
|
||||
string(REPLACE "libssh.so" "libssh_threads.so"
|
||||
LIBSSH_THREADS_LIBRARY
|
||||
${LIBSSH_LIBRARY}
|
||||
)
|
||||
string(REPLACE "libssh.dylib" "libssh_threads.dylib"
|
||||
LIBSSH_THREADS_LIBRARY
|
||||
${LIBSSH_THREADS_LIBRARY}
|
||||
)
|
||||
string(REPLACE "ssh.so" "ssh_threads.so"
|
||||
LIBSSH_THREADS_LIBRARY
|
||||
${LIBSSH_THREADS_LIBRARY}
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(LIBSSH_INCLUDE_DIRS ${LIBSSH_INCLUDE_DIR})
|
||||
set(LIBSSH_LIBRARIES ${LIBSSH_LIBRARY} ${LIBSSH_THREADS_LIBRARY})
|
||||
mark_as_advanced(LIBSSH_INCLUDE_DIRS LIBSSH_LIBRARIES)
|
||||
|
||||
find_package_handle_standard_args(LibSSH FOUND_VAR LIBSSH_FOUND
|
||||
REQUIRED_VARS LIBSSH_INCLUDE_DIRS LIBSSH_LIBRARIES
|
||||
VERSION_VAR LIBSSH_VERSION)
|
||||
endif()
|
||||
|
102
CMakeModules/FindLibVAL.cmake
Normal file
102
CMakeModules/FindLibVAL.cmake
Normal file
|
@ -0,0 +1,102 @@
|
|||
# - Try to find LibVAL
|
||||
# Once done this will define
|
||||
#
|
||||
# LIBVAL_FOUND - system has LibVAL
|
||||
# LIBVAL_INCLUDE_DIRS - the LibVAL include directory
|
||||
# LIBVAL_LIBRARIES - link these to use LibVAL
|
||||
#
|
||||
# Author Michal Vasko <mvasko@cesnet.cz>
|
||||
# Copyright (c) 2015 CESNET, z.s.p.o.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of the author may not be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
if(LIBVAL_LIBRARIES AND LIBVAL_INCLUDE_DIRS)
|
||||
# in cache already
|
||||
set(LIBVAL_FOUND TRUE)
|
||||
else()
|
||||
|
||||
find_path(LIBVAL_INCLUDE_DIR
|
||||
NAMES
|
||||
validator/validator.h
|
||||
validator/resolver.h
|
||||
validator/validator-compat.h
|
||||
validator/val_dane.h
|
||||
validator/val_errors.h
|
||||
PATHS
|
||||
/usr/include
|
||||
/usr/local/include
|
||||
/opt/local/include
|
||||
/sw/include
|
||||
${CMAKE_INCLUDE_PATH}
|
||||
${CMAKE_INSTALL_PREFIX}/include
|
||||
)
|
||||
|
||||
find_library(LIBVAL_LIBRARY
|
||||
NAMES
|
||||
libval-threads
|
||||
val-threads
|
||||
PATHS
|
||||
/usr/lib
|
||||
/usr/lib64
|
||||
/usr/local/lib
|
||||
/usr/local/lib64
|
||||
/opt/local/lib
|
||||
/sw/lib
|
||||
${CMAKE_LIBRARY_PATH}
|
||||
${CMAKE_INSTALL_PREFIX}/lib
|
||||
)
|
||||
|
||||
find_library(LIBSRES_LIBRARY
|
||||
NAMES
|
||||
libsres
|
||||
sres
|
||||
PATHS
|
||||
/usr/lib
|
||||
/usr/lib64
|
||||
/usr/local/lib
|
||||
/usr/local/lib64
|
||||
/opt/local/lib
|
||||
/sw/lib
|
||||
${CMAKE_LIBRARY_PATH}
|
||||
${CMAKE_INSTALL_PREFIX}/lib
|
||||
)
|
||||
|
||||
if(LIBVAL_INCLUDE_DIR AND LIBVAL_LIBRARY AND LIBSRES_LIBRARY)
|
||||
set(LIBVAL_FOUND TRUE)
|
||||
else()
|
||||
set(LIBVAL_FOUND FALSE)
|
||||
endif()
|
||||
|
||||
set(LIBVAL_INCLUDE_DIRS ${LIBVAL_INCLUDE_DIR})
|
||||
set(LIBVAL_LIBRARIES ${LIBSRES_LIBRARY} ${LIBVAL_LIBRARY})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(LibVAL DEFAULT_MSG LIBVAL_LIBRARIES LIBVAL_INCLUDE_DIRS)
|
||||
|
||||
# show the LIBVAL_INCLUDE_DIRS and LIBVAL_LIBRARIES variables only in the advanced view
|
||||
mark_as_advanced(LIBVAL_INCLUDE_DIRS LIBVAL_LIBRARIES)
|
||||
|
||||
endif()
|
||||
|
89
CMakeModules/FindLibYANG.cmake
Normal file
89
CMakeModules/FindLibYANG.cmake
Normal file
|
@ -0,0 +1,89 @@
|
|||
# - Try to find LibYANG
|
||||
# Once done this will define
|
||||
#
|
||||
# LIBYANG_FOUND - system has LibYANG
|
||||
# LIBYANG_INCLUDE_DIRS - the LibYANG include directory
|
||||
# LIBYANG_LIBRARIES - Link these to use LibYANG
|
||||
# LIBYANG_VERSION - SO version of the found libyang library
|
||||
#
|
||||
# Author Michal Vasko <mvasko@cesnet.cz>
|
||||
# Copyright (c) 2021 CESNET, z.s.p.o.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of the author may not be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
if(LIBYANG_LIBRARIES AND LIBYANG_INCLUDE_DIRS)
|
||||
# in cache already
|
||||
set(LIBYANG_FOUND TRUE)
|
||||
else()
|
||||
find_path(LIBYANG_INCLUDE_DIR
|
||||
NAMES
|
||||
libyang/libyang.h
|
||||
PATHS
|
||||
/usr/include
|
||||
/usr/local/include
|
||||
/opt/local/include
|
||||
/sw/include
|
||||
${CMAKE_INCLUDE_PATH}
|
||||
${CMAKE_INSTALL_PREFIX}/include
|
||||
)
|
||||
|
||||
find_library(LIBYANG_LIBRARY
|
||||
NAMES
|
||||
yang
|
||||
libyang
|
||||
PATHS
|
||||
/usr/lib
|
||||
/usr/lib64
|
||||
/usr/local/lib
|
||||
/usr/local/lib64
|
||||
/opt/local/lib
|
||||
/sw/lib
|
||||
${CMAKE_LIBRARY_PATH}
|
||||
${CMAKE_INSTALL_PREFIX}/lib
|
||||
)
|
||||
|
||||
if(LIBYANG_INCLUDE_DIR)
|
||||
find_path(LY_VERSION_PATH "libyang/version.h" HINTS ${LIBYANG_INCLUDE_DIR})
|
||||
if(LY_VERSION_PATH)
|
||||
file(READ "${LY_VERSION_PATH}/libyang/version.h" LY_VERSION_FILE)
|
||||
else()
|
||||
find_path(LY_HEADER_PATH "libyang/libyang.h" HINTS ${LIBYANG_INCLUDE_DIR})
|
||||
file(READ "${LY_HEADER_PATH}/libyang/libyang.h" LY_VERSION_FILE)
|
||||
endif()
|
||||
string(REGEX MATCH "#define LY_VERSION \"[0-9]+\\.[0-9]+\\.[0-9]+\"" LY_VERSION_MACRO "${LY_VERSION_FILE}")
|
||||
string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" LIBYANG_VERSION "${LY_VERSION_MACRO}")
|
||||
endif()
|
||||
|
||||
set(LIBYANG_INCLUDE_DIRS ${LIBYANG_INCLUDE_DIR})
|
||||
set(LIBYANG_LIBRARIES ${LIBYANG_LIBRARY})
|
||||
mark_as_advanced(LIBYANG_INCLUDE_DIRS LIBYANG_LIBRARIES)
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set LIBYANG_FOUND to TRUE
|
||||
# if all listed variables are TRUE
|
||||
find_package_handle_standard_args(LibYANG FOUND_VAR LIBYANG_FOUND
|
||||
REQUIRED_VARS LIBYANG_LIBRARY LIBYANG_INCLUDE_DIR
|
||||
VERSION_VAR LIBYANG_VERSION)
|
||||
endif()
|
21
CMakeModules/FindUncrustify.cmake
Normal file
21
CMakeModules/FindUncrustify.cmake
Normal file
|
@ -0,0 +1,21 @@
|
|||
# - Find uncrustify
|
||||
# Find the uncrustify binary.
|
||||
#
|
||||
# UNCRUSTIFY - path ot the binary
|
||||
# UNCRUSTIFY_VERSION - found version
|
||||
# UNCRUSTIFY_FOUND - True if uncrustify found.
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_program(UNCRUSTIFY uncrustify)
|
||||
if(UNCRUSTIFY)
|
||||
execute_process(COMMAND ${UNCRUSTIFY} --version OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE VERSION)
|
||||
string(FIND ${VERSION} "-" START_IDX)
|
||||
math(EXPR START_IDX "${START_IDX} + 1")
|
||||
string(SUBSTRING "${VERSION}" ${START_IDX} -1 VERSION)
|
||||
|
||||
string(FIND ${VERSION} "-" LEN)
|
||||
string(SUBSTRING "${VERSION}" 0 ${LEN} UNCRUSTIFY_VERSION)
|
||||
endif()
|
||||
|
||||
# Handle the QUIETLY and REQUIRED arguments and set UNCRUSTIFY_FOUND to TRUE if all listed variables are TRUE.
|
||||
find_package_handle_standard_args(Uncrustify REQUIRED_VARS UNCRUSTIFY VERSION_VAR UNCRUSTIFY_VERSION)
|
118
CMakeModules/GenCoverage.cmake
Normal file
118
CMakeModules/GenCoverage.cmake
Normal file
|
@ -0,0 +1,118 @@
|
|||
# generate test code coverage report
|
||||
|
||||
# check that coverage tools are available - always use before GEN_COVERAGE
|
||||
macro(GEN_COVERAGE_ENABLE ENABLE_TESTS)
|
||||
# make into normal variable
|
||||
set(TESTS_ENABLED ${ENABLE_TESTS})
|
||||
|
||||
set(GEN_COVERAGE_ENABLED ON)
|
||||
if(NOT TESTS_ENABLED)
|
||||
message(WARNING "You cannot generate coverage when tests are disabled. Enable test by additing parameter -DENABLE_BUILD_TESTS=ON or run cmake with Debug build target.")
|
||||
set(GEN_COVERAGE_ENABLED OFF)
|
||||
endif()
|
||||
|
||||
if(GEN_COVERAGE_ENABLED)
|
||||
find_program(PATH_GCOV NAMES gcov)
|
||||
if(NOT PATH_GCOV)
|
||||
message(WARNING "gcov executable not found! Disabling building code coverage report.")
|
||||
set(GEN_COVERAGE_ENABLED OFF)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(GEN_COVERAGE_ENABLED)
|
||||
find_program(PATH_LCOV NAMES lcov)
|
||||
if(NOT PATH_LCOV)
|
||||
message(WARNING "lcov executable not found! Disabling building code coverage report.")
|
||||
set(GEN_COVERAGE_ENABLED OFF)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(GEN_COVERAGE_ENABLED)
|
||||
find_program(PATH_GENHTML NAMES genhtml)
|
||||
if(NOT PATH_GENHTML)
|
||||
message(WARNING "genhtml executable not found! Disabling building code coverage report.")
|
||||
set(GEN_COVERAGE_ENABLED OFF)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(GEN_COVERAGE_ENABLED)
|
||||
if(NOT CMAKE_COMPILER_IS_GNUCC)
|
||||
message(WARNING "Compiler is not gcc! Coverage may break the tests!")
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND bash "-c" "${CMAKE_C_COMPILER} --version | head -n1 | sed \"s/.* (.*) \\([0-9]\\+.[0-9]\\+.[0-9]\\+ .*\\)/\\1/\""
|
||||
OUTPUT_VARIABLE GCC_VERSION_FULL
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
execute_process(
|
||||
COMMAND bash "-c" "${PATH_GCOV} --version | head -n1 | sed \"s/.* (.*) \\([0-9]\\+.[0-9]\\+.[0-9]\\+ .*\\)/\\1/\""
|
||||
OUTPUT_VARIABLE GCOV_VERSION_FULL
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
if(NOT GCC_VERSION_FULL STREQUAL GCOV_VERSION_FULL)
|
||||
message(WARNING "gcc and gcov versions do not match! Generating coverage may fail with errors.")
|
||||
endif()
|
||||
|
||||
# add specific required compile flags
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage -fprofile-arcs -ftest-coverage")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# tests are always expected to be in ${CMAKE_SOURCE_DIR}/tests
|
||||
function(GEN_COVERAGE MATCH_TEST_REGEX EXCLUDE_TEST_REGEX)
|
||||
if(NOT GEN_COVERAGE_ENABLED)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# destination
|
||||
set(COVERAGE_DIR "${CMAKE_BINARY_DIR}/code_coverage/")
|
||||
set(COVERAGE_FILE_RAW "${CMAKE_BINARY_DIR}/coverage_raw.info")
|
||||
set(COVERAGE_FILE_CLEAN "${CMAKE_BINARY_DIR}/coverage_clean.info")
|
||||
|
||||
# test match/exclude
|
||||
if(MATCH_TEST_REGEX)
|
||||
set(MATCH_TEST_ARGS -R \"${MATCH_TEST_REGEX}\")
|
||||
endif()
|
||||
if(EXCLUDE_TEST_REGEX)
|
||||
set(EXCLUDE_TEST_ARGS -E \"${EXCLUDE_TEST_REGEX}\")
|
||||
endif()
|
||||
|
||||
# coverage target
|
||||
add_custom_target(coverage
|
||||
COMMENT "Generating code coverage..."
|
||||
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
|
||||
# Cleanup code counters
|
||||
COMMAND "${PATH_LCOV}" --directory . --zerocounters --quiet
|
||||
|
||||
# Run tests
|
||||
COMMAND "${CMAKE_CTEST_COMMAND}" --quiet ${MATCH_TEST_ARGS} ${EXCLUDE_TEST_ARGS}
|
||||
|
||||
# Capture the counters
|
||||
COMMAND "${PATH_LCOV}"
|
||||
--directory .
|
||||
--rc lcov_branch_coverage=1
|
||||
--rc 'lcov_excl_line=assert'
|
||||
--capture --quiet
|
||||
--output-file "${COVERAGE_FILE_RAW}"
|
||||
# Remove coverage of tests, system headers, etc.
|
||||
COMMAND "${PATH_LCOV}"
|
||||
--remove "${COVERAGE_FILE_RAW}" '${CMAKE_SOURCE_DIR}/tests/*'
|
||||
--rc lcov_branch_coverage=1
|
||||
--quiet --output-file "${COVERAGE_FILE_CLEAN}"
|
||||
# Generate HTML report
|
||||
COMMAND "${PATH_GENHTML}"
|
||||
--branch-coverage --function-coverage --quiet --title "${PROJECT_NAME}"
|
||||
--legend --show-details --output-directory "${COVERAGE_DIR}"
|
||||
"${COVERAGE_FILE_CLEAN}"
|
||||
# Delete the counters
|
||||
COMMAND "${CMAKE_COMMAND}" -E remove
|
||||
${COVERAGE_FILE_RAW} ${COVERAGE_FILE_CLEAN}
|
||||
)
|
||||
|
||||
add_custom_command(TARGET coverage POST_BUILD
|
||||
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/tests"
|
||||
COMMENT "To see the code coverage report, open ${COVERAGE_DIR}index.html"
|
||||
COMMAND ;
|
||||
)
|
||||
endfunction()
|
28
CMakeModules/GenDoc.cmake
Normal file
28
CMakeModules/GenDoc.cmake
Normal file
|
@ -0,0 +1,28 @@
|
|||
# Prepare building doxygen documentation
|
||||
macro(GEN_DOC INPUT_FILES PROJECT_VERSION PROJECT_DESCRIPTION DOC_LOGO)
|
||||
find_package(Doxygen)
|
||||
if(DOXYGEN_FOUND)
|
||||
find_program(DOT_PATH dot PATH_SUFFIXES graphviz2.38/bin graphviz/bin)
|
||||
if(DOT_PATH)
|
||||
set(HAVE_DOT "YES")
|
||||
else()
|
||||
set(HAVE_DOT "NO")
|
||||
message(AUTHOR_WARNING "Doxygen: to generate UML diagrams please install graphviz")
|
||||
endif()
|
||||
|
||||
# target doc
|
||||
add_custom_target(doc
|
||||
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
# generate list with spaces as separators
|
||||
string(REPLACE ";" " " DOXY_INPUT "${INPUT_FILES}")
|
||||
|
||||
# make other arguments into variables
|
||||
set(PROJECT_VERSION ${PROJECT_VERSION})
|
||||
set(PROJECT_DESCRIPTION ${PROJECT_DESCRIPTION})
|
||||
set(DOC_LOGO ${DOC_LOGO})
|
||||
|
||||
configure_file(Doxyfile.in Doxyfile)
|
||||
endif()
|
||||
endmacro()
|
32
CMakeModules/SourceFormat.cmake
Normal file
32
CMakeModules/SourceFormat.cmake
Normal file
|
@ -0,0 +1,32 @@
|
|||
# format source files with uncrustify
|
||||
|
||||
# check that format checking is available - always use before SOURCE_FORMAT
|
||||
macro(SOURCE_FORMAT_ENABLE)
|
||||
find_package(Uncrustify 0.71)
|
||||
if(UNCRUSTIFY_FOUND)
|
||||
set(SOURCE_FORMAT_ENABLED TRUE)
|
||||
else()
|
||||
set(SOURCE_FORMAT_ENABLED FALSE)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# files are expected to be a list and relative paths are resolved wtih respect to CMAKE_SOURCE DIR
|
||||
macro(SOURCE_FORMAT)
|
||||
if(NOT ${ARGC})
|
||||
message(FATAL_ERROR "source_format() needs a list of files to format!")
|
||||
endif()
|
||||
|
||||
if(SOURCE_FORMAT_ENABLED)
|
||||
add_custom_target(format
|
||||
COMMAND ${UNCRUSTIFY} -c ${CMAKE_SOURCE_DIR}/uncrustify.cfg --no-backup --replace ${ARGN}
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
COMMENT "Formating sources with ${UNCRUSTIFY} ...")
|
||||
|
||||
add_custom_target(format-check
|
||||
COMMAND ${UNCRUSTIFY} -c ${CMAKE_SOURCE_DIR}/uncrustify.cfg --check ${ARGN}
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
COMMENT "Checking format of the sources with ${UNCRUSTIFY} ...")
|
||||
|
||||
set(SOURCE_FORMAT_ENABLED TRUE)
|
||||
endif()
|
||||
endmacro()
|
57
CMakeModules/UseCompat.cmake
Normal file
57
CMakeModules/UseCompat.cmake
Normal file
|
@ -0,0 +1,57 @@
|
|||
# - Use compat library providing various functions and macros that may be missing on some systems
|
||||
# Once done this will define
|
||||
#
|
||||
# compatsrc - sources to add to compilation
|
||||
#
|
||||
# Additionally, "compat.h" include directory is added and can be included.
|
||||
#
|
||||
# Author Michal Vasko <mvasko@cesnet.cz>
|
||||
# Copyright (c) 2021 CESNET, z.s.p.o.
|
||||
#
|
||||
# This source code is licensed under BSD 3-Clause License (the "License").
|
||||
# You may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://opensource.org/licenses/BSD-3-Clause
|
||||
#
|
||||
include(CheckSymbolExists)
|
||||
include(CheckFunctionExists)
|
||||
include(CheckIncludeFile)
|
||||
include(TestBigEndian)
|
||||
if(POLICY CMP0075)
|
||||
cmake_policy(SET CMP0075 NEW)
|
||||
endif()
|
||||
|
||||
macro(USE_COMPAT)
|
||||
# compatibility checks
|
||||
set(CMAKE_REQUIRED_DEFINITIONS -D_POSIX_C_SOURCE=200809L)
|
||||
list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
|
||||
list(APPEND CMAKE_REQUIRED_DEFINITIONS -D__BSD_VISIBLE=1)
|
||||
set(CMAKE_REQUIRED_LIBRARIES pthread)
|
||||
|
||||
check_symbol_exists(vdprintf "stdio.h;stdarg.h" HAVE_VDPRINTF)
|
||||
check_symbol_exists(asprintf "stdio.h" HAVE_ASPRINTF)
|
||||
check_symbol_exists(vasprintf "stdio.h" HAVE_VASPRINTF)
|
||||
check_symbol_exists(getline "stdio.h" HAVE_GETLINE)
|
||||
|
||||
check_symbol_exists(strndup "string.h" HAVE_STRNDUP)
|
||||
check_symbol_exists(strnstr "string.h" HAVE_STRNSTR)
|
||||
check_symbol_exists(strdupa "string.h" HAVE_STRDUPA)
|
||||
check_symbol_exists(strchrnul "string.h" HAVE_STRCHRNUL)
|
||||
|
||||
check_symbol_exists(get_current_dir_name "unistd.h" HAVE_GET_CURRENT_DIR_NAME)
|
||||
|
||||
check_function_exists(pthread_mutex_timedlock HAVE_PTHREAD_MUTEX_TIMEDLOCK)
|
||||
|
||||
TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
|
||||
|
||||
check_include_file("stdatomic.h" HAVE_STDATOMIC)
|
||||
|
||||
unset(CMAKE_REQUIRED_DEFINITIONS)
|
||||
unset(CMAKE_REQUIRED_LIBRARIES)
|
||||
|
||||
# header and source file (adding the source directly allows for hiding its symbols)
|
||||
configure_file(${PROJECT_SOURCE_DIR}/compat/compat.h.in ${PROJECT_BINARY_DIR}/compat/compat.h @ONLY)
|
||||
include_directories(${PROJECT_BINARY_DIR}/compat)
|
||||
set(compatsrc ${PROJECT_SOURCE_DIR}/compat/compat.c)
|
||||
endmacro()
|
27
CMakeModules/uninstall.cmake
Normal file
27
CMakeModules/uninstall.cmake
Normal file
|
@ -0,0 +1,27 @@
|
|||
cmake_minimum_required(VERSION 3.0.2)
|
||||
|
||||
set(MANIFEST "${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt")
|
||||
|
||||
if(NOT EXISTS ${MANIFEST})
|
||||
message(FATAL_ERROR "Cannot find install manifest: ${MANIFEST}")
|
||||
endif()
|
||||
|
||||
file(STRINGS ${MANIFEST} files)
|
||||
foreach(file ${files})
|
||||
if(EXISTS ${file} OR IS_SYMLINK ${file})
|
||||
message(STATUS "Removing: ${file}")
|
||||
|
||||
execute_process(COMMAND rm -f ${file}
|
||||
RESULT_VARIABLE result
|
||||
OUTPUT_QUIET
|
||||
ERROR_VARIABLE stderr
|
||||
ERROR_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
if(NOT ${result} EQUAL 0)
|
||||
message(FATAL_ERROR "${stderr}")
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "Does-not-exist: ${file}")
|
||||
endif()
|
||||
endforeach(file)
|
Loading…
Add table
Add a link
Reference in a new issue