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 #IF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERISION} GREATER 2.4)
9 #ENDIF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERISION} GREATER 2.4)
11 IF (COMMAND cmake_policy)
12 # escape preprocessor, see -DVERSION below
13 CMAKE_POLICY (SET CMP0005 OLD)
14 ENDIF (COMMAND cmake_policy)
18 SET (LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${LIB}")
20 IF (CMAKE_SIZEOF_VOID_P MATCHES "8")
22 ENDIF (CMAKE_SIZEOF_VOID_P MATCHES "8")
23 SET (LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
25 MESSAGE (STATUS "Libraries will be installed in ${LIB_INSTALL_DIR}")
26 SET (BIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin")
28 ####################################################################
30 ####################################################################
32 # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
33 SET (CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
35 INCLUDE (${CMAKE_SOURCE_DIR}/VERSION.cmake)
37 FIND_PACKAGE (EXPAT REQUIRED)
38 FIND_PACKAGE (Check REQUIRED)
39 FIND_PACKAGE (ZLIB REQUIRED)
42 MESSAGE(STATUS "Building for Fedora")
43 ADD_DEFINITIONS (-DFEDORA)
47 MESSAGE (STATUS "Building for Debian")
48 ADD_DEFINITIONS (-DDEBIAN -DDEBIAN_SEMANTICS)
52 MESSAGE (STATUS "Enabling multi dist support")
53 ADD_DEFINITIONS (-DMULTI_SEMANTICS)
54 ENDIF (MULTI_SEMANTICS)
57 MESSAGE (STATUS "Enabling RPM 5 support")
58 ADD_DEFINITIONS (-DRPM5)
59 FIND_PACKAGE (PkgConfig REQUIRED)
60 PKG_CHECK_MODULES (RPM REQUIRED rpm)
61 INCLUDE_DIRECTORIES (${RPM_INCLUDE_DIRS})
65 IF (RPM5 OR NOT DEBIAN)
66 FIND_LIBRARY (RPMDB_LIBRARY NAMES rpmdb)
68 IF (NOT RPMDB_LIBRARY)
69 FIND_LIBRARY (RPMDB_LIBRARY NAMES rpm)
70 ENDIF (NOT RPMDB_LIBRARY)
72 FIND_LIBRARY (RPMIO_LIBRARY NAMES rpmio)
74 SET(RPMDB_LIBRARY ${RPMIO_LIBRARY} ${RPMDB_LIBRARY})
78 FIND_LIBRARY (RPMMISC_LIBRARY NAMES rpmmisc)
80 SET (RPMDB_LIBRARY ${RPMMISC_LIBRARY} ${RPMDB_LIBRARY})
81 ENDIF (RPMMISC_LIBRARY)
85 FIND_LIBRARY (DB_LIBRARY NAMES db)
87 SET (RPMDB_LIBRARY ${DB_LIBRARY} ${RPMDB_LIBRARY})
89 ENDIF (RPM5 OR FEDORA)
91 ENDIF (RPM5 OR NOT DEBIAN)
93 INCLUDE (CheckFunctionExists)
94 INCLUDE (TestBigEndian)
96 CHECK_FUNCTION_EXISTS (strchrnul HAVE_STRCHRNUL)
97 CHECK_FUNCTION_EXISTS (fopencookie HAVE_FOPENCOOKIE)
98 CHECK_FUNCTION_EXISTS (funopen HAVE_FUNOPEN)
99 TEST_BIG_ENDIAN (WORDS_BIGENDIAN)
101 # should create config.h with #cmakedefine instead...
102 FOREACH (VAR HAVE_STRCHRNUL HAVE_FOPENCOOKIE HAVE_FUNOPEN WORDS_BIGENDIAN)
104 ADD_DEFINITIONS (-D${VAR}=1)
108 SET (PACKAGE "libsolv")
109 SET (VERSION "${LIBSOLV_MAJOR}.${LIBSOLV_MINOR}.${LIBSOLV_PATCH}")
111 ADD_DEFINITIONS (-D_FILE_OFFSET_BITS=64)
112 ADD_DEFINITIONS (-DVERSION=\\\"${VERSION}\\\")
113 CONFIGURE_FILE (src/satversion.h.in src/satversion.h)
115 SET (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Package dependency solver library")
116 SET (CPACK_PACKAGE_VENDOR "SUSE")
117 SET (CPACK_PACKAGE_VERSION_MAJOR ${LIBSOLV_MAJOR})
118 SET (CPACK_PACKAGE_VERSION_MINOR ${LIBSOLV_MINOR})
119 SET (CPACK_PACKAGE_VERSION_PATCH ${LIBSOLV_PATCH})
120 SET (CPACK_GENERATOR "TBZ2")
121 SET (CPACK_SOURCE_GENERATOR "TBZ2")
122 SET (CPACK_SOURCE_PACKAGE_FILE_NAME "${PACKAGE}-${VERSION}")
123 SET (CPACK_SOURCE_TOPLEVEL_TAG "Linux-Source:")
124 SET (CPACK_TOPLEVEL_TAG "Linux-Source:")
126 # The following components are regex's to match anywhere (unless anchored)
127 # in absolute path + filename to find files or directories to be excluded
128 # from source tarball.
129 SET (CPACK_SOURCE_IGNORE_FILES
154 "DartConfiguration.tcl$"
157 "cmake_install.cmake$"
158 "CMakeLists.txt.auto$"
159 "CTestTestfile.cmake"
161 "CPackSourceConfig.cmake$"
167 ####################################################################
169 ####################################################################
171 #SET (CMAKE_INCLUDE_DIRECTORIES_BEFORE ON)
172 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 )
174 ####################################################################
176 MESSAGE (STATUS "Looking for modules in ${CMAKE_MODULE_PATH}")
178 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wall -Wl,--as-needed")
179 set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -g -O3")
180 set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g3 -O0")
182 ADD_SUBDIRECTORY (src)
183 ADD_SUBDIRECTORY (ext)
184 ADD_SUBDIRECTORY (tools)
185 ADD_SUBDIRECTORY (examples)
187 MESSAGE (STATUS "version: ${VERSION}")
189 ####################################################################
191 ####################################################################
194 MESSAGE (STATUS "Writing spec file...")
195 CONFIGURE_FILE (${CMAKE_SOURCE_DIR}/package/libsolv.spec.in ${CMAKE_BINARY_DIR}/package/libsolv.spec @ONLY)
200 SET (AUTOBUILD_COMMAND
201 COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_BINARY_DIR}/package/*.tar.bz2
202 COMMAND mkdir -p _CPack_Packages/${CPACK_TOPLEVEL_TAG}
203 COMMAND ${CMAKE_MAKE_PROGRAM} package_source
204 COMMAND ${CMAKE_COMMAND} -E copy ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2 ${CMAKE_BINARY_DIR}/package
205 COMMAND ${CMAKE_COMMAND} -E remove ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2
206 COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/package/libsolv.changes" "${CMAKE_BINARY_DIR}/package/libsolv.changes"
209 ADD_CUSTOM_TARGET (srcpackage
213 ADD_CUSTOM_TARGET (srcpackage_local