+INCLUDE (CheckIncludeFile)
+IF (ENABLE_RPMDB)
+ FIND_LIBRARY (RPMDB_LIBRARY NAMES rpmdb)
+
+ IF (NOT RPMDB_LIBRARY)
+ FIND_LIBRARY (RPMDB_LIBRARY NAMES rpm)
+ ENDIF (NOT RPMDB_LIBRARY)
+
+ FIND_LIBRARY (RPMIO_LIBRARY NAMES rpmio)
+ IF (RPMIO_LIBRARY)
+ SET(RPMDB_LIBRARY ${RPMIO_LIBRARY} ${RPMDB_LIBRARY})
+ ENDIF (RPMIO_LIBRARY)
+
+ IF (RPM5)
+ FIND_LIBRARY (RPMMISC_LIBRARY NAMES rpmmisc)
+ IF (RPMMISC_LIBRARY)
+ SET (RPMDB_LIBRARY ${RPMMISC_LIBRARY} ${RPMDB_LIBRARY})
+ ENDIF (RPMMISC_LIBRARY)
+ ENDIF (RPM5)
+
+ # check if rpm contains a bundled berkeley db
+ CHECK_INCLUDE_FILE(rpm/db.h HAVE_RPM_DB_H)
+ IF (NOT HAVE_RPM_DB_H)
+ FIND_LIBRARY (DB_LIBRARY NAMES db)
+ IF (DB_LIBRARY)
+ SET (RPMDB_LIBRARY ${DB_LIBRARY} ${RPMDB_LIBRARY})
+ ENDIF (DB_LIBRARY)
+ ENDIF (NOT HAVE_RPM_DB_H)
+ INCLUDE (CheckLibraryExists)
+ CHECK_LIBRARY_EXISTS(rpmio pgpDigGetParams "" HAVE_PGPDIGGETPARAMS)
+ENDIF (ENABLE_RPMDB)
+
+IF (ENABLE_PUBKEY)
+ SET (ENABLE_PGPVRFY ON)
+ENDIF (ENABLE_PUBKEY)
+
+INCLUDE (CheckFunctionExists)
+INCLUDE (TestBigEndian)
+
+CHECK_FUNCTION_EXISTS (strchrnul HAVE_STRCHRNUL)
+CHECK_FUNCTION_EXISTS (fopencookie HAVE_FOPENCOOKIE)
+CHECK_FUNCTION_EXISTS (funopen HAVE_FUNOPEN)
+TEST_BIG_ENDIAN (WORDS_BIGENDIAN)
+
+IF (${CMAKE_MAJOR_VERSION} GREATER 2)
+INCLUDE (CMakePushCheckState)
+INCLUDE (CheckCCompilerFlag)
+MACRO (check_linker_flag FLAG VAR)
+ CMAKE_PUSH_CHECK_STATE (RESET)
+ SET (CMAKE_REQUIRED_FLAGS "${FLAG}")
+ CHECK_C_COMPILER_FLAG ("" "${VAR}")
+ CMAKE_POP_CHECK_STATE ()
+ENDMACRO (check_linker_flag)
+check_linker_flag("-Wl,--as-needed" HAVE_LINKER_AS_NEEDED)
+check_linker_flag("-Wl,--version-script=${CMAKE_SOURCE_DIR}/src/libsolv.ver" HAVE_LINKER_VERSION_SCRIPT)
+ELSE (${CMAKE_MAJOR_VERSION} GREATER 2)
+SET (HAVE_LINKER_AS_NEEDED 1)
+SET (HAVE_LINKER_VERSION_SCRIPT 1)
+ENDIF (${CMAKE_MAJOR_VERSION} GREATER 2)
+
+# should create config.h with #cmakedefine instead...
+FOREACH (VAR HAVE_STRCHRNUL HAVE_FOPENCOOKIE HAVE_FUNOPEN WORDS_BIGENDIAN
+ HAVE_RPM_DB_H HAVE_PGPDIGGETPARAMS
+ ENABLE_RPMDB ENABLE_PUBKEY ENABLE_RPMMD ENABLE_RPMDB_BYRPMHEADER ENABLE_SUSEREPO ENABLE_COMPS
+ ENABLE_HELIXREPO ENABLE_MDKREPO ENABLE_ARCHREPO ENABLE_DEBIAN ENABLE_HAIKU
+ ENABLE_LZMA_COMPRESSION ENABLE_BZIP2_COMPRESSION ENABLE_PGPVRFY ENABLE_APPDATA
+ ENABLE_LINKED_PKGS ENABLE_COMPLEX_DEPS)
+ IF(${VAR})
+ ADD_DEFINITIONS (-D${VAR}=1)
+ SET (SWIG_FLAGS ${SWIG_FLAGS} -D${VAR})
+ ENDIF (${VAR})
+ENDFOREACH (VAR)
+
+SET (PACKAGE "libsolv")
+SET (VERSION "${LIBSOLV_MAJOR}.${LIBSOLV_MINOR}.${LIBSOLV_PATCH}")
+
+ADD_DEFINITIONS (-D_FILE_OFFSET_BITS=64)
+ADD_DEFINITIONS (-DVERSION=\\\"${VERSION}\\\")
+CONFIGURE_FILE (src/solvversion.h.in src/solvversion.h)
+
+SET (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Package dependency solver library")
+SET (CPACK_PACKAGE_VENDOR "SUSE")
+SET (CPACK_PACKAGE_VERSION_MAJOR ${LIBSOLV_MAJOR})
+SET (CPACK_PACKAGE_VERSION_MINOR ${LIBSOLV_MINOR})
+SET (CPACK_PACKAGE_VERSION_PATCH ${LIBSOLV_PATCH})
+SET (CPACK_GENERATOR "TBZ2")
+SET (CPACK_SOURCE_GENERATOR "TBZ2")
+SET (CPACK_SOURCE_PACKAGE_FILE_NAME "${PACKAGE}-${VERSION}")
+SET (CPACK_SOURCE_TOPLEVEL_TAG "Linux-Source:")
+SET (CPACK_TOPLEVEL_TAG "Linux-Source:")