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_RPMDB_PUBKEY "Build with rpmdb pubkey support?" OFF)
16 OPTION (ENABLE_RPMMD "Build with rpmmd repository support?" OFF)
17 OPTION (ENABLE_SUSEREPO "Build with suse repository support?" OFF)
18 OPTION (ENABLE_COMPS "Build with fedora comps support?" OFF)
19 OPTION (ENABLE_HELIXREPO "Build with helix repository support?" OFF)
20 OPTION (ENABLE_DEBIAN "Build with debian database/repository support?" OFF)
21 OPTION (ENABLE_MDKREPO "Build with mandriva/mageia repository support?" OFF)
22 OPTION (ENABLE_ARCHREPO "Build with archlinux repository support?" OFF)
23 OPTION (ENABLE_CUDFREPO "Build with cudf repository support?" OFF)
25 OPTION (ENABLE_LZMA_COMPRESSION "Build with lzma/xz compression support?" OFF)
26 OPTION (ENABLE_BZIP2_COMPRESSION "Build with bzip2 compression support?" OFF)
28 #IF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERISION} GREATER 2.4)
29 #ENDIF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERISION} GREATER 2.4)
31 IF (COMMAND cmake_policy)
32 # escape preprocessor, see -DVERSION below
33 CMAKE_POLICY (SET CMP0005 OLD)
34 ENDIF (COMMAND cmake_policy)
38 SET (LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${LIB}")
40 IF (CMAKE_SIZEOF_VOID_P MATCHES "8")
42 ENDIF (CMAKE_SIZEOF_VOID_P MATCHES "8")
43 SET (LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
45 MESSAGE (STATUS "Libraries will be installed in ${LIB_INSTALL_DIR}")
46 SET (BIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin")
48 ####################################################################
50 ####################################################################
52 # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
53 SET (CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
54 INSTALL( FILES ${CMAKE_MODULE_PATH}/FindLibSolv.cmake DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cmake/Modules )
56 INCLUDE (${CMAKE_SOURCE_DIR}/VERSION.cmake)
61 MESSAGE(STATUS "Building for Fedora")
62 ADD_DEFINITIONS (-DFEDORA)
65 SET (have_system ${have_system}x)
69 MESSAGE (STATUS "Building for Debian")
70 ADD_DEFINITIONS (-DDEBIAN)
71 SET (ENABLE_DEBIAN ON)
72 SET (have_system ${have_system}x)
76 MESSAGE (STATUS "Building for SUSE")
77 ADD_DEFINITIONS (-DSUSE)
79 SET (ENABLE_RPMDB_PUBKEY ON)
81 SET (ENABLE_SUSEREPO ON)
82 SET (ENABLE_HELIXREPO ON)
83 SET (have_system ${have_system}x)
87 MESSAGE (STATUS "Building for Archlinux")
88 ADD_DEFINITIONS (-DARCHLINUX)
89 SET (ENABLE_ARCHREPO ON)
90 SET (have_system ${have_system}x)
94 MESSAGE (STATUS "Building for Mandriva/Mageia")
95 ADD_DEFINITIONS (-DMANDRIVA)
96 SET (ENABLE_MDKREPO ON)
97 SET (have_system ${have_system}x)
100 IF (${have_system} STREQUAL x)
101 MESSAGE (STATUS "Building for no system")
102 ADD_DEFINITIONS (-DNOSYSTEM)
103 ENDIF (${have_system} STREQUAL x)
104 IF (${have_system} STRGREATER xx)
105 MESSAGE (FATAL_ERROR "Can only compile for one system type.")
106 ENDIF (${have_system} STRGREATER xx)
109 SET (ENABLE_LZMA_COMPRESSION ON)
110 ENDIF (ENABLE_ARCHREPO)
112 FIND_PACKAGE (EXPAT REQUIRED)
113 FIND_PACKAGE (ZLIB REQUIRED)
114 IF (ENABLE_LZMA_COMPRESSION)
115 FIND_PACKAGE (LZMA REQUIRED)
116 ENDIF (ENABLE_LZMA_COMPRESSION)
117 IF (ENABLE_BZIP2_COMPRESSION)
118 FIND_PACKAGE (BZip2 REQUIRED)
119 ENDIF (ENABLE_BZIP2_COMPRESSION)
122 MESSAGE (STATUS "Enabling RPM 5 support")
123 ADD_DEFINITIONS (-DRPM5)
124 SET (ENABLE_RPMDB ON)
125 SET (ENABLE_RPMMD ON)
126 FIND_PACKAGE (PkgConfig REQUIRED)
127 PKG_CHECK_MODULES (RPM REQUIRED rpm)
128 INCLUDE_DIRECTORIES (${RPM_INCLUDE_DIRS})
132 MESSAGE (STATUS "Enabling multi dist support")
133 ADD_DEFINITIONS (-DMULTI_SEMANTICS)
134 ENDIF (MULTI_SEMANTICS)
137 FIND_LIBRARY (RPMDB_LIBRARY NAMES rpmdb)
139 IF (NOT RPMDB_LIBRARY)
140 FIND_LIBRARY (RPMDB_LIBRARY NAMES rpm)
141 ENDIF (NOT RPMDB_LIBRARY)
143 FIND_LIBRARY (RPMIO_LIBRARY NAMES rpmio)
145 SET(RPMDB_LIBRARY ${RPMIO_LIBRARY} ${RPMDB_LIBRARY})
146 ENDIF (RPMIO_LIBRARY)
149 FIND_LIBRARY (RPMMISC_LIBRARY NAMES rpmmisc)
151 SET (RPMDB_LIBRARY ${RPMMISC_LIBRARY} ${RPMDB_LIBRARY})
152 ENDIF (RPMMISC_LIBRARY)
156 FIND_LIBRARY (DB_LIBRARY NAMES db)
158 SET (RPMDB_LIBRARY ${DB_LIBRARY} ${RPMDB_LIBRARY})
160 ENDIF (RPM5 OR FEDORA)
163 INCLUDE (CheckFunctionExists)
164 INCLUDE (TestBigEndian)
166 CHECK_FUNCTION_EXISTS (strchrnul HAVE_STRCHRNUL)
167 CHECK_FUNCTION_EXISTS (fopencookie HAVE_FOPENCOOKIE)
168 CHECK_FUNCTION_EXISTS (funopen HAVE_FUNOPEN)
169 TEST_BIG_ENDIAN (WORDS_BIGENDIAN)
171 # should create config.h with #cmakedefine instead...
172 FOREACH (VAR HAVE_STRCHRNUL HAVE_FOPENCOOKIE HAVE_FUNOPEN WORDS_BIGENDIAN
173 ENABLE_RPMDB ENABLE_RPMDB_PUBKEY ENABLE_RPMMD ENABLE_SUSEREPO ENABLE_COMPS
174 ENABLE_HELIXREPO ENABLE_MDKREPO ENABLE_ARCHREPO ENABLE_DEBIAN
175 ENABLE_LZMA_COMPRESSION ENABLE_BZIP2_COMPRESSION)
177 ADD_DEFINITIONS (-D${VAR}=1)
178 SET (SWIG_FLAGS ${SWIG_FLAGS} -D${VAR})
182 SET (PACKAGE "libsolv")
183 SET (VERSION "${LIBSOLV_MAJOR}.${LIBSOLV_MINOR}.${LIBSOLV_PATCH}")
185 ADD_DEFINITIONS (-D_FILE_OFFSET_BITS=64)
186 ADD_DEFINITIONS (-DVERSION=\\\"${VERSION}\\\")
187 CONFIGURE_FILE (src/solvversion.h.in src/solvversion.h)
189 SET (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Package dependency solver library")
190 SET (CPACK_PACKAGE_VENDOR "SUSE")
191 SET (CPACK_PACKAGE_VERSION_MAJOR ${LIBSOLV_MAJOR})
192 SET (CPACK_PACKAGE_VERSION_MINOR ${LIBSOLV_MINOR})
193 SET (CPACK_PACKAGE_VERSION_PATCH ${LIBSOLV_PATCH})
194 SET (CPACK_GENERATOR "TBZ2")
195 SET (CPACK_SOURCE_GENERATOR "TBZ2")
196 SET (CPACK_SOURCE_PACKAGE_FILE_NAME "${PACKAGE}-${VERSION}")
197 SET (CPACK_SOURCE_TOPLEVEL_TAG "Linux-Source:")
198 SET (CPACK_TOPLEVEL_TAG "Linux-Source:")
200 # The following components are regex's to match anywhere (unless anchored)
201 # in absolute path + filename to find files or directories to be excluded
202 # from source tarball.
203 SET (CPACK_SOURCE_IGNORE_FILES
228 "DartConfiguration.tcl$"
231 "cmake_install.cmake$"
232 "CMakeLists.txt.auto$"
233 "CTestTestfile.cmake"
235 "CPackSourceConfig.cmake$"
241 ####################################################################
243 ####################################################################
245 #SET (CMAKE_INCLUDE_DIRECTORIES_BEFORE ON)
246 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 )
248 ####################################################################
250 MESSAGE (STATUS "Looking for modules in ${CMAKE_MODULE_PATH}")
252 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wl,--as-needed")
253 set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -O3")
254 set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS} -g -O3")
255 set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g3 -O0")
257 ADD_SUBDIRECTORY (src)
258 ADD_SUBDIRECTORY (ext)
259 ADD_SUBDIRECTORY (tools)
260 IF (ENABLE_PERL OR ENABLE_PYTHON OR ENABLE_RUBY)
261 ADD_SUBDIRECTORY (bindings)
262 ENDIF (ENABLE_PERL OR ENABLE_PYTHON OR ENABLE_RUBY)
263 ADD_SUBDIRECTORY (examples)
265 MESSAGE (STATUS "Version: ${VERSION}")
267 ####################################################################
269 ####################################################################
272 MESSAGE (STATUS "Writing spec file...")
273 CONFIGURE_FILE (${CMAKE_SOURCE_DIR}/package/libsolv.spec.in ${CMAKE_BINARY_DIR}/package/libsolv.spec @ONLY)
278 SET (AUTOBUILD_COMMAND
279 COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_BINARY_DIR}/package/*.tar.bz2
280 COMMAND mkdir -p _CPack_Packages/${CPACK_TOPLEVEL_TAG}
281 COMMAND ${CMAKE_MAKE_PROGRAM} package_source
282 COMMAND ${CMAKE_COMMAND} -E copy ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2 ${CMAKE_BINARY_DIR}/package
283 COMMAND ${CMAKE_COMMAND} -E remove ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2
284 COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/package/libsolv.changes" "${CMAKE_BINARY_DIR}/package/libsolv.changes"
287 ADD_CUSTOM_TARGET (srcpackage
291 ADD_CUSTOM_TARGET (srcpackage_local
296 ADD_SUBDIRECTORY (test)