From 6e30a50cfa1c8d29edc6e83209532a59d33d0e08 Mon Sep 17 00:00:00 2001 From: Michal Vasko Date: Thu, 2 May 2024 09:42:18 +0200 Subject: [PATCH] cmake UPDATE make pkg-config optional --- CMakeLists.txt | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b1aa75e..48b06ca7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -144,31 +144,34 @@ set(FORMAT_SRC # PKGCONFIG { -find_package(PkgConfig REQUIRED) +find_package(PkgConfig) +if(PkgConfig_FOUND) + # find libnetconf2 pkg + pkg_check_modules(PKG_LN2 REQUIRED libnetconf2) + + # libnetconf2 thread count check + pkg_get_variable(LN2_THREAD_COUNT libnetconf2 "LN2_MAX_THREAD_COUNT") + if(LN2_THREAD_COUNT) + if(LN2_THREAD_COUNT LESS THREAD_COUNT) + message(FATAL_ERROR "libnetconf2 was compiled with support up to ${LN2_THREAD_COUNT} threads, server is configured with ${THREAD_COUNT}.") + else() + message(STATUS "libnetconf2 was compiled with support of up to ${LN2_THREAD_COUNT} threads") + endif() + endif() -# find libnetconf2 pkg -pkg_check_modules(PKG_LN2 REQUIRED libnetconf2) + # get libnetconf2 module directory, use it later when installing modules + pkg_get_variable(LN2_YANG_MODULE_DIR libnetconf2 "LN2_SCHEMAS_DIR") +endif() -# libnetconf2 thread count check -pkg_get_variable(LN2_THREAD_COUNT libnetconf2 "LN2_MAX_THREAD_COUNT") -if(LN2_THREAD_COUNT) - if(LN2_THREAD_COUNT LESS THREAD_COUNT) - message(FATAL_ERROR "libnetconf2 was compiled with support up to ${LN2_THREAD_COUNT} threads, server is configured with ${THREAD_COUNT}.") - else() - message(STATUS "libnetconf2 was compiled with support of up to ${LN2_THREAD_COUNT} threads") - endif() -else() +# } PKGCONFIG + +if(NOT LN2_THREAD_COUNT) message(STATUS "Unable to learn libnetconf2 thread support, check skipped") endif() - -# get libnetconf2 module directory, use it later when installing modules -pkg_get_variable(LN2_YANG_MODULE_DIR libnetconf2 "LN2_SCHEMAS_DIR") -if(NOT LN2_YANG_MODULE_DIR) +if(SYSREPO_SETUP AND NOT LN2_YANG_MODULE_DIR) message(FATAL_ERROR "Unable to learn libnetconf2 module search directory.") endif() -# } PKGCONFIG - if(ENABLE_VALGRIND_TESTS) find_program(VALGRIND_FOUND valgrind) if(NOT VALGRIND_FOUND)