constify solv_pgpvrfy
[platform/upstream/libsolv.git] / CMakeLists.txt
1 PROJECT (libsolv)
2
3 CMAKE_MINIMUM_REQUIRED (VERSION 2.4)
4
5 OPTION (ENABLE_STATIC "Build a static version of the libraries?" OFF)
6 OPTION (DISABLE_SHARED "Do not build a shared version of the libraries?" OFF)
7
8 OPTION (ENABLE_PERL "Build the perl bindings?" OFF)
9 OPTION (ENABLE_PYTHON "Build the python bindings?" OFF)
10 OPTION (ENABLE_RUBY "Build the ruby bindings?" OFF)
11
12 OPTION (USE_VENDORDIRS "Install the bindings in vendor directories?" OFF)
13
14 OPTION (ENABLE_RPMDB "Build with rpm database support?" OFF)
15 OPTION (ENABLE_PUBKEY "Build with pubkey support?" OFF)
16 OPTION (ENABLE_RPMDB_BYRPMHEADER "Build with rpmdb Header support?" OFF)
17 OPTION (ENABLE_RPMMD "Build with rpmmd repository support?" OFF)
18 OPTION (ENABLE_SUSEREPO "Build with suse repository support?" OFF)
19 OPTION (ENABLE_COMPS "Build with fedora comps support?" OFF)
20 OPTION (ENABLE_HELIXREPO "Build with helix repository support?" OFF)
21 OPTION (ENABLE_DEBIAN "Build with debian database/repository support?" OFF)
22 OPTION (ENABLE_MDKREPO "Build with mandriva/mageia repository support?" OFF)
23 OPTION (ENABLE_ARCHREPO "Build with archlinux repository support?" OFF)
24 OPTION (ENABLE_CUDFREPO "Build with cudf repository support?" OFF)
25 OPTION (ENABLE_HAIKU "Build with Haiku package support?" OFF)
26
27 OPTION (ENABLE_LZMA_COMPRESSION "Build with lzma/xz compression support?" OFF)
28 OPTION (ENABLE_BZIP2_COMPRESSION "Build with bzip2 compression support?" OFF)
29
30 #IF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERISION} GREATER 2.4)
31 #ENDIF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERISION} GREATER 2.4)
32
33 IF (COMMAND cmake_policy)
34   # escape preprocessor, see -DVERSION below
35   CMAKE_POLICY (SET CMP0005 OLD)
36 ENDIF (COMMAND cmake_policy)
37
38 # Library
39 IF (DEFINED LIB)
40   SET (LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${LIB}")
41 ELSE (DEFINED  LIB)
42   IF (CMAKE_SIZEOF_VOID_P MATCHES "8")
43     SET (LIB_SUFFIX "64")
44   ENDIF (CMAKE_SIZEOF_VOID_P MATCHES "8")
45   SET (LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
46 ENDIF (DEFINED  LIB)
47 MESSAGE (STATUS "Libraries will be installed in ${LIB_INSTALL_DIR}")
48 SET (BIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin")
49 SET (MAN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/man")
50 IF (IS_DIRECTORY "${CMAKE_INSTALL_PREFIX}/share/man"  AND NOT IS_DIRECTORY "${CMAKE_INSTALL_PREFIX}/man")
51   SET (MAN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/man")
52 ENDIF (IS_DIRECTORY "${CMAKE_INSTALL_PREFIX}/share/man"  AND NOT IS_DIRECTORY "${CMAKE_INSTALL_PREFIX}/man")
53 MESSAGE(STATUS "Man pages will be installed in ${MAN_INSTALL_DIR}")
54
55 ####################################################################
56 # CONFIGURATION                                                    #
57 ####################################################################
58
59 # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
60 SET (CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
61 INSTALL( FILES ${CMAKE_MODULE_PATH}/FindLibSolv.cmake DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cmake/Modules )
62
63 INCLUDE (${CMAKE_SOURCE_DIR}/VERSION.cmake)
64
65 SET (have_system x)
66
67 IF (FEDORA)
68 MESSAGE(STATUS "Building for Fedora")
69 ADD_DEFINITIONS (-DFEDORA)
70 SET (ENABLE_RPMDB ON)
71 SET (ENABLE_RPMMD ON)
72 SET (have_system ${have_system}x)
73 ENDIF (FEDORA)
74
75 IF (DEBIAN)
76 MESSAGE (STATUS "Building for Debian")
77 ADD_DEFINITIONS (-DDEBIAN)
78 SET (ENABLE_DEBIAN ON)
79 SET (have_system ${have_system}x)
80 ENDIF (DEBIAN)
81
82 IF (SUSE)
83 MESSAGE (STATUS "Building for SUSE")
84 ADD_DEFINITIONS (-DSUSE)
85 SET (ENABLE_RPMDB ON)
86 SET (ENABLE_PUBKEY ON)
87 SET (ENABLE_RPMDB_BYRPMHEADER ON)
88 SET (ENABLE_RPMMD ON)
89 SET (ENABLE_SUSEREPO ON)
90 SET (ENABLE_HELIXREPO ON)
91 SET (have_system ${have_system}x)
92 ENDIF (SUSE)
93
94 IF (ARCHLINUX)
95 MESSAGE (STATUS "Building for Archlinux")
96 ADD_DEFINITIONS (-DARCHLINUX)
97 SET (ENABLE_ARCHREPO ON)
98 SET (have_system ${have_system}x)
99 ENDIF (ARCHLINUX)
100
101 IF (MANDRIVA)
102 MESSAGE (STATUS "Building for Mandriva/Mageia")
103 ADD_DEFINITIONS (-DMANDRIVA)
104 SET (ENABLE_MDKREPO ON)
105 SET (ENABLE_RPMDB ON)
106 SET (have_system ${have_system}x)
107 ENDIF (MANDRIVA)
108
109 IF (HAIKU)
110 MESSAGE(STATUS "Building for Haiku")
111 FIND_LIBRARY(HAIKU_BE_LIBRARY NAMES be)
112 FIND_LIBRARY(HAIKU_NETWORK_LIBRARY NAMES network)
113 FIND_LIBRARY(HAIKU_PACKAGE_LIBRARY NAMES package)
114 SET (HAIKU_SYSTEM_LIBRARIES
115     ${HAIKU_BE_LIBRARY} ${HAIKU_NETWORK_LIBRARY} ${HAIKU_PACKAGE_LIBRARY})
116 ADD_DEFINITIONS (-DHAIKU)
117 SET (ENABLE_HAIKU ON)
118 SET (have_system ${have_system}x)
119 ENDIF (HAIKU)
120
121 IF (${have_system} STREQUAL x)
122     MESSAGE (STATUS "Building for no system")
123     ADD_DEFINITIONS (-DNOSYSTEM)
124 ENDIF (${have_system} STREQUAL x)
125 IF (${have_system} STRGREATER xx)
126     MESSAGE (FATAL_ERROR "Can only compile for one system type.")
127 ENDIF (${have_system} STRGREATER xx)
128
129 IF (ENABLE_ARCHREPO)
130 SET (ENABLE_LZMA_COMPRESSION ON)
131 ENDIF (ENABLE_ARCHREPO)
132
133 FIND_PACKAGE (EXPAT REQUIRED)
134 FIND_PACKAGE (ZLIB REQUIRED)
135 IF (ENABLE_LZMA_COMPRESSION)
136 FIND_PACKAGE (LZMA REQUIRED)
137 ENDIF (ENABLE_LZMA_COMPRESSION)
138 IF (ENABLE_BZIP2_COMPRESSION)
139 FIND_PACKAGE (BZip2 REQUIRED)
140 ENDIF (ENABLE_BZIP2_COMPRESSION)
141
142 IF (RPM5)
143 MESSAGE (STATUS "Enabling RPM 5 support")
144 ADD_DEFINITIONS (-DRPM5)
145 SET (ENABLE_RPMDB ON)
146 SET (ENABLE_RPMMD ON)
147 FIND_PACKAGE (PkgConfig REQUIRED)
148 PKG_CHECK_MODULES (RPM REQUIRED rpm)
149 INCLUDE_DIRECTORIES (${RPM_INCLUDE_DIRS})
150 ENDIF (RPM5)
151
152 IF (MULTI_SEMANTICS)
153 MESSAGE (STATUS "Enabling multi dist support")
154 ADD_DEFINITIONS (-DMULTI_SEMANTICS)
155 ENDIF (MULTI_SEMANTICS)
156
157 INCLUDE (CheckIncludeFile)
158 IF (ENABLE_RPMDB)
159   FIND_LIBRARY (RPMDB_LIBRARY NAMES rpmdb)
160
161   IF (NOT RPMDB_LIBRARY)
162     FIND_LIBRARY (RPMDB_LIBRARY NAMES rpm)
163   ENDIF (NOT RPMDB_LIBRARY)
164
165   FIND_LIBRARY (RPMIO_LIBRARY NAMES rpmio)
166   IF (RPMIO_LIBRARY)
167     SET(RPMDB_LIBRARY ${RPMIO_LIBRARY} ${RPMDB_LIBRARY})
168   ENDIF (RPMIO_LIBRARY)
169
170   IF (RPM5)
171     FIND_LIBRARY (RPMMISC_LIBRARY NAMES rpmmisc)
172     IF (RPMMISC_LIBRARY)
173       SET (RPMDB_LIBRARY ${RPMMISC_LIBRARY} ${RPMDB_LIBRARY})
174     ENDIF (RPMMISC_LIBRARY)
175   ENDIF (RPM5)
176
177   # check if rpm contains a bundled berkeley db
178   CHECK_INCLUDE_FILE(rpm/db.h HAVE_RPM_DB_H)
179   IF (NOT HAVE_RPM_DB_H)
180     FIND_LIBRARY (DB_LIBRARY NAMES db)
181     IF (DB_LIBRARY)
182       SET (RPMDB_LIBRARY ${DB_LIBRARY} ${RPMDB_LIBRARY})
183     ENDIF (DB_LIBRARY)
184   ENDIF (NOT HAVE_RPM_DB_H)
185   INCLUDE (CheckLibraryExists)
186   CHECK_LIBRARY_EXISTS(rpmio pgpDigGetParams "" HAVE_PGPDIGGETPARAMS)
187 ENDIF (ENABLE_RPMDB)
188
189 IF (ENABLE_PUBKEY)
190   SET (ENABLE_PGPVRFY ON)
191 ENDIF (ENABLE_PUBKEY)
192
193 INCLUDE (CheckFunctionExists)
194 INCLUDE (TestBigEndian)
195
196 CHECK_FUNCTION_EXISTS (strchrnul HAVE_STRCHRNUL)
197 CHECK_FUNCTION_EXISTS (fopencookie HAVE_FOPENCOOKIE)
198 CHECK_FUNCTION_EXISTS (funopen HAVE_FUNOPEN)
199 TEST_BIG_ENDIAN (WORDS_BIGENDIAN)
200
201 # should create config.h with #cmakedefine instead...
202 FOREACH (VAR HAVE_STRCHRNUL HAVE_FOPENCOOKIE HAVE_FUNOPEN WORDS_BIGENDIAN
203   HAVE_RPM_DB_H HAVE_PGPDIGGETPARAMS
204   ENABLE_RPMDB ENABLE_PUBKEY ENABLE_RPMMD ENABLE_SUSEREPO ENABLE_COMPS
205   ENABLE_HELIXREPO ENABLE_MDKREPO ENABLE_ARCHREPO ENABLE_DEBIAN ENABLE_HAIKU
206   ENABLE_LZMA_COMPRESSION ENABLE_BZIP2_COMPRESSION ENABLE_PGPVRFY)
207   IF(${VAR})
208     ADD_DEFINITIONS (-D${VAR}=1)
209     SET (SWIG_FLAGS ${SWIG_FLAGS} -D${VAR})
210   ENDIF (${VAR})
211 ENDFOREACH (VAR)
212
213 SET (PACKAGE "libsolv")
214 SET (VERSION "${LIBSOLV_MAJOR}.${LIBSOLV_MINOR}.${LIBSOLV_PATCH}")
215
216 ADD_DEFINITIONS (-D_FILE_OFFSET_BITS=64)
217 ADD_DEFINITIONS (-DVERSION=\\\"${VERSION}\\\")
218 CONFIGURE_FILE (src/solvversion.h.in src/solvversion.h)
219
220 SET (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Package dependency solver library")
221 SET (CPACK_PACKAGE_VENDOR "SUSE")
222 SET (CPACK_PACKAGE_VERSION_MAJOR ${LIBSOLV_MAJOR})
223 SET (CPACK_PACKAGE_VERSION_MINOR ${LIBSOLV_MINOR})
224 SET (CPACK_PACKAGE_VERSION_PATCH ${LIBSOLV_PATCH})
225 SET (CPACK_GENERATOR "TBZ2")
226 SET (CPACK_SOURCE_GENERATOR "TBZ2")
227 SET (CPACK_SOURCE_PACKAGE_FILE_NAME "${PACKAGE}-${VERSION}")
228 SET (CPACK_SOURCE_TOPLEVEL_TAG "Linux-Source:")
229 SET (CPACK_TOPLEVEL_TAG "Linux-Source:")
230
231 # The following components are regex's to match anywhere (unless anchored)
232 # in absolute path + filename to find files or directories to be excluded
233 # from source tarball.
234 SET (CPACK_SOURCE_IGNORE_FILES
235 # temporary files
236 "\\\\.swp$"
237 # backup files
238 "~$"
239 # eclipse files
240 "\\\\.cdtproject$"
241 "\\\\.cproject$"
242 "\\\\.project$"
243 "\\\\.settings/"
244 # others
245 "\\\\.#"
246 "/#"
247 "/build/"
248 "/_build/"
249 "/\\\\.git/"
250 # used before
251 "/\\\\.libs/"
252 "/\\\\.deps/"
253 "\\\\.o$"
254 "\\\\.lo$"
255 "\\\\.la$"
256 "Makefile$"
257 "Makefile\\\\.in$"
258 # cmake cache files
259 "DartConfiguration.tcl$"
260 "CMakeCache.txt"
261 "CMakeFiles"
262 "cmake_install.cmake$"
263 "CMakeLists.txt.auto$"
264 "CTestTestfile.cmake"
265 "CPackConfig.cmake$"
266 "CPackSourceConfig.cmake$"
267 "libsolv.spec$"
268 )
269
270 INCLUDE(CPack)
271
272 ####################################################################
273 # INCLUDES                                                         #
274 ####################################################################
275
276 #SET (CMAKE_INCLUDE_DIRECTORIES_BEFORE ON)
277 INCLUDE_DIRECTORIES (${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/ext ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BINARY_DIR}/src SYSTEM )
278
279 ####################################################################
280
281 MESSAGE (STATUS "Looking for modules in ${CMAKE_MODULE_PATH}")
282
283 set (CMAKE_C_FLAGS     "${CMAKE_C_FLAGS} -Wall")
284 set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -O3")
285 set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS} -g -O3")
286 set (CMAKE_C_FLAGS_DEBUG     "${CMAKE_C_FLAGS} -g3 -O0")
287
288 SET (SYSTEM_LIBRARIES "-Wl,--as-needed" ${EXPAT_LIBRARY} ${ZLIB_LIBRARY})
289 IF (ENABLE_LZMA_COMPRESSION)
290 SET (SYSTEM_LIBRARIES ${SYSTEM_LIBRARIES} ${LZMA_LIBRARY})
291 ENDIF (ENABLE_LZMA_COMPRESSION)
292 IF (ENABLE_BZIP2_COMPRESSION)
293 SET (SYSTEM_LIBRARIES ${SYSTEM_LIBRARIES} ${BZIP2_LIBRARIES})
294 ENDIF (ENABLE_BZIP2_COMPRESSION)
295 IF (ENABLE_RPMDB)
296 SET (SYSTEM_LIBRARIES ${RPMDB_LIBRARY} ${SYSTEM_LIBRARIES})
297 ENDIF (ENABLE_RPMDB)
298 IF (ENABLE_HAIKU)
299 SET (SYSTEM_LIBRARIES ${HAIKU_SYSTEM_LIBRARIES} ${SYSTEM_LIBRARIES})
300 ENDIF (ENABLE_HAIKU)
301
302 ADD_SUBDIRECTORY (src)
303 ADD_SUBDIRECTORY (ext)
304 ADD_SUBDIRECTORY (tools)
305 IF (ENABLE_PERL OR ENABLE_PYTHON OR ENABLE_RUBY)
306     ADD_SUBDIRECTORY (bindings)
307 ENDIF (ENABLE_PERL OR ENABLE_PYTHON OR ENABLE_RUBY)
308 ADD_SUBDIRECTORY (examples)
309 ADD_SUBDIRECTORY (doc)
310
311 MESSAGE (STATUS "Version: ${VERSION}")
312
313 ####################################################################
314 # RPM SPEC                                                         #
315 ####################################################################
316
317 MACRO (SPECFILE)
318   MESSAGE (STATUS "Writing spec file...")
319   CONFIGURE_FILE (${CMAKE_SOURCE_DIR}/package/libsolv.spec.in ${CMAKE_BINARY_DIR}/package/libsolv.spec @ONLY)
320 ENDMACRO (SPECFILE)
321
322 SPECFILE ()
323
324 SET (AUTOBUILD_COMMAND
325   COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_BINARY_DIR}/package/*.tar.bz2
326   COMMAND mkdir -p _CPack_Packages/${CPACK_TOPLEVEL_TAG}
327   COMMAND ${CMAKE_MAKE_PROGRAM} package_source
328   COMMAND ${CMAKE_COMMAND} -E copy ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2 ${CMAKE_BINARY_DIR}/package
329   COMMAND ${CMAKE_COMMAND} -E remove ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2
330   COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/package/libsolv.changes" "${CMAKE_BINARY_DIR}/package/libsolv.changes"
331 )
332
333 ADD_CUSTOM_TARGET (srcpackage
334   ${AUTOBUILD_COMMAND}
335 )
336
337 ADD_CUSTOM_TARGET (srcpackage_local
338   ${AUTOBUILD_COMMAND}
339 )
340
341 ENABLE_TESTING()
342 ADD_SUBDIRECTORY (test)