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 #IF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERISION} GREATER 2.4)
15 #ENDIF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERISION} GREATER 2.4)
17 IF (COMMAND cmake_policy)
18 # escape preprocessor, see -DVERSION below
19 CMAKE_POLICY (SET CMP0005 OLD)
20 ENDIF (COMMAND cmake_policy)
24 SET (LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${LIB}")
26 IF (CMAKE_SIZEOF_VOID_P MATCHES "8")
28 ENDIF (CMAKE_SIZEOF_VOID_P MATCHES "8")
29 SET (LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
31 MESSAGE (STATUS "Libraries will be installed in ${LIB_INSTALL_DIR}")
32 SET (BIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin")
34 ####################################################################
36 ####################################################################
38 # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
39 SET (CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
41 INCLUDE (${CMAKE_SOURCE_DIR}/VERSION.cmake)
43 FIND_PACKAGE (EXPAT REQUIRED)
44 FIND_PACKAGE (ZLIB REQUIRED)
47 MESSAGE(STATUS "Building for Fedora")
48 ADD_DEFINITIONS (-DFEDORA)
52 MESSAGE (STATUS "Building for Debian")
53 ADD_DEFINITIONS (-DDEBIAN -DDEBIAN_SEMANTICS)
57 MESSAGE (STATUS "Enabling multi dist support")
58 ADD_DEFINITIONS (-DMULTI_SEMANTICS)
59 ENDIF (MULTI_SEMANTICS)
62 MESSAGE (STATUS "Enabling RPM 5 support")
63 ADD_DEFINITIONS (-DRPM5)
64 FIND_PACKAGE (PkgConfig REQUIRED)
65 PKG_CHECK_MODULES (RPM REQUIRED rpm)
66 INCLUDE_DIRECTORIES (${RPM_INCLUDE_DIRS})
70 IF (RPM5 OR NOT DEBIAN)
71 FIND_LIBRARY (RPMDB_LIBRARY NAMES rpmdb)
73 IF (NOT RPMDB_LIBRARY)
74 FIND_LIBRARY (RPMDB_LIBRARY NAMES rpm)
75 ENDIF (NOT RPMDB_LIBRARY)
77 FIND_LIBRARY (RPMIO_LIBRARY NAMES rpmio)
79 SET(RPMDB_LIBRARY ${RPMIO_LIBRARY} ${RPMDB_LIBRARY})
83 FIND_LIBRARY (RPMMISC_LIBRARY NAMES rpmmisc)
85 SET (RPMDB_LIBRARY ${RPMMISC_LIBRARY} ${RPMDB_LIBRARY})
86 ENDIF (RPMMISC_LIBRARY)
90 FIND_LIBRARY (DB_LIBRARY NAMES db)
92 SET (RPMDB_LIBRARY ${DB_LIBRARY} ${RPMDB_LIBRARY})
94 ENDIF (RPM5 OR FEDORA)
96 ENDIF (RPM5 OR NOT DEBIAN)
98 INCLUDE (CheckFunctionExists)
99 INCLUDE (TestBigEndian)
101 CHECK_FUNCTION_EXISTS (strchrnul HAVE_STRCHRNUL)
102 CHECK_FUNCTION_EXISTS (fopencookie HAVE_FOPENCOOKIE)
103 CHECK_FUNCTION_EXISTS (funopen HAVE_FUNOPEN)
104 TEST_BIG_ENDIAN (WORDS_BIGENDIAN)
106 # should create config.h with #cmakedefine instead...
107 FOREACH (VAR HAVE_STRCHRNUL HAVE_FOPENCOOKIE HAVE_FUNOPEN WORDS_BIGENDIAN)
109 ADD_DEFINITIONS (-D${VAR}=1)
113 SET (PACKAGE "libsolv")
114 SET (VERSION "${LIBSOLV_MAJOR}.${LIBSOLV_MINOR}.${LIBSOLV_PATCH}")
116 ADD_DEFINITIONS (-D_FILE_OFFSET_BITS=64)
117 ADD_DEFINITIONS (-DVERSION=\\\"${VERSION}\\\")
118 CONFIGURE_FILE (src/solvversion.h.in src/solvversion.h)
120 SET (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Package dependency solver library")
121 SET (CPACK_PACKAGE_VENDOR "SUSE")
122 SET (CPACK_PACKAGE_VERSION_MAJOR ${LIBSOLV_MAJOR})
123 SET (CPACK_PACKAGE_VERSION_MINOR ${LIBSOLV_MINOR})
124 SET (CPACK_PACKAGE_VERSION_PATCH ${LIBSOLV_PATCH})
125 SET (CPACK_GENERATOR "TBZ2")
126 SET (CPACK_SOURCE_GENERATOR "TBZ2")
127 SET (CPACK_SOURCE_PACKAGE_FILE_NAME "${PACKAGE}-${VERSION}")
128 SET (CPACK_SOURCE_TOPLEVEL_TAG "Linux-Source:")
129 SET (CPACK_TOPLEVEL_TAG "Linux-Source:")
131 # The following components are regex's to match anywhere (unless anchored)
132 # in absolute path + filename to find files or directories to be excluded
133 # from source tarball.
134 SET (CPACK_SOURCE_IGNORE_FILES
159 "DartConfiguration.tcl$"
162 "cmake_install.cmake$"
163 "CMakeLists.txt.auto$"
164 "CTestTestfile.cmake"
166 "CPackSourceConfig.cmake$"
172 ####################################################################
174 ####################################################################
176 #SET (CMAKE_INCLUDE_DIRECTORIES_BEFORE ON)
177 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 )
179 ####################################################################
181 MESSAGE (STATUS "Looking for modules in ${CMAKE_MODULE_PATH}")
183 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wall -Wl,--as-needed")
184 set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -g -O3")
185 set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g3 -O0")
187 ADD_SUBDIRECTORY (src)
188 ADD_SUBDIRECTORY (ext)
189 ADD_SUBDIRECTORY (tools)
190 IF (ENABLE_PERL OR ENABLE_PYTHON OR ENABLE_RUBY)
191 ADD_SUBDIRECTORY (bindings)
192 ENDIF (ENABLE_PERL OR ENABLE_PYTHON OR ENABLE_RUBY)
193 ADD_SUBDIRECTORY (examples)
195 MESSAGE (STATUS "version: ${VERSION}")
197 ####################################################################
199 ####################################################################
202 MESSAGE (STATUS "Writing spec file...")
203 CONFIGURE_FILE (${CMAKE_SOURCE_DIR}/package/libsolv.spec.in ${CMAKE_BINARY_DIR}/package/libsolv.spec @ONLY)
208 SET (AUTOBUILD_COMMAND
209 COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_BINARY_DIR}/package/*.tar.bz2
210 COMMAND mkdir -p _CPack_Packages/${CPACK_TOPLEVEL_TAG}
211 COMMAND ${CMAKE_MAKE_PROGRAM} package_source
212 COMMAND ${CMAKE_COMMAND} -E copy ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2 ${CMAKE_BINARY_DIR}/package
213 COMMAND ${CMAKE_COMMAND} -E remove ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2
214 COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/package/libsolv.changes" "${CMAKE_BINARY_DIR}/package/libsolv.changes"
217 ADD_CUSTOM_TARGET (srcpackage
221 ADD_CUSTOM_TARGET (srcpackage_local