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