Skip to content

Commit

Permalink
Packager: FindLibOPKG syncup with metro version
Browse files Browse the repository at this point in the history
  • Loading branch information
HaseenaSainul committed Feb 27, 2024
1 parent a13218b commit c2f64be
Showing 1 changed file with 45 additions and 11 deletions.
56 changes: 45 additions & 11 deletions Packager/cmake/FindLibOPKG.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,65 @@
#
# Copyright 2020 RDK Management
#
# Licensed under the Apache License, Version 2.0 (the "License");
# Licensed under the Apache License, Version 2.0 (the License);
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# distributed under the License is distributed on an AS IS BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# - Try to find OPKG library
# - Try to find libopkg.so
# Once done this will define
# LIBOPKG_FOUND - System has LIBOPKG
# LIBOPKG_INCLUDE_DIRS - The LIBOPKG include directories
# LIBOPKG_LIBRARIES - The libraries needed to use LIBOPKG
# LIBOPKG_FOUND - System has libopkg
# LIBOPKG_INCLUDE_DIRS - The libopkg include directories
# LIBOPKG_LIBRARIES - The libraries needed to use libopkg
#

if(LibOPKG_FIND_QUIETLY)
set(_LIBOPKG_MODE QUIET)
elseif(LibOPKG_FIND_REQUIRED)
set(_LIBOPKG_MODE REQUIRED)
endif()

find_package(PkgConfig)
pkg_check_modules(PC_LIBOPKG ${_LIBOPKG_MODE} libopkg)

if(PC_LIBOPKG_FOUND)
if(LIBOPKG_FIND_VERSION AND PC_LIBOPKG_VERSION)
if ("${LIBOPKG_FIND_VERSION}" VERSION_GREATER "${PC_LIBOPKG_VERSION}")
message(SEND_ERROR "Incorrect version, found ${PC_LIBOPKG_VERSION}, need at least ${WPEFRAMEWORK_FIND_VERSION}, please install correct version ${LIBOPKG_FIND_VERSION}")
set(LIBOPKG_FOUND_TEXT "Found incorrect version")
unset(PC_LIBOPKG_FOUND)
endif()
set(LIBOPKG_FOUND TRUE)
endif()
else()
set(LIBOPKG_FOUND_TEXT "Not found")
endif()

find_library(LIBOPKG_LIBRARIES NAMES opkg)
set(LIBOPKG_DEFINITIONS ${PC_LIBOPKG_CFLAGS_OTHER})
set(LIBOPKG_INCLUDE_DIRS ${PC_LIBOPKG_INCLUDE_DIRS})
set(LIBOPKG_LIBRARIES ${PC_LIBOPKG_LIBRARIES})
set(LIBOPKG_LIBRARY_DIRS ${PC_LIBOPKG_LIBRARY_DIRS} ${PC_LIBOPKG_LIBDIR})

find_path(LIBOPKG_INCLUDE_DIRS NAMES opkg.h PATH_SUFFIXES libopkg)
find_path(LIBOPKG_INCLUDE_DIRS NAMES opkg_cmd.h PATH_SUFFIXES libopkg)
find_path(LIBOPKG_INCLUDE_DIRS NAMES opkg_download.h PATH_SUFFIXES libopkg)
find_library(OPKG_LIBRARY_LOCATION "${LIBOPKG_LIBRARIES}")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LibOPKG DEFAULT_MSG OPKG_LIBRARY_LOCATION LIBOPKG_INCLUDE_DIRS LIBOPKG_LIBRARIES)
mark_as_advanced(LIBOPKG_DEFINITIONS LIBOPKG_INCLUDE_DIRS LIBOPKG_LIBRARIES)

mark_as_advanced(LIBOPKG_FOUND LIBOPKG_INCLUDE_DIRS LIBOPKG_LIBRARIES)
if(NOT TARGET LibOPKG::LibOPKG)
add_library(LibOPKG::LibOPKG SHARED IMPORTED)
set_target_properties(LibOPKG::LibOPKG PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${OPKG_LIBRARY_LOCATION}"
INTERFACE_INCLUDE_DIRECTORIES "${LIBOPKG_INCLUDE_DIRS}"
INTERFACE_COMPILE_DEFINITIONS "${LIBOPKG_DEFINITIONS}"
INTERFACE_COMPILE_OPTIONS "${PC_LIBOPKG_CFLAGS}"
IMPORTED_LINK_INTERFACE_LIBRARIES "${LIBOPKG_LIBRARIES}"
)
endif()

0 comments on commit c2f64be

Please sign in to comment.