make -devel require exact version
[platform/upstream/libzypp.git] / CMakeLists.txt
1 PROJECT(libzypp)
2
3 # Library
4 IF ( DEFINED LIB )
5   SET ( LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${LIB}" )
6 ELSE ( DEFINED  LIB )
7   IF ( EXISTS "${CMAKE_INSTALL_PREFIX}/lib64" )
8     SET( LIB_SUFFIX "64" )
9   ENDIF ( EXISTS "${CMAKE_INSTALL_PREFIX}/lib64" )
10   SET ( LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" )
11 ENDIF ( DEFINED  LIB )
12 MESSAGE(STATUS "Libraries will be installed in ${LIB_INSTALL_DIR}" )
13 ####################################################################
14 # CONFIGURATION                                                    #
15 ####################################################################
16
17 # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
18 SET( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules )
19
20 INCLUDE( ${CMAKE_SOURCE_DIR}/VERSION.cmake )
21 MATH( EXPR LIBZYPP_CURRENT "${LIBZYPP_MAJOR} * 100 + ${LIBZYPP_MINOR}" )
22 MATH( EXPR LIBZYPP_AGE     "${LIBZYPP_MINOR} - ${LIBZYPP_COMPATMINOR}" )
23
24 SET( PACKAGE "libzypp" )
25 SET( VERSION "${LIBZYPP_MAJOR}.${LIBZYPP_MINOR}.${LIBZYPP_PATCH}" )
26
27 ADD_DEFINITIONS( -DVERSION=\\\"${VERSION}\\\" )
28 SET( LIBZYPP_VERSION_INFO   "${LIBZYPP_CURRENT}.${LIBZYPP_PATCH}.${LIBZYPP_AGE}" )
29
30
31 SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Novell's package management core engine.")
32 SET(CPACK_PACKAGE_VENDOR "Novell Inc.")
33 #SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/ReadMe.txt")
34 #SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt")
35 SET(CPACK_PACKAGE_VERSION_MAJOR ${LIBZYPP_MAJOR})
36 SET(CPACK_PACKAGE_VERSION_MINOR ${LIBZYPP_MINOR})
37 SET(CPACK_PACKAGE_VERSION_PATCH ${LIBZYPP_PATCH})
38 SET( CPACK_GENERATOR "TBZ2")
39 SET( CPACK_SOURCE_GENERATOR "TBZ2")
40 SET( CPACK_SOURCE_PACKAGE_FILE_NAME "${PACKAGE}-${VERSION}" )
41
42 # The following components are regex's to match anywhere (unless anchored)
43 # in absolute path + filename to find files or directories to be excluded
44 # from source tarball.
45 SET (CPACK_SOURCE_IGNORE_FILES
46 #/CVS/;/\\.svn/;/\\.libs/;/\\.deps/;\\.swp$;/build/;\\.o$;\\.lo$;\\.la$;~$;\\\\.cvsignore$;Makefile\\\\.in$;
47 /CVS/;/\\\\.svn/;/\\\\.libs/;/\\\\.deps/;\\\\.swp$;/build/;\\\\.o$;\\\\.lo$;\\\\.la$;~$
48 )
49
50 INCLUDE(CPack)
51
52 ####################################################################
53
54 SET( DOC_INSTALL_DIR
55    "${CMAKE_INSTALL_PREFIX}/share/doc/packages/${PACKAGE}"
56    CACHE PATH "The install dir for documentation (default prefix/share/doc/packages/${PACKAGE})"
57    FORCE
58 )
59
60 ####################################################################
61
62 FIND_PACKAGE(Rpm REQUIRED)
63 IF ( NOT RPM_FOUND)
64   MESSAGE( FATAL_ERROR " rpm not found" )
65 ELSE ( NOT RPM_FOUND)
66   INCLUDE_DIRECTORIES(${RPM_INCLUDE_DIR})
67 ENDIF( NOT RPM_FOUND)
68
69 FIND_PACKAGE(Boost REQUIRED)
70 IF (Boost_FOUND)
71   MESSAGE( STATUS "boost found: includes in ${Boost_INCLUDE_DIRS}, library in ${Boost_LIBRARY_DIRS}")
72   INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
73   LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
74 ENDIF(Boost_FOUND)
75
76 FIND_PACKAGE(Gettext REQUIRED)
77 IF (GETTEXT_FOUND)
78   MESSAGE(STATUS "Found Gettext: ${GETTEXT_SOURCE}")
79   INCLUDE_DIRECTORIES(${GETTEXT_INCLUDE_DIR})
80 ELSE (GETTEXT_FOUND)
81   MESSAGE( FATAL_ERROR "Gettext not found" )
82 ENDIF (GETTEXT_FOUND)
83
84 FIND_PACKAGE(Hal REQUIRED)
85 IF ( NOT HAL_FOUND)
86   MESSAGE( FATAL_ERROR " Hal not found" )
87 ELSE ( NOT HAL_FOUND)
88   INCLUDE_DIRECTORIES(${HAL_INCLUDE_DIR})
89 # hal/libhal-storage.h is broken grrr
90   INCLUDE_DIRECTORIES(${HAL_INCLUDE_DIR}/hal)
91 ENDIF( NOT HAL_FOUND)
92
93 FIND_PACKAGE(Dbus REQUIRED)
94 IF ( NOT DBUS_FOUND)
95   MESSAGE( FATAL_ERROR " dbus not found" )
96 ELSE ( NOT DBUS_FOUND)
97   INCLUDE_DIRECTORIES(${DBUS_INCLUDE_DIR})
98   INCLUDE_DIRECTORIES(${DBUS_ARCH_INCLUDE_DIR})
99 ENDIF( NOT DBUS_FOUND)
100
101 FIND_PACKAGE(Glib REQUIRED)
102 IF (GLIB_FOUND)
103   MESSAGE( STATUS "glib found: includes in ${GLIB_INCLUDE_DIR}, library in ${GLIB_LIBRARY}")
104   INCLUDE_DIRECTORIES(${GLIB_INCLUDE_DIR})
105   INCLUDE_DIRECTORIES(${GLIB_CONFIG_INCLUDE_DIR})
106 ELSE(GLIB_FOUND)
107   MESSAGE( FATAL_ERROR "glib not found" )
108 ENDIF(GLIB_FOUND)
109
110 #IF (DBUS_GLIB_FOUND)
111 #  MESSAGE( STATUS "dbus-glib found" )
112 #  INCLUDE_DIRECTORIES(${DBUS_GLIB_INCLUDE_DIR})
113 #  LINK_DIRECTORIES(${DBUS_GLIB_LINK_DIR})
114 #ELSE(DBUS_GLIB_FOUND)
115 #  MESSAGE( ERROR "dbus-glib not found" )
116 #ENDIF(DBUS_GLIB_FOUND)
117
118 FIND_PACKAGE(Curl REQUIRED)
119 IF ( NOT CURL_FOUND)
120   MESSAGE( FATAL_ERROR " curl not found" )
121 ELSE ( NOT CURL_FOUND)
122   INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIR})
123 ENDIF( NOT CURL_FOUND)
124
125 FIND_PACKAGE(Libxml REQUIRED)
126 IF ( NOT LIBXML_FOUND)
127   MESSAGE( FATAL_ERROR " libxml not found" )
128 ELSE ( NOT LIBXML_FOUND)
129   INCLUDE_DIRECTORIES(${LIBXML_INCLUDE_DIR})
130 ENDIF( NOT LIBXML_FOUND)
131
132 FIND_PACKAGE(Sqlite REQUIRED)
133
134 FIND_PACKAGE(ZLIB REQUIRED)
135 IF ( NOT ZLIB_FOUND)
136   MESSAGE( FATAL_ERROR " zlib not found" )
137 ELSE ( NOT ZLIB_FOUND)
138   INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
139 ENDIF( NOT ZLIB_FOUND)
140
141 FIND_PROGRAM( DOXYGEN doxygen )
142 IF ( NOT DOXYGEN )
143   MESSAGE( FATAL_ERROR "doxygen not found: install doxygen to build the documentation." )
144 ELSE ( NOT DOXYGEN )
145   MESSAGE( STATUS "doxygen found: ${DOXYGEN}" )
146 ENDIF ( NOT DOXYGEN )
147
148 MESSAGE(STATUS "soname: ${LIBZYPP_CURRENT}.${LIBZYPP_PATCH}.${LIBZYPP_AGE}")
149 MESSAGE(STATUS "version: ${VERSION}")
150
151 ####################################################################
152 # RPM SPEC                                                         #
153 ####################################################################
154 MESSAGE(STATUS "Writing spec file...")
155 CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/libzypp.spec.cmake ${CMAKE_BINARY_DIR}/package/libzypp.spec @ONLY)
156
157 MESSAGE(STATUS "Writing pkg-config file...")
158 CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/libzypp.pc.cmake ${CMAKE_BINARY_DIR}/libzypp.pc @ONLY)
159 INSTALL( FILES ${CMAKE_BINARY_DIR}/libzypp.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig )
160
161 MESSAGE(STATUS "FindZypp.cmake will be installed in ${CMAKE_INSTALL_PREFIX}/share/cmake/Modules")
162 INSTALL( FILES ${CMAKE_SOURCE_DIR}/cmake/modules/FindZypp.cmake DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cmake/Modules )
163
164 ####################################################################
165 # SUBDIRECTORIES                                                   #
166 ####################################################################
167
168 ADD_SUBDIRECTORY( zypp )
169 ADD_SUBDIRECTORY( zypp2 )
170 # do not build devel by default
171 ADD_SUBDIRECTORY( devel EXCLUDE_FROM_ALL )
172 ADD_SUBDIRECTORY( tools )
173 #ADD_SUBDIRECTORY( examples )
174 ADD_SUBDIRECTORY( po EXCLUDE_FROM_ALL )
175 ADD_SUBDIRECTORY( doc EXCLUDE_FROM_ALL )
176
177 ####################################################################
178 # INCLUDES                                                         #
179 ####################################################################
180
181 INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
182
183 ####################################################################
184 # OTHERS                                                           #
185 ####################################################################
186
187 #configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h )
188 #yumschemadir=${zyppdir}/schema/yum
189 #xmlstoreschemadir=${zyppdir}/schema/xmlstore
190
191 ####################################################################
192 # INSTALL                                                          #
193 ####################################################################
194
195 #INSTALL_FILES(  FILES  libzypp.pc )
196
197 ADD_CUSTOM_TARGET( svncheck
198   COMMAND cd $(CMAKE_SOURCE_DIR) && ! LC_ALL=C svn status --show-updates --quiet | grep -v '^Status against revision'
199 )
200
201 SET( AUTOBUILD_COMMAND
202   COMMAND ${CMAKE_MAKE_PROGRAM} package_source
203   COMMAND ${CMAKE_COMMAND} -E copy ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2 ${CMAKE_BINARY_DIR}/package
204   COMMAND ${CMAKE_COMMAND} -E remove ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2
205   COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/package/${PACKAGE}.changes" "${CMAKE_BINARY_DIR}/package/${PACKAGE}.changes"
206 )
207
208 ADD_CUSTOM_TARGET( autobuild_local
209   ${AUTOBUILD_COMMAND}
210 )
211
212 ADD_CUSTOM_TARGET( autobuild
213   COMMAND ${CMAKE_MAKE_PROGRAM} svncheck
214   ${AUTOBUILD_COMMAND}
215 )