3 CMAKE_MINIMUM_REQUIRED (VERSION 2.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)
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 OPTION (ENABLE_TCL "Build the Tcl bindings?" OFF)
13 OPTION (USE_VENDORDIRS "Install the bindings in vendor directories?" OFF)
15 OPTION (ENABLE_RPMDB "Build with rpm database support?" OFF)
16 OPTION (ENABLE_RPMPKG "Build with rpm package support?" OFF)
17 OPTION (ENABLE_PUBKEY "Build with pubkey support?" OFF)
18 OPTION (ENABLE_RPMDB_BYRPMHEADER "Build with rpmdb Header support?" OFF)
19 OPTION (ENABLE_RPMDB_LIBRPM "Use librpm to access the rpm database?" OFF)
20 OPTION (ENABLE_RPMPKG_LIBRPM "Use librpm to access rpm header information?" OFF)
21 OPTION (ENABLE_RPMMD "Build with rpmmd repository support?" OFF)
22 OPTION (ENABLE_SUSEREPO "Build with suse repository support?" OFF)
23 OPTION (ENABLE_COMPS "Build with fedora comps support?" OFF)
24 OPTION (ENABLE_HELIXREPO "Build with helix repository support?" OFF)
25 OPTION (ENABLE_DEBIAN "Build with debian database/repository support?" OFF)
26 OPTION (ENABLE_MDKREPO "Build with mandriva/mageia repository support?" OFF)
27 OPTION (ENABLE_ARCHREPO "Build with archlinux repository support?" OFF)
28 OPTION (ENABLE_CUDFREPO "Build with cudf repository support?" OFF)
29 OPTION (ENABLE_HAIKU "Build with Haiku package support?" OFF)
30 OPTION (ENABLE_APPDATA "Build with AppStream appdata support?" OFF)
32 OPTION (MULTI_SEMANTICS "Build with support for multiple distribution types?" OFF)
34 OPTION (ENABLE_LZMA_COMPRESSION "Build with lzma/xz compression support?" OFF)
35 OPTION (ENABLE_BZIP2_COMPRESSION "Build with bzip2 compression support?" OFF)
37 OPTION (WITH_LIBXML2 "Build with libxml2 instead of libexpat?" OFF)
39 #IF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERISION} GREATER 2.4)
40 #ENDIF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERISION} GREATER 2.4)
42 IF (COMMAND cmake_policy)
43 # escape preprocessor, see -DVERSION below
44 CMAKE_POLICY (SET CMP0005 OLD)
45 ENDIF (COMMAND cmake_policy)
49 SET (LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${LIB}")
51 IF (CMAKE_SIZEOF_VOID_P MATCHES "8")
53 ENDIF (CMAKE_SIZEOF_VOID_P MATCHES "8")
54 SET (LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
56 MESSAGE (STATUS "Libraries will be installed in ${LIB_INSTALL_DIR}")
59 SET (INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${INCLUDE}")
60 else (DEFINED INCLUDE)
61 SET (INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include")
62 ENDIF (DEFINED INCLUDE)
63 MESSAGE (STATUS "Header files will be installed in ${INCLUDE_INSTALL_DIR}")
64 SET (BIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin")
65 IF (NOT MAN_INSTALL_DIR)
66 SET (MAN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/man")
67 IF (IS_DIRECTORY "${CMAKE_INSTALL_PREFIX}/man" AND NOT IS_DIRECTORY "${CMAKE_INSTALL_PREFIX}/share/man")
68 SET (MAN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/man")
69 ENDIF (IS_DIRECTORY "${CMAKE_INSTALL_PREFIX}/man" AND NOT IS_DIRECTORY "${CMAKE_INSTALL_PREFIX}/share/man")
70 ENDIF (NOT MAN_INSTALL_DIR)
71 MESSAGE(STATUS "Man pages will be installed in ${MAN_INSTALL_DIR}")
73 IF (NOT PKGCONFIG_INSTALL_DIR)
74 SET (PKGCONFIG_INSTALL_DIR ${LIB_INSTALL_DIR}/pkgconfig)
75 ENDIF (NOT PKGCONFIG_INSTALL_DIR)
76 ####################################################################
78 ####################################################################
80 # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
81 SET (CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
82 INSTALL( FILES ${CMAKE_MODULE_PATH}/FindLibSolv.cmake DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cmake/Modules )
84 INCLUDE (${CMAKE_SOURCE_DIR}/VERSION.cmake)
89 MESSAGE(STATUS "Building for Fedora")
90 ADD_DEFINITIONS (-DFEDORA)
93 SET (have_system ${have_system}x)
97 MESSAGE (STATUS "Building for Debian")
98 ADD_DEFINITIONS (-DDEBIAN)
99 SET (ENABLE_DEBIAN ON)
100 SET (have_system ${have_system}x)
104 MESSAGE (STATUS "Building for SUSE")
105 ADD_DEFINITIONS (-DSUSE)
106 SET (ENABLE_RPMDB ON)
107 SET (ENABLE_PUBKEY ON)
108 SET (ENABLE_RPMDB_BYRPMHEADER ON)
109 SET (ENABLE_RPMMD ON)
110 SET (ENABLE_SUSEREPO ON)
111 SET (ENABLE_HELIXREPO ON)
112 SET (ENABLE_LINKED_PKGS ON)
113 SET (have_system ${have_system}x)
117 MESSAGE (STATUS "Building for Archlinux")
118 ADD_DEFINITIONS (-DARCHLINUX)
119 SET (ENABLE_ARCHREPO ON)
120 SET (have_system ${have_system}x)
124 MESSAGE (STATUS "Building for Mandriva")
125 ADD_DEFINITIONS (-DMANDRIVA)
126 SET (ENABLE_MDKREPO ON)
127 SET (ENABLE_RPMDB ON)
128 SET (have_system ${have_system}x)
132 MESSAGE (STATUS "Building for Mageia")
133 ADD_DEFINITIONS (-DMAGEIA)
134 SET (ENABLE_MDKREPO ON)
135 SET (ENABLE_RPMDB ON)
136 SET (ENABLE_RPMMD ON)
137 SET (ENABLE_LZMA_COMPRESSION ON)
138 SET (have_system ${have_system}x)
142 MESSAGE(STATUS "Building for Haiku")
143 FIND_LIBRARY(HAIKU_BE_LIBRARY NAMES be)
144 FIND_LIBRARY(HAIKU_NETWORK_LIBRARY NAMES network)
145 FIND_LIBRARY(HAIKU_PACKAGE_LIBRARY NAMES package)
146 SET (HAIKU_SYSTEM_LIBRARIES
147 ${HAIKU_BE_LIBRARY} ${HAIKU_NETWORK_LIBRARY} ${HAIKU_PACKAGE_LIBRARY})
148 ADD_DEFINITIONS (-DHAIKU)
149 SET (ENABLE_HAIKU ON)
150 SET (have_system ${have_system}x)
153 IF (${have_system} STREQUAL x)
154 MESSAGE (STATUS "Building for no system")
155 ENDIF (${have_system} STREQUAL x)
156 IF (${have_system} STRGREATER xx)
157 MESSAGE (FATAL_ERROR "Can only compile for one system type.")
158 ENDIF (${have_system} STRGREATER xx)
160 SET (ENABLE_ZLIB_COMPRESSION ON)
161 IF (ENABLE_ARCHREPO OR ENABLE_DEBIAN)
162 SET (ENABLE_LZMA_COMPRESSION ON)
163 ENDIF (ENABLE_ARCHREPO OR ENABLE_DEBIAN)
165 IF (ENABLE_RPMMD OR ENABLE_SUSEREPO OR ENABLE_APPDATA OR ENABLE_COMPS OR ENABLE_HELIXREPO OR ENABLE_MDKREPO)
167 FIND_PACKAGE (LibXml2 REQUIRED)
168 INCLUDE_DIRECTORIES (${LIBXML2_INCLUDE_DIR})
170 FIND_PACKAGE (EXPAT REQUIRED)
171 INCLUDE_DIRECTORIES (${EXPAT_INCLUDE_DIRS})
172 ENDIF (WITH_LIBXML2 )
173 ENDIF (ENABLE_RPMMD OR ENABLE_SUSEREPO OR ENABLE_APPDATA OR ENABLE_COMPS OR ENABLE_HELIXREPO OR ENABLE_MDKREPO)
175 IF (ENABLE_ZLIB_COMPRESSION)
176 FIND_PACKAGE (ZLIB REQUIRED)
177 ENDIF (ENABLE_ZLIB_COMPRESSION)
179 IF (ENABLE_LZMA_COMPRESSION)
180 FIND_PACKAGE (LZMA REQUIRED)
181 ENDIF (ENABLE_LZMA_COMPRESSION)
183 IF (ENABLE_BZIP2_COMPRESSION)
184 FIND_PACKAGE (BZip2 REQUIRED)
185 ENDIF (ENABLE_BZIP2_COMPRESSION)
188 MESSAGE (STATUS "Enabling RPM 5 support")
189 ADD_DEFINITIONS (-DRPM5)
190 SET (ENABLE_RPMDB ON)
191 SET (ENABLE_RPMMD ON)
192 FIND_PACKAGE (PkgConfig REQUIRED)
193 PKG_CHECK_MODULES (RPM REQUIRED rpm)
194 INCLUDE_DIRECTORIES (${RPM_INCLUDE_DIRS})
198 MESSAGE (STATUS "Enabling multi dist support")
199 ENDIF (MULTI_SEMANTICS)
202 SET (ENABLE_RPMPKG ON)
205 INCLUDE (CheckIncludeFile)
206 IF (ENABLE_RPMDB OR ENABLE_RPMPKG_LIBRPM)
207 FIND_LIBRARY (RPMDB_LIBRARY NAMES rpmdb)
209 IF (NOT RPMDB_LIBRARY)
210 FIND_LIBRARY (RPMDB_LIBRARY NAMES rpm)
211 ENDIF (NOT RPMDB_LIBRARY)
213 FIND_LIBRARY (RPMIO_LIBRARY NAMES rpmio)
215 SET(RPMDB_LIBRARY ${RPMIO_LIBRARY} ${RPMDB_LIBRARY})
216 ENDIF (RPMIO_LIBRARY)
219 FIND_LIBRARY (RPMMISC_LIBRARY NAMES rpmmisc)
221 SET (RPMDB_LIBRARY ${RPMMISC_LIBRARY} ${RPMDB_LIBRARY})
222 ENDIF (RPMMISC_LIBRARY)
225 # check if rpm contains a bundled berkeley db
226 CHECK_INCLUDE_FILE(rpm/db.h HAVE_RPM_DB_H)
227 IF (NOT ENABLE_RPMDB_LIBRPM)
228 IF (NOT HAVE_RPM_DB_H)
229 FIND_LIBRARY (DB_LIBRARY NAMES db)
231 SET (RPMDB_LIBRARY ${DB_LIBRARY} ${RPMDB_LIBRARY})
234 INCLUDE_DIRECTORIES (${DB_INCLUDE_DIR})
235 ENDIF (DB_INCLUDE_DIR)
236 ENDIF (NOT HAVE_RPM_DB_H)
237 ENDIF (NOT ENABLE_RPMDB_LIBRPM)
238 INCLUDE (CheckLibraryExists)
239 CHECK_LIBRARY_EXISTS(rpmio pgpDigGetParams "" HAVE_PGPDIGGETPARAMS)
240 ENDIF (ENABLE_RPMDB OR ENABLE_RPMPKG_LIBRPM)
243 SET (ENABLE_PGPVRFY ON)
244 ENDIF (ENABLE_PUBKEY)
246 INCLUDE (CheckFunctionExists)
247 INCLUDE (TestBigEndian)
249 CHECK_FUNCTION_EXISTS (strchrnul HAVE_STRCHRNUL)
250 CHECK_FUNCTION_EXISTS (fopencookie HAVE_FOPENCOOKIE)
251 CHECK_FUNCTION_EXISTS (funopen HAVE_FUNOPEN)
252 TEST_BIG_ENDIAN (WORDS_BIGENDIAN)
254 IF (${CMAKE_MAJOR_VERSION} GREATER 2)
255 INCLUDE (CMakePushCheckState)
256 INCLUDE (CheckCCompilerFlag)
257 MACRO (check_linker_flag FLAG VAR)
258 CMAKE_PUSH_CHECK_STATE (RESET)
259 SET (CMAKE_REQUIRED_FLAGS "${FLAG}")
260 CHECK_C_COMPILER_FLAG ("" "${VAR}")
261 CMAKE_POP_CHECK_STATE ()
262 ENDMACRO (check_linker_flag)
263 check_linker_flag("-Wl,--as-needed" HAVE_LINKER_AS_NEEDED)
264 check_linker_flag("-Wl,--version-script=${CMAKE_SOURCE_DIR}/src/libsolv.ver" HAVE_LINKER_VERSION_SCRIPT)
265 ELSE (${CMAKE_MAJOR_VERSION} GREATER 2)
266 SET (HAVE_LINKER_AS_NEEDED 1)
267 SET (HAVE_LINKER_VERSION_SCRIPT 1)
268 ENDIF (${CMAKE_MAJOR_VERSION} GREATER 2)
270 # should create config.h with #cmakedefine instead...
271 FOREACH (VAR HAVE_STRCHRNUL HAVE_FOPENCOOKIE HAVE_FUNOPEN WORDS_BIGENDIAN
272 HAVE_RPM_DB_H HAVE_PGPDIGGETPARAMS WITH_LIBXML2 )
274 ADD_DEFINITIONS (-D${VAR}=1)
275 SET (SWIG_FLAGS ${SWIG_FLAGS} -D${VAR})
280 ENABLE_LINKED_PKGS ENABLE_COMPLEX_DEPS MULTI_SEMANTICS)
282 ADD_DEFINITIONS (-D${VAR}=1)
283 SET (SWIG_FLAGS ${SWIG_FLAGS} -D${VAR})
284 STRING(REPLACE ENABLE_ "" VARX ${VAR})
285 SET (LIBSOLV_FEATURE_${VARX} 1)
290 ENABLE_RPMDB ENABLE_RPMPKG ENABLE_PUBKEY ENABLE_RPMMD
291 ENABLE_RPMPKG_LIBRPM ENABLE_RPMDB_LIBRPM ENABLE_RPMDB_BYRPMHEADER
292 ENABLE_SUSEREPO ENABLE_COMPS ENABLE_TESTCASE_HELIXREPO
293 ENABLE_HELIXREPO ENABLE_MDKREPO ENABLE_ARCHREPO ENABLE_DEBIAN ENABLE_HAIKU
294 ENABLE_ZLIB_COMPRESSION ENABLE_LZMA_COMPRESSION ENABLE_BZIP2_COMPRESSION
295 ENABLE_PGPVRFY ENABLE_APPDATA)
297 ADD_DEFINITIONS (-D${VAR}=1)
298 SET (SWIG_FLAGS ${SWIG_FLAGS} -D${VAR})
299 STRING(REPLACE ENABLE_ "" VARX ${VAR})
300 SET (LIBSOLVEXT_FEATURE_${VARX} 1)
304 SET (PACKAGE "libsolv")
305 SET (VERSION "${LIBSOLV_MAJOR}.${LIBSOLV_MINOR}.${LIBSOLV_PATCH}")
307 ADD_DEFINITIONS (-D_FILE_OFFSET_BITS=64)
308 ADD_DEFINITIONS (-DVERSION=\\\"${VERSION}\\\")
309 CONFIGURE_FILE (src/solvversion.h.in src/solvversion.h)
311 SET (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Package dependency solver library")
312 SET (CPACK_PACKAGE_VENDOR "SUSE")
313 SET (CPACK_PACKAGE_VERSION_MAJOR ${LIBSOLV_MAJOR})
314 SET (CPACK_PACKAGE_VERSION_MINOR ${LIBSOLV_MINOR})
315 SET (CPACK_PACKAGE_VERSION_PATCH ${LIBSOLV_PATCH})
316 SET (CPACK_GENERATOR "TBZ2")
317 SET (CPACK_SOURCE_GENERATOR "TBZ2")
318 SET (CPACK_SOURCE_PACKAGE_FILE_NAME "${PACKAGE}-${VERSION}")
319 SET (CPACK_SOURCE_TOPLEVEL_TAG "Linux-Source:")
320 SET (CPACK_TOPLEVEL_TAG "Linux-Source:")
322 # The following components are regex's to match anywhere (unless anchored)
323 # in absolute path + filename to find files or directories to be excluded
324 # from source tarball.
325 SET (CPACK_SOURCE_IGNORE_FILES
350 "DartConfiguration.tcl$"
353 "cmake_install.cmake$"
354 "CMakeLists.txt.auto$"
355 "CTestTestfile.cmake"
357 "CPackSourceConfig.cmake$"
363 ####################################################################
365 ####################################################################
367 #SET (CMAKE_INCLUDE_DIRECTORIES_BEFORE ON)
368 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 )
370 ####################################################################
372 MESSAGE (STATUS "Looking for modules in ${CMAKE_MODULE_PATH}")
374 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
375 set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -O3")
376 set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS} -g -O3")
377 set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g3 -O0")
379 # set system libraries
380 SET (SYSTEM_LIBRARIES "")
381 IF (ENABLE_RPMMD OR ENABLE_SUSEREPO OR ENABLE_APPDATA OR ENABLE_COMPS OR ENABLE_HELIXREPO OR ENABLE_MDKREPO)
383 SET (SYSTEM_LIBRARIES ${SYSTEM_LIBRARIES} ${LIBXML2_LIBRARIES})
385 SET (SYSTEM_LIBRARIES ${SYSTEM_LIBRARIES} ${EXPAT_LIBRARY})
386 ENDIF (WITH_LIBXML2 )
388 ENDIF (ENABLE_RPMMD OR ENABLE_SUSEREPO OR ENABLE_APPDATA OR ENABLE_COMPS OR ENABLE_HELIXREPO OR ENABLE_MDKREPO)
389 IF (ENABLE_ZLIB_COMPRESSION)
390 SET (SYSTEM_LIBRARIES ${SYSTEM_LIBRARIES} ${ZLIB_LIBRARY})
391 ENDIF (ENABLE_ZLIB_COMPRESSION)
392 IF (ENABLE_LZMA_COMPRESSION)
393 SET (SYSTEM_LIBRARIES ${SYSTEM_LIBRARIES} ${LZMA_LIBRARY})
394 ENDIF (ENABLE_LZMA_COMPRESSION)
395 IF (ENABLE_BZIP2_COMPRESSION)
396 SET (SYSTEM_LIBRARIES ${SYSTEM_LIBRARIES} ${BZIP2_LIBRARIES})
397 ENDIF (ENABLE_BZIP2_COMPRESSION)
399 SET (SYSTEM_LIBRARIES ${RPMDB_LIBRARY} ${SYSTEM_LIBRARIES})
402 SET (SYSTEM_LIBRARIES ${HAIKU_SYSTEM_LIBRARIES} ${SYSTEM_LIBRARIES})
404 IF (HAVE_LINKER_AS_NEEDED)
405 SET (SYSTEM_LIBRARIES "-Wl,--as-needed" ${SYSTEM_LIBRARIES})
406 ENDIF (HAVE_LINKER_AS_NEEDED)
408 ADD_SUBDIRECTORY (src)
409 ADD_SUBDIRECTORY (ext)
410 ADD_SUBDIRECTORY (tools)
411 IF (ENABLE_PERL OR ENABLE_PYTHON OR ENABLE_RUBY OR ENABLE_TCL)
412 ADD_SUBDIRECTORY (bindings)
413 ENDIF (ENABLE_PERL OR ENABLE_PYTHON OR ENABLE_RUBY OR ENABLE_TCL)
414 ADD_SUBDIRECTORY (examples)
415 ADD_SUBDIRECTORY (doc)
417 MESSAGE (STATUS "Version: ${VERSION}")
419 ####################################################################
421 ####################################################################
424 MESSAGE (STATUS "Writing spec file...")
425 CONFIGURE_FILE (${CMAKE_SOURCE_DIR}/package/libsolv.spec.in ${CMAKE_BINARY_DIR}/package/libsolv.spec @ONLY)
429 MESSAGE (STATUS "Writing pkg-config files...")
430 CONFIGURE_FILE (${CMAKE_SOURCE_DIR}/libsolv.pc.in ${CMAKE_BINARY_DIR}/libsolv.pc @ONLY)
431 INSTALL( FILES ${CMAKE_BINARY_DIR}/libsolv.pc DESTINATION ${PKGCONFIG_INSTALL_DIR} )
432 CONFIGURE_FILE (${CMAKE_SOURCE_DIR}/libsolvext.pc.in ${CMAKE_BINARY_DIR}/libsolvext.pc @ONLY)
433 INSTALL( FILES ${CMAKE_BINARY_DIR}/libsolvext.pc DESTINATION ${PKGCONFIG_INSTALL_DIR} )
439 SET (AUTOBUILD_COMMAND
440 COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_BINARY_DIR}/package/*.tar.bz2
441 COMMAND mkdir -p _CPack_Packages/${CPACK_TOPLEVEL_TAG}
442 COMMAND ${CMAKE_MAKE_PROGRAM} package_source
443 COMMAND ${CMAKE_COMMAND} -E copy ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2 ${CMAKE_BINARY_DIR}/package
444 COMMAND ${CMAKE_COMMAND} -E remove ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2
445 COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/package/libsolv.changes" "${CMAKE_BINARY_DIR}/package/libsolv.changes"
448 ADD_CUSTOM_TARGET (srcpackage
452 ADD_CUSTOM_TARGET (srcpackage_local
457 ADD_SUBDIRECTORY (test)