-PROJECT(libzypp)
-
-SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g" )
-SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g" )
-
-# Library
-IF ( DEFINED LIB )
- SET ( LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${LIB}" )
-ELSE ( DEFINED LIB )
- IF (CMAKE_SIZEOF_VOID_P MATCHES "8")
- SET( LIB_SUFFIX "64" )
- ENDIF(CMAKE_SIZEOF_VOID_P MATCHES "8")
- SET ( LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" )
-ENDIF ( DEFINED LIB )
-MESSAGE(STATUS "Libraries will be installed in ${LIB_INSTALL_DIR}" )
-####################################################################
-# CONFIGURATION #
-####################################################################
-
+PROJECT(LIBZYPP)
+SET( PACKAGE "libzypp" )
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
-SET( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules )
+SET( CMAKE_MODULE_PATH ${LIBZYPP_SOURCE_DIR}/cmake/modules )
+cmake_minimum_required(VERSION 2.6)
+
+# allow name libraries by name mixed with full
+# paths
+if(COMMAND cmake_policy)
+ cmake_policy(SET CMP0003 NEW)
+endif(COMMAND cmake_policy)
+
+INCLUDE(ZyppCommon)
+INCLUDE( ${LIBZYPP_SOURCE_DIR}/VERSION.cmake )
-INCLUDE( ${CMAKE_SOURCE_DIR}/VERSION.cmake )
MATH( EXPR LIBZYPP_CURRENT "${LIBZYPP_MAJOR} * 100 + ${LIBZYPP_MINOR}" )
MATH( EXPR LIBZYPP_AGE "${LIBZYPP_MINOR} - ${LIBZYPP_COMPATMINOR}" )
-
-SET( PACKAGE "libzypp" )
+# Libtool wanted current:patch:age
+# But cmake is not libtool, it wants the verbatim suffix to libzypp.so
+MATH( EXPR LIBZYPP_SO_FIRST "${LIBZYPP_CURRENT}-${LIBZYPP_AGE}" )
SET( VERSION "${LIBZYPP_MAJOR}.${LIBZYPP_MINOR}.${LIBZYPP_PATCH}" )
-ADD_DEFINITIONS( -DVERSION=\\\"${VERSION}\\\" )
-SET( LIBZYPP_VERSION_INFO "${LIBZYPP_CURRENT}.${LIBZYPP_PATCH}.${LIBZYPP_AGE}" )
-
-
-SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Novell's package management core engine.")
-SET(CPACK_PACKAGE_VENDOR "Novell Inc.")
-#SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/ReadMe.txt")
-#SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt")
-SET(CPACK_PACKAGE_VERSION_MAJOR ${LIBZYPP_MAJOR})
-SET(CPACK_PACKAGE_VERSION_MINOR ${LIBZYPP_MINOR})
-SET(CPACK_PACKAGE_VERSION_PATCH ${LIBZYPP_PATCH})
-SET( CPACK_GENERATOR "TBZ2")
-SET( CPACK_SOURCE_GENERATOR "TBZ2")
-SET( CPACK_SOURCE_PACKAGE_FILE_NAME "${PACKAGE}-${VERSION}" )
-
-# The following components are regex's to match anywhere (unless anchored)
-# in absolute path + filename to find files or directories to be excluded
-# from source tarball.
-SET (CPACK_SOURCE_IGNORE_FILES
-#/CVS/;/\\.svn/;/\\.libs/;/\\.deps/;\\.swp$;/build/;\\.o$;\\.lo$;\\.la$;~$;\\\\.cvsignore$;Makefile\\\\.in$;
-/CVS/;/\\\\.svn/;/\\\\.libs/;/\\\\.deps/;\\\\.swp$;/build/;\\\\.o$;\\\\.lo$;\\\\.la$;~$
-)
+SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing -fPIC -g -Wall -Werror=format-security -Woverloaded-virtual -Wnon-virtual-dtor -Wl,-as-needed" )
+SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-strict-aliasing -fPIC -g -Wall -Werror=format-security -Wl,-as-needed" )
+set( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -O3" )
+set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O3" )
-INCLUDE(CPack)
+ADD_DEFINITIONS( -D_FILE_OFFSET_BITS=64 )
+ADD_DEFINITIONS( -DVERSION="${VERSION}" )
+SET( LIBZYPP_VERSION_INFO "${LIBZYPP_SO_FIRST}.${LIBZYPP_AGE}.${LIBZYPP_PATCH}" )
+SET( LIBZYPP_SOVERSION_INFO "${LIBZYPP_SO_FIRST}" )
-####################################################################
+GENERATE_PACKAGING(${PACKAGE} ${VERSION})
-SET( DOC_INSTALL_DIR
- "${CMAKE_INSTALL_PREFIX}/share/doc/packages/${PACKAGE}"
- CACHE PATH "The install dir for documentation (default prefix/share/doc/packages/${PACKAGE})"
- FORCE
-)
+INCLUDE(CPack)
+
+MACRO(ADD_TESTS)
+ FOREACH( loop_var ${ARGV} )
+ SET_SOURCE_FILES_PROPERTIES( ${loop_var}_test.cc COMPILE_FLAGS "-DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN -DBOOST_AUTO_TEST_MAIN=\"\" " )
+ ADD_EXECUTABLE( ${loop_var}_test ${loop_var}_test.cc )
+ TARGET_LINK_LIBRARIES( ${loop_var}_test zypp boost_unit_test_framework zypp_test_utils)
+ ADD_TEST( ${loop_var}_test ${CMAKE_CURRENT_BINARY_DIR}/${loop_var}_test --catch_system_errors=no)
+ ENDFOREACH( loop_var )
+ENDMACRO(ADD_TESTS)
####################################################################
FIND_PACKAGE(Rpm REQUIRED)
IF ( NOT RPM_FOUND)
- MESSAGE( FATAL_ERROR " rpm not found" )
+ MESSAGE( FATAL_ERROR " rpm-devel not found" )
ELSE ( NOT RPM_FOUND)
INCLUDE_DIRECTORIES(${RPM_INCLUDE_DIR})
+ # fix includes not relative to rpm
+ INCLUDE_DIRECTORIES(${RPM_INCLUDE_DIR}/rpm)
+ if ( RPM_SUSPECT_VERSION STREQUAL "5.x" )
+ MESSAGE( STATUS "rpm found: enable rpm-4 compat interface." )
+ ADD_DEFINITIONS(-D_RPM_5)
+ elseif ( RPM_SUSPECT_VERSION STREQUAL "4.x" )
+ MESSAGE( STATUS "rpm found: enable rpm-4.4 legacy interface." )
+ ADD_DEFINITIONS(-D_RPM_4_4_COMPAT)
+ endif ( RPM_SUSPECT_VERSION STREQUAL "5.x" )
ENDIF( NOT RPM_FOUND)
FIND_PACKAGE(Boost REQUIRED)
MESSAGE( FATAL_ERROR "Gettext not found" )
ENDIF (GETTEXT_FOUND)
-FIND_PACKAGE(Hal REQUIRED)
-IF ( NOT HAL_FOUND)
- MESSAGE( FATAL_ERROR " Hal not found" )
-ELSE ( NOT HAL_FOUND)
- INCLUDE_DIRECTORIES(${HAL_INCLUDE_DIR})
-# hal/libhal-storage.h is broken grrr
- INCLUDE_DIRECTORIES(${HAL_INCLUDE_DIR}/hal)
-ENDIF( NOT HAL_FOUND)
-
-FIND_PACKAGE(Dbus REQUIRED)
-IF ( NOT DBUS_FOUND)
- MESSAGE( FATAL_ERROR " dbus not found" )
-ELSE ( NOT DBUS_FOUND)
- INCLUDE_DIRECTORIES(${DBUS_INCLUDE_DIR})
- INCLUDE_DIRECTORIES(${DBUS_ARCH_INCLUDE_DIR})
-ENDIF( NOT DBUS_FOUND)
-
-FIND_PACKAGE(Glib REQUIRED)
-IF (GLIB_FOUND)
- MESSAGE( STATUS "glib found: includes in ${GLIB_INCLUDE_DIR}, library in ${GLIB_LIBRARY}")
- INCLUDE_DIRECTORIES(${GLIB_INCLUDE_DIR})
- INCLUDE_DIRECTORIES(${GLIB_CONFIG_INCLUDE_DIR})
-ELSE(GLIB_FOUND)
- MESSAGE( FATAL_ERROR "glib not found" )
-ENDIF(GLIB_FOUND)
-
-#IF (DBUS_GLIB_FOUND)
-# MESSAGE( STATUS "dbus-glib found" )
-# INCLUDE_DIRECTORIES(${DBUS_GLIB_INCLUDE_DIR})
-# LINK_DIRECTORIES(${DBUS_GLIB_LINK_DIR})
-#ELSE(DBUS_GLIB_FOUND)
-# MESSAGE( ERROR "dbus-glib not found" )
-#ENDIF(DBUS_GLIB_FOUND)
-
FIND_PACKAGE(Curl REQUIRED)
IF ( NOT CURL_FOUND)
MESSAGE( FATAL_ERROR " curl not found" )
INCLUDE_DIRECTORIES(${LIBXML_INCLUDE_DIR})
ENDIF( NOT LIBXML_FOUND)
-FIND_PACKAGE(Sqlite REQUIRED)
-
FIND_PACKAGE(ZLIB REQUIRED)
IF ( NOT ZLIB_FOUND)
MESSAGE( FATAL_ERROR " zlib not found" )
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
ENDIF( NOT ZLIB_FOUND)
+FIND_PACKAGE(Satsolver REQUIRED)
+IF ( NOT SATSOLVER_FOUND )
+ MESSAGE( FATAL_ERROR " libsatsolver not found" )
+ELSE ( NOT SATSOLVER_FOUND )
+ INCLUDE_DIRECTORIES( ${SATSOLVER_INCLUDE_DIR} )
+ENDIF( NOT SATSOLVER_FOUND )
+
+# satsolver uses expat and has open references to it:
+FIND_PACKAGE(EXPAT REQUIRED)
+
+FIND_PACKAGE(OpenSSL REQUIRED)
+FIND_PACKAGE(Udev REQUIRED)
+
FIND_PROGRAM( DOXYGEN doxygen )
IF ( NOT DOXYGEN )
MESSAGE( FATAL_ERROR "doxygen not found: install doxygen to build the documentation." )
MESSAGE( STATUS "doxygen found: ${DOXYGEN}" )
ENDIF ( NOT DOXYGEN )
-MESSAGE(STATUS "soname: ${LIBZYPP_CURRENT}.${LIBZYPP_PATCH}.${LIBZYPP_AGE}")
+MESSAGE(STATUS "soname: ${LIBZYPP_VERSION_INFO}")
MESSAGE(STATUS "version: ${VERSION}")
+MESSAGE(STATUS "Writing pkg-config file...")
+CONFIGURE_FILE(${LIBZYPP_SOURCE_DIR}/libzypp.pc.cmake ${LIBZYPP_BINARY_DIR}/libzypp.pc @ONLY)
+INSTALL( FILES ${LIBZYPP_BINARY_DIR}/libzypp.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig )
+
+MESSAGE(STATUS "FindZypp.cmake will be installed in ${CMAKE_INSTALL_PREFIX}/share/cmake/Modules")
+INSTALL( FILES ${LIBZYPP_SOURCE_DIR}/cmake/modules/FindZypp.cmake DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cmake/Modules )
+INSTALL( FILES ${LIBZYPP_SOURCE_DIR}/cmake/modules/ZyppCommon.cmake DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cmake/Modules )
+
####################################################################
-# RPM SPEC #
+# config templates
+# (don't forget to mention them in the .spec file)
####################################################################
-MESSAGE(STATUS "Writing spec file...")
-CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/libzypp.spec.cmake ${CMAKE_BINARY_DIR}/package/libzypp.spec @ONLY)
-MESSAGE(STATUS "Writing pkg-config file...")
-CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/libzypp.pc.cmake ${CMAKE_BINARY_DIR}/libzypp.pc @ONLY)
-INSTALL( FILES ${CMAKE_BINARY_DIR}/libzypp.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig )
+MESSAGE(STATUS "zypp.conf will be installed in ${SYSCONFDIR}/zypp")
+INSTALL( FILES ${LIBZYPP_SOURCE_DIR}/zypp.conf DESTINATION ${SYSCONFDIR}/zypp )
-MESSAGE(STATUS "FindZypp.cmake will be installed in ${CMAKE_INSTALL_PREFIX}/share/cmake/Modules")
-INSTALL( FILES ${CMAKE_SOURCE_DIR}/cmake/modules/FindZypp.cmake DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cmake/Modules )
+#install systemCheck
+MESSAGE(STATUS "systemCheck will be installed in ${SYSCONFDIR}/zypp")
+INSTALL( FILES ${LIBZYPP_SOURCE_DIR}/systemCheck DESTINATION ${SYSCONFDIR}/zypp )
+
+# logrotate config file
+INSTALL( FILES ${LIBZYPP_SOURCE_DIR}/zypp-history.lr DESTINATION ${SYSCONFDIR}/logrotate.d )
####################################################################
# SUBDIRECTORIES #
####################################################################
ADD_SUBDIRECTORY( zypp )
-ADD_SUBDIRECTORY( zypp2 )
+#ADD_SUBDIRECTORY( zypp2 )
# do not build devel by default
ADD_SUBDIRECTORY( devel EXCLUDE_FROM_ALL )
ADD_SUBDIRECTORY( tools )
-#ADD_SUBDIRECTORY( examples )
+ADD_SUBDIRECTORY( examples )
ADD_SUBDIRECTORY( po EXCLUDE_FROM_ALL )
-ADD_SUBDIRECTORY( doc EXCLUDE_FROM_ALL )
+ADD_SUBDIRECTORY( doc )
+ADD_SUBDIRECTORY( vendor )
ADD_SUBDIRECTORY( tests EXCLUDE_FROM_ALL )
-####################################################################
-# INCLUDES #
-####################################################################
-
-INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
-
-####################################################################
-# OTHERS #
-####################################################################
-
-#configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h )
-#yumschemadir=${zyppdir}/schema/yum
-#xmlstoreschemadir=${zyppdir}/schema/xmlstore
-
-####################################################################
-# INSTALL #
-####################################################################
-
-#INSTALL_FILES( FILES libzypp.pc )
-
-ADD_CUSTOM_TARGET( svncheck
- COMMAND cd $(CMAKE_SOURCE_DIR) && ! LC_ALL=C svn status --show-updates --quiet | grep -v '^Status against revision'
-)
-
-SET( AUTOBUILD_COMMAND
- COMMAND ${CMAKE_MAKE_PROGRAM} package_source
- COMMAND ${CMAKE_COMMAND} -E copy ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2 ${CMAKE_BINARY_DIR}/package
- COMMAND ${CMAKE_COMMAND} -E remove ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2
- COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/package/${PACKAGE}.changes" "${CMAKE_BINARY_DIR}/package/${PACKAGE}.changes"
-)
-
-ADD_CUSTOM_TARGET( autobuild_local
- ${AUTOBUILD_COMMAND}
-)
-
-ADD_CUSTOM_TARGET( autobuild
- COMMAND ${CMAKE_MAKE_PROGRAM} svncheck
- ${AUTOBUILD_COMMAND}
-)
+INCLUDE(CTest)
+ENABLE_TESTING()