Skip to content
Permalink
Browse files
Package modules improvements.
Avoid redefining libzip::libzip and support Jansson target for etcdlib.
  • Loading branch information
PengZheng committed Mar 9, 2022
1 parent 289bf9e commit 1e9e20a15a8bdb81b30ac26d801e830f909a9008
Showing 2 changed files with 18 additions and 3 deletions.
@@ -37,7 +37,7 @@ include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LIBZIP DEFAULT_MSG
LIBZIP_LIBRARY LIBZIP_INCLUDE_DIR)

if(LIBZIP_FOUND)
if(LIBZIP_FOUND AND NOT TARGET libzip::libzip)
add_library(libzip::libzip IMPORTED STATIC GLOBAL)
set_target_properties(libzip::libzip PROPERTIES
IMPORTED_LOCATION "${LIBZIP_LIBRARY}"
@@ -21,7 +21,7 @@
# JANSSON_FOUND - System has Jansson
# JANSSON_INCLUDE_DIRS - The Jansson include directories
# JANSSON_LIBRARIES - The libraries needed to use Jansson
# JANSSON_DEFINITIONS - Compiler switches required for using Jansson
# Jansson - Imported target for Jansson

find_path(JANSSON_INCLUDE_DIR jansson.h
/usr/include
@@ -39,4 +39,19 @@ include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Jansson DEFAULT_MSG
JANSSON_LIBRARY JANSSON_INCLUDE_DIR)

mark_as_advanced(JANSSON_INCLUDE_DIR JANSSON_LIBRARY )
mark_as_advanced(JANSSON_INCLUDE_DIR JANSSON_LIBRARY)

if (JANSSON_FOUND AND NOT TARGET Jansson)
add_library(Jansson SHARED IMPORTED)
set_target_properties(Jansson PROPERTIES
IMPORTED_LOCATION "${JANSSON_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${JANSSON_INCLUDE_DIR}"
)

endif ()

#For backward compatability
set(JANSSON_LIBRARY ${JANSSON_LIBRARY})
set(JANSSON_LIBRARIES ${JANSSON_LIBRARY})
set(JANSSON_INCLUDE_DIR ${JANSSON_INCLUDE_DIR})
set(JANSSON_INCLUDE_DIRS ${JANSSON_INCLUDE_DIR})

0 comments on commit 1e9e20a

Please sign in to comment.