+include(FindPkgConfig)
+
+pkg_check_modules(EXTRAS REQUIRED libxml-2.0 openssl xmlsec1 xmlsec1-openssl json-c)
+add_compile_options(${EXTRAS_CFLAGS})
+include_directories(${EXTRAS_INCLUDE_DIRS})
+link_libraries(${EXTRAS_LIBRARIES})
+
+pkg_check_modules(libzip libzip>=0.11)
+if(libzip_FOUND AND USE_LIBZIP)
+ add_compile_options(${libzip_CFLAGS})
+ include_directories(${libzip_INCLUDE_DIRS})
+ link_libraries(${libzip_LIBRARIES})
+ add_definitions(-DUSE_LIBZIP=1)
+else()
+ add_definitions(-DUSE_LIBZIP=0)
+endif()
+
+pkg_check_modules(libsystemd libsystemd>=222)
+if(libsystemd_FOUND)
+ add_compile_options(${libsystemd_CFLAGS})
+ include_directories(${libsystemd_INCLUDE_DIRS})
+ link_libraries(${libsystemd_LIBRARIES})
+else()
+ add_definitions(-DNO_LIBSYSTEMD)
+endif()
+
+###########################################################################
+
+if(SIMULATE_SECMGR)
+ add_definitions(-DSIMULATE_SECURITY_MANAGER=1)
+else(SIMULATE_SECMGR)
+ pkg_check_modules(SECMGR REQUIRED security-manager)
+ add_compile_options(${SECMGR_CFLAGS})
+ include_directories(${SECMGR_INCLUDE_DIRS})
+ link_libraries(${SECMGR_LIBRARIES})
+ add_definitions(-DSIMULATE_SECURITY_MANAGER=0)
+endif(SIMULATE_SECMGR)
+
+if(SIMULATE_SMACK)
+ add_definitions(-DSIMULATE_LIBSMACK=1)
+else(SIMULATE_SMACK)
+ pkg_check_modules(SMACK REQUIRED libsmack)
+ add_compile_options(${SMACK_CFLAGS})
+ include_directories(${SMACK_INCLUDE_DIRS})
+ link_libraries(${SMACK_LIBRARIES})
+ add_definitions(-DSIMULATE_LIBSMACK=0)
+endif(SIMULATE_SMACK)
+
+###########################################################################
+
+add_library(wgtpkg STATIC