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