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)
12 OPTION (USE_VENDORDIRS "Install the bindings in vendor directories?" OFF)
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 OPTION (ENABLE_APPDATA "Build with AppStream appdata support?" OFF)
28 OPTION (ENABLE_LZMA_COMPRESSION "Build with lzma/xz compression support?" OFF)
29 OPTION (ENABLE_BZIP2_COMPRESSION "Build with bzip2 compression support?" OFF)
31 #IF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERISION} GREATER 2.4)
32 #ENDIF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERISION} GREATER 2.4)
34 IF (COMMAND cmake_policy)
35 # escape preprocessor, see -DVERSION below
36 CMAKE_POLICY (SET CMP0005 OLD)
37 ENDIF (COMMAND cmake_policy)
41 SET (LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${LIB}")
43 IF (CMAKE_SIZEOF_VOID_P MATCHES "8")
45 ENDIF (CMAKE_SIZEOF_VOID_P MATCHES "8")
46 SET (LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
48 MESSAGE (STATUS "Libraries will be installed in ${LIB_INSTALL_DIR}")
49 SET (BIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin")
50 SET (MAN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/man")
51 IF (IS_DIRECTORY "${CMAKE_INSTALL_PREFIX}/share/man" AND NOT IS_DIRECTORY "${CMAKE_INSTALL_PREFIX}/man")
52 SET (MAN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/man")
53 ENDIF (IS_DIRECTORY "${CMAKE_INSTALL_PREFIX}/share/man" AND NOT IS_DIRECTORY "${CMAKE_INSTALL_PREFIX}/man")
54 MESSAGE(STATUS "Man pages will be installed in ${MAN_INSTALL_DIR}")
56 ####################################################################
58 ####################################################################
60 # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
61 SET (CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
62 INSTALL( FILES ${CMAKE_MODULE_PATH}/FindLibSolv.cmake DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cmake/Modules )
64 INCLUDE (${CMAKE_SOURCE_DIR}/VERSION.cmake)
69 MESSAGE(STATUS "Building for Fedora")
70 ADD_DEFINITIONS (-DFEDORA)
73 SET (have_system ${have_system}x)
77 MESSAGE (STATUS "Building for Debian")
78 ADD_DEFINITIONS (-DDEBIAN)
79 SET (ENABLE_DEBIAN ON)
80 SET (have_system ${have_system}x)
84 MESSAGE (STATUS "Building for SUSE")
85 ADD_DEFINITIONS (-DSUSE)
87 SET (ENABLE_PUBKEY ON)
88 SET (ENABLE_RPMDB_BYRPMHEADER ON)
90 SET (ENABLE_SUSEREPO ON)
91 SET (ENABLE_HELIXREPO ON)
92 SET (ENABLE_LINKED_PKGS ON)
93 SET (have_system ${have_system}x)
97 MESSAGE (STATUS "Building for Archlinux")
98 ADD_DEFINITIONS (-DARCHLINUX)
99 SET (ENABLE_ARCHREPO ON)
100 SET (have_system ${have_system}x)
104 MESSAGE (STATUS "Building for Mandriva/Mageia")
105 ADD_DEFINITIONS (-DMANDRIVA)
106 SET (ENABLE_MDKREPO ON)
107 SET (ENABLE_RPMDB ON)
108 SET (have_system ${have_system}x)
112 MESSAGE(STATUS "Building for Haiku")
113 FIND_LIBRARY(HAIKU_BE_LIBRARY NAMES be)
114 FIND_LIBRARY(HAIKU_NETWORK_LIBRARY NAMES network)
115 FIND_LIBRARY(HAIKU_PACKAGE_LIBRARY NAMES package)
116 SET (HAIKU_SYSTEM_LIBRARIES
117 ${HAIKU_BE_LIBRARY} ${HAIKU_NETWORK_LIBRARY} ${HAIKU_PACKAGE_LIBRARY})
118 ADD_DEFINITIONS (-DHAIKU)
119 SET (ENABLE_HAIKU ON)
120 SET (have_system ${have_system}x)
123 IF (${have_system} STREQUAL x)
124 MESSAGE (STATUS "Building for no system")
125 ADD_DEFINITIONS (-DNOSYSTEM)
126 ENDIF (${have_system} STREQUAL x)
127 IF (${have_system} STRGREATER xx)
128 MESSAGE (FATAL_ERROR "Can only compile for one system type.")
129 ENDIF (${have_system} STRGREATER xx)
132 SET (ENABLE_LZMA_COMPRESSION ON)
133 ENDIF (ENABLE_ARCHREPO)
135 FIND_PACKAGE (EXPAT REQUIRED)
136 FIND_PACKAGE (ZLIB REQUIRED)
137 IF (ENABLE_LZMA_COMPRESSION)
138 FIND_PACKAGE (LZMA REQUIRED)
139 ENDIF (ENABLE_LZMA_COMPRESSION)
140 IF (ENABLE_BZIP2_COMPRESSION)
141 FIND_PACKAGE (BZip2 REQUIRED)
142 ENDIF (ENABLE_BZIP2_COMPRESSION)
145 MESSAGE (STATUS "Enabling RPM 5 support")
146 ADD_DEFINITIONS (-DRPM5)
147 SET (ENABLE_RPMDB ON)
148 SET (ENABLE_RPMMD ON)
149 FIND_PACKAGE (PkgConfig REQUIRED)
150 PKG_CHECK_MODULES (RPM REQUIRED rpm)
151 INCLUDE_DIRECTORIES (${RPM_INCLUDE_DIRS})
155 MESSAGE (STATUS "Enabling multi dist support")
156 ADD_DEFINITIONS (-DMULTI_SEMANTICS)
157 ENDIF (MULTI_SEMANTICS)
159 INCLUDE (CheckIncludeFile)
161 FIND_LIBRARY (RPMDB_LIBRARY NAMES rpmdb)
163 IF (NOT RPMDB_LIBRARY)
164 FIND_LIBRARY (RPMDB_LIBRARY NAMES rpm)
165 ENDIF (NOT RPMDB_LIBRARY)
167 FIND_LIBRARY (RPMIO_LIBRARY NAMES rpmio)
169 SET(RPMDB_LIBRARY ${RPMIO_LIBRARY} ${RPMDB_LIBRARY})
170 ENDIF (RPMIO_LIBRARY)
173 FIND_LIBRARY (RPMMISC_LIBRARY NAMES rpmmisc)
175 SET (RPMDB_LIBRARY ${RPMMISC_LIBRARY} ${RPMDB_LIBRARY})
176 ENDIF (RPMMISC_LIBRARY)
179 # check if rpm contains a bundled berkeley db
180 CHECK_INCLUDE_FILE(rpm/db.h HAVE_RPM_DB_H)
181 IF (NOT HAVE_RPM_DB_H)
182 FIND_LIBRARY (DB_LIBRARY NAMES db)
184 SET (RPMDB_LIBRARY ${DB_LIBRARY} ${RPMDB_LIBRARY})
186 ENDIF (NOT HAVE_RPM_DB_H)
187 INCLUDE (CheckLibraryExists)
188 CHECK_LIBRARY_EXISTS(rpmio pgpDigGetParams "" HAVE_PGPDIGGETPARAMS)
192 SET (ENABLE_PGPVRFY ON)
193 ENDIF (ENABLE_PUBKEY)
195 INCLUDE (CheckFunctionExists)
196 INCLUDE (TestBigEndian)
198 CHECK_FUNCTION_EXISTS (strchrnul HAVE_STRCHRNUL)
199 CHECK_FUNCTION_EXISTS (fopencookie HAVE_FOPENCOOKIE)
200 CHECK_FUNCTION_EXISTS (funopen HAVE_FUNOPEN)
201 TEST_BIG_ENDIAN (WORDS_BIGENDIAN)
203 # should create config.h with #cmakedefine instead...
204 FOREACH (VAR HAVE_STRCHRNUL HAVE_FOPENCOOKIE HAVE_FUNOPEN WORDS_BIGENDIAN
205 HAVE_RPM_DB_H HAVE_PGPDIGGETPARAMS
206 ENABLE_RPMDB ENABLE_PUBKEY ENABLE_RPMMD ENABLE_RPMDB_BYRPMHEADER ENABLE_SUSEREPO ENABLE_COMPS
207 ENABLE_HELIXREPO ENABLE_MDKREPO ENABLE_ARCHREPO ENABLE_DEBIAN ENABLE_HAIKU
208 ENABLE_LZMA_COMPRESSION ENABLE_BZIP2_COMPRESSION ENABLE_PGPVRFY ENABLE_APPDATA
211 ADD_DEFINITIONS (-D${VAR}=1)
212 SET (SWIG_FLAGS ${SWIG_FLAGS} -D${VAR})
216 SET (PACKAGE "libsolv")
217 SET (VERSION "${LIBSOLV_MAJOR}.${LIBSOLV_MINOR}.${LIBSOLV_PATCH}")
219 ADD_DEFINITIONS (-D_FILE_OFFSET_BITS=64)
220 ADD_DEFINITIONS (-DVERSION=\\\"${VERSION}\\\")
221 CONFIGURE_FILE (src/solvversion.h.in src/solvversion.h)
223 SET (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Package dependency solver library")
224 SET (CPACK_PACKAGE_VENDOR "SUSE")
225 SET (CPACK_PACKAGE_VERSION_MAJOR ${LIBSOLV_MAJOR})
226 SET (CPACK_PACKAGE_VERSION_MINOR ${LIBSOLV_MINOR})
227 SET (CPACK_PACKAGE_VERSION_PATCH ${LIBSOLV_PATCH})
228 SET (CPACK_GENERATOR "TBZ2")
229 SET (CPACK_SOURCE_GENERATOR "TBZ2")
230 SET (CPACK_SOURCE_PACKAGE_FILE_NAME "${PACKAGE}-${VERSION}")
231 SET (CPACK_SOURCE_TOPLEVEL_TAG "Linux-Source:")
232 SET (CPACK_TOPLEVEL_TAG "Linux-Source:")
234 # The following components are regex's to match anywhere (unless anchored)
235 # in absolute path + filename to find files or directories to be excluded
236 # from source tarball.
237 SET (CPACK_SOURCE_IGNORE_FILES
262 "DartConfiguration.tcl$"
265 "cmake_install.cmake$"
266 "CMakeLists.txt.auto$"
267 "CTestTestfile.cmake"
269 "CPackSourceConfig.cmake$"
275 ####################################################################
277 ####################################################################
279 #SET (CMAKE_INCLUDE_DIRECTORIES_BEFORE ON)
280 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 )
282 ####################################################################
284 MESSAGE (STATUS "Looking for modules in ${CMAKE_MODULE_PATH}")
286 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
287 set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -O3")
288 set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS} -g -O3")
289 set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g3 -O0")
291 SET (SYSTEM_LIBRARIES ${EXPAT_LIBRARY} ${ZLIB_LIBRARY})
292 IF (ENABLE_LZMA_COMPRESSION)
293 SET (SYSTEM_LIBRARIES ${SYSTEM_LIBRARIES} ${LZMA_LIBRARY})
294 ENDIF (ENABLE_LZMA_COMPRESSION)
295 IF (ENABLE_BZIP2_COMPRESSION)
296 SET (SYSTEM_LIBRARIES ${SYSTEM_LIBRARIES} ${BZIP2_LIBRARIES})
297 ENDIF (ENABLE_BZIP2_COMPRESSION)
299 SET (SYSTEM_LIBRARIES ${RPMDB_LIBRARY} ${SYSTEM_LIBRARIES})
302 SET (SYSTEM_LIBRARIES ${HAIKU_SYSTEM_LIBRARIES} ${SYSTEM_LIBRARIES})
304 SET (SYSTEM_LIBRARIES "-Wl,--as-needed" ${SYSTEM_LIBRARIES})
306 ADD_SUBDIRECTORY (src)
307 ADD_SUBDIRECTORY (ext)
308 ADD_SUBDIRECTORY (tools)
309 IF (ENABLE_PERL OR ENABLE_PYTHON OR ENABLE_RUBY)
310 ADD_SUBDIRECTORY (bindings)
311 ENDIF (ENABLE_PERL OR ENABLE_PYTHON OR ENABLE_RUBY)
312 ADD_SUBDIRECTORY (examples)
313 ADD_SUBDIRECTORY (doc)
315 MESSAGE (STATUS "Version: ${VERSION}")
317 ####################################################################
319 ####################################################################
322 MESSAGE (STATUS "Writing spec file...")
323 CONFIGURE_FILE (${CMAKE_SOURCE_DIR}/package/libsolv.spec.in ${CMAKE_BINARY_DIR}/package/libsolv.spec @ONLY)
328 SET (AUTOBUILD_COMMAND
329 COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_BINARY_DIR}/package/*.tar.bz2
330 COMMAND mkdir -p _CPack_Packages/${CPACK_TOPLEVEL_TAG}
331 COMMAND ${CMAKE_MAKE_PROGRAM} package_source
332 COMMAND ${CMAKE_COMMAND} -E copy ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2 ${CMAKE_BINARY_DIR}/package
333 COMMAND ${CMAKE_COMMAND} -E remove ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2
334 COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/package/libsolv.changes" "${CMAKE_BINARY_DIR}/package/libsolv.changes"
337 ADD_CUSTOM_TARGET (srcpackage
341 ADD_CUSTOM_TARGET (srcpackage_local
346 ADD_SUBDIRECTORY (test)