diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d50819..24b7cbf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/cmake/Modules/FindSYSREPO.cmake b/cmake/Modules/FindSYSREPO.cmake index 3d6ece2..30abd91 100644 --- a/cmake/Modules/FindSYSREPO.cmake +++ b/cmake/Modules/FindSYSREPO.cmake @@ -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 () \ No newline at end of file