2 SET( PACKAGE "libzypp" )
3 # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
4 SET( CMAKE_MODULE_PATH ${LIBZYPP_SOURCE_DIR}/cmake/modules )
5 cmake_minimum_required(VERSION 2.6)
7 # allow name libraries by name mixed with full
9 if(COMMAND cmake_policy)
10 cmake_policy(SET CMP0003 NEW)
11 endif(COMMAND cmake_policy)
14 INCLUDE( ${LIBZYPP_SOURCE_DIR}/VERSION.cmake )
16 MATH( EXPR LIBZYPP_CURRENT "${LIBZYPP_MAJOR} * 100 + ${LIBZYPP_MINOR}" )
17 MATH( EXPR LIBZYPP_AGE "${LIBZYPP_MINOR} - ${LIBZYPP_COMPATMINOR}" )
18 # Libtool wanted current:patch:age
19 # But cmake is not libtool, it wants the verbatim suffix to libzypp.so
20 MATH( EXPR LIBZYPP_SO_FIRST "${LIBZYPP_CURRENT}-${LIBZYPP_AGE}" )
21 SET( VERSION "${LIBZYPP_MAJOR}.${LIBZYPP_MINOR}.${LIBZYPP_PATCH}" )
23 SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -g -Wall -Woverloaded-virtual -Wnon-virtual-dtor -Wl,-as-needed" )
24 SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -g -Wall -Wl,-as-needed" )
25 set( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -O3" )
26 set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O3" )
28 ADD_DEFINITIONS( -D_FILE_OFFSET_BITS=64 )
29 ADD_DEFINITIONS( -DVERSION="${VERSION}" )
30 SET( LIBZYPP_VERSION_INFO "${LIBZYPP_SO_FIRST}.${LIBZYPP_AGE}.${LIBZYPP_PATCH}" )
31 SET( LIBZYPP_SOVERSION_INFO "${LIBZYPP_SO_FIRST}" )
33 GENERATE_PACKAGING(${PACKAGE} ${VERSION})
38 FOREACH( loop_var ${ARGV} )
39 SET_SOURCE_FILES_PROPERTIES( ${loop_var}_test.cc COMPILE_FLAGS "-DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN -DBOOST_AUTO_TEST_MAIN=\"\" " )
40 ADD_EXECUTABLE( ${loop_var}_test ${loop_var}_test.cc )
41 TARGET_LINK_LIBRARIES( ${loop_var}_test zypp boost_unit_test_framework zypp_test_utils)
42 ADD_TEST( ${loop_var}_test ${CMAKE_CURRENT_BINARY_DIR}/${loop_var}_test)
43 ENDFOREACH( loop_var )
46 ####################################################################
48 FIND_PACKAGE(Rpm REQUIRED)
50 MESSAGE( FATAL_ERROR " rpm-devel not found" )
52 INCLUDE_DIRECTORIES(${RPM_INCLUDE_DIR})
53 # fix includes not relative to rpm
54 INCLUDE_DIRECTORIES(${RPM_INCLUDE_DIR}/rpm)
56 MESSAGE( STATUS "Enable rpm 4.4 legacy interface")
57 ADD_DEFINITIONS(-D_RPM_4_4_COMPAT)
58 endif (RPM_4_4_LEGACY)
61 FIND_PACKAGE(Boost REQUIRED)
63 MESSAGE( STATUS "boost found: includes in ${Boost_INCLUDE_DIRS}, library in ${Boost_LIBRARY_DIRS}")
64 INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
65 LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
68 FIND_PACKAGE(Gettext REQUIRED)
70 MESSAGE(STATUS "Found Gettext: ${GETTEXT_SOURCE}")
71 INCLUDE_DIRECTORIES(${GETTEXT_INCLUDE_DIR})
73 MESSAGE( FATAL_ERROR "Gettext not found" )
76 FIND_PACKAGE(Hal REQUIRED)
78 MESSAGE( FATAL_ERROR " Hal not found" )
80 INCLUDE_DIRECTORIES(${HAL_INCLUDE_DIR})
81 # hal/libhal-storage.h is broken grrr
82 INCLUDE_DIRECTORIES(${HAL_INCLUDE_DIR}/hal)
85 FIND_PACKAGE(Dbus REQUIRED)
87 MESSAGE( FATAL_ERROR " dbus not found" )
88 ELSE ( NOT DBUS_FOUND)
89 INCLUDE_DIRECTORIES(${DBUS_INCLUDE_DIR})
90 INCLUDE_DIRECTORIES(${DBUS_ARCH_INCLUDE_DIR})
91 ENDIF( NOT DBUS_FOUND)
93 FIND_PACKAGE(Curl REQUIRED)
95 MESSAGE( FATAL_ERROR " curl not found" )
96 ELSE ( NOT CURL_FOUND)
97 INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIR})
98 ENDIF( NOT CURL_FOUND)
100 FIND_PACKAGE(Libxml REQUIRED)
101 IF ( NOT LIBXML_FOUND)
102 MESSAGE( FATAL_ERROR " libxml not found" )
103 ELSE ( NOT LIBXML_FOUND)
104 INCLUDE_DIRECTORIES(${LIBXML_INCLUDE_DIR})
105 ENDIF( NOT LIBXML_FOUND)
107 FIND_PACKAGE(ZLIB REQUIRED)
109 MESSAGE( FATAL_ERROR " zlib not found" )
110 ELSE ( NOT ZLIB_FOUND)
111 INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
112 ENDIF( NOT ZLIB_FOUND)
114 FIND_PACKAGE(Satsolver REQUIRED)
115 IF ( NOT SATSOLVER_FOUND )
116 MESSAGE( FATAL_ERROR " libsatsolver not found" )
117 ELSE ( NOT SATSOLVER_FOUND )
118 INCLUDE_DIRECTORIES( ${SATSOLVER_INCLUDE_DIR} )
119 ENDIF( NOT SATSOLVER_FOUND )
121 # satsolver uses expat and has open references to it:
122 FIND_PACKAGE(EXPAT REQUIRED)
124 FIND_PACKAGE(OpenSSL REQUIRED)
126 FIND_PROGRAM( DOXYGEN doxygen )
128 MESSAGE( FATAL_ERROR "doxygen not found: install doxygen to build the documentation." )
130 MESSAGE( STATUS "doxygen found: ${DOXYGEN}" )
131 ENDIF ( NOT DOXYGEN )
133 MESSAGE(STATUS "soname: ${LIBZYPP_VERSION_INFO}")
134 MESSAGE(STATUS "version: ${VERSION}")
136 MESSAGE(STATUS "Writing pkg-config file...")
137 CONFIGURE_FILE(${LIBZYPP_SOURCE_DIR}/libzypp.pc.cmake ${LIBZYPP_BINARY_DIR}/libzypp.pc @ONLY)
138 INSTALL( FILES ${LIBZYPP_BINARY_DIR}/libzypp.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig )
140 MESSAGE(STATUS "FindZypp.cmake will be installed in ${CMAKE_INSTALL_PREFIX}/share/cmake/Modules")
141 INSTALL( FILES ${LIBZYPP_SOURCE_DIR}/cmake/modules/FindZypp.cmake DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cmake/Modules )
142 INSTALL( FILES ${LIBZYPP_SOURCE_DIR}/cmake/modules/ZyppCommon.cmake DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cmake/Modules )
144 ####################################################################
146 # (don't forget to mention them in the .spec file)
147 ####################################################################
149 MESSAGE(STATUS "zypp.conf will be installed in ${SYSCONFDIR}/zypp")
150 INSTALL( FILES ${LIBZYPP_SOURCE_DIR}/zypp.conf DESTINATION ${SYSCONFDIR}/zypp )
153 MESSAGE(STATUS "systemCheck will be installed in ${SYSCONFDIR}/zypp")
154 INSTALL( FILES ${LIBZYPP_SOURCE_DIR}/systemCheck DESTINATION ${SYSCONFDIR}/zypp )
156 # logrotate config file
157 INSTALL( FILES ${LIBZYPP_SOURCE_DIR}/zypp-history.lr DESTINATION ${SYSCONFDIR}/logrotate.d )
159 ####################################################################
161 ####################################################################
163 ADD_SUBDIRECTORY( zypp )
164 #ADD_SUBDIRECTORY( zypp2 )
165 # do not build devel by default
166 ADD_SUBDIRECTORY( devel EXCLUDE_FROM_ALL )
167 ADD_SUBDIRECTORY( tools )
168 #ADD_SUBDIRECTORY( examples )
169 ADD_SUBDIRECTORY( po EXCLUDE_FROM_ALL )
170 ADD_SUBDIRECTORY( doc )
171 ADD_SUBDIRECTORY( vendor )
172 ADD_SUBDIRECTORY( tests EXCLUDE_FROM_ALL )