Skip to content

Commit

Permalink
cmake UPDATE make pkg-config optional
Browse files Browse the repository at this point in the history
  • Loading branch information
michalvasko committed May 2, 2024
1 parent d7239bc commit 6e30a50
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6e30a50

Please sign in to comment.