Skip to content

Commit

Permalink
Change FindSYSREPO.cmake script
Browse files Browse the repository at this point in the history
  • Loading branch information
zinccyy committed Dec 5, 2022
1 parent 19fa1ce commit 61e1b22
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 38 deletions.
16 changes: 0 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,6 @@ set(
src/plugin/api/system/authentication/change.c
)

# get sysrepo version
find_package(PkgConfig)

if(PKG_CONFIG_FOUND)
execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} "--modversion" "sysrepo" OUTPUT_VARIABLE SYSREPO_VERSION)

if(SYSREPO_VERSION)
# strip new line from string
string(STRIP ${SYSREPO_VERSION} SYSREPO_VERSION)

if(${SYSREPO_VERSION} VERSION_LESS "1.0.0")
message(FATAL_ERROR "${PROJECT_NAME} requires at least libsysrepo verision 1.0.0")
endif()
endif()
endif()

add_library(${PLUGIN_LIRBARY_NAME} STATIC ${SOURCES})
install(TARGETS ${PLUGIN_LIRBARY_NAME} DESTINATION lib)

Expand Down
43 changes: 21 additions & 22 deletions cmake/Modules/FindSYSREPO.cmake
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
# SYSREPO_FOUND - System has SYSREPO
# SYSREPO_INCLUDE_DIRS - The SYSREPO include directories
# SYSREPO_LIBRARIES - The libraries needed to use SYSREPO
# SYSREPO_DEFINITIONS - Compiler switches required for using SYSREPO
if (SYSREPO_LIBRARIES AND SYSREPO_INCLUDE_DIRS)
set(SYSREPO_FOUND TRUE)
else ()

find_package(PkgConfig)
pkg_check_modules(PC_SYSREPO QUIET sysrepo)
set(SYSREPO_DEFINITIONS ${PC_SYSREPO_CFLAGS_OTHER})
find_path(
SYSREPO_INCLUDE_DIR
NAMES sysrepo.h
PATHS /usr/include /usr/local/include /opt/local/include /sw/include ${CMAKE_INCLUDE_PATH} ${CMAKE_INSTALL_PREFIX}/include
)

find_path(SYSREPO_INCLUDE_DIR sysrepo.h
HINTS ${PC_SYSREPO_INCLUDEDIR} ${PC_SYSREPO_INCLUDE_DIRS}
PATH_SUFFIXES sysrepo )
find_library(
SYSREPO_LIBRARY
NAMES sysrepo
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(SYSREPO_LIBRARY NAMES sysrepo
HINTS ${PC_SYSREPO_LIBDIR} ${PC_SYSREPO_LIBRARY_DIRS} )
if (SYSREPO_INCLUDE_DIR AND SYSREPO_LIBRARY)
set(SYSREPO_FOUND TRUE)
else (SYSREPO_INCLUDE_DIR AND SYSREPO_LIBRARY)
set(SYSREPO_FOUND FALSE)
endif (SYSREPO_INCLUDE_DIR AND SYSREPO_LIBRARY)

set(SYSREPO_LIBRARIES ${SYSREPO_LIBRARY} )
set(SYSREPO_INCLUDE_DIRS ${SYSREPO_INCLUDE_DIR} )

include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set SYSREPO_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(sysrepo DEFAULT_MSG
SYSREPO_LIBRARY SYSREPO_INCLUDE_DIR)

mark_as_advanced(SYSREPO_INCLUDE_DIR SYSREPO_LIBRARY )
set(SYSREPO_INCLUDE_DIRS ${SYSREPO_INCLUDE_DIR})
set(SYSREPO_LIBRARIES ${SYSREPO_LIBRARY})
endif ()

0 comments on commit 61e1b22

Please sign in to comment.