3 cmake_minimum_required (VERSION 2.4)
5 #IF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERISION} GREATER 2.4)
6 #ENDIF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERISION} GREATER 2.4)
8 IF (COMMAND cmake_policy)
9 # escape preprocessor, see -DVERSION below
10 cmake_policy (SET CMP0005 OLD)
11 ENDIF (COMMAND cmake_policy)
15 SET (LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${LIB}")
17 IF (CMAKE_SIZEOF_VOID_P MATCHES "8")
19 ENDIF (CMAKE_SIZEOF_VOID_P MATCHES "8")
20 SET (LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
22 MESSAGE (STATUS "Libraries will be installed in ${LIB_INSTALL_DIR}")
23 SET (BIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin")
25 ####################################################################
27 ####################################################################
29 # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
30 SET (CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
32 INCLUDE (${CMAKE_SOURCE_DIR}/VERSION.cmake)
34 FIND_PACKAGE (EXPAT REQUIRED)
35 FIND_PACKAGE (Check REQUIRED)
36 FIND_PACKAGE (ZLIB REQUIRED)
39 MESSAGE(STATUS "Building for Fedora")
40 ADD_DEFINITIONS (-DFEDORA)
44 MESSAGE (STATUS "Building for Debian")
45 ADD_DEFINITIONS (-DDEBIAN -DDEBIAN_SEMANTICS)
49 MESSAGE (STATUS "Enabling multi dist support")
50 ADD_DEFINITIONS (-DMULTI_SEMANTICS)
51 ENDIF (MULTI_SEMANTICS)
54 MESSAGE (STATUS "Enabling RPM 5 support")
55 ADD_DEFINITIONS (-DRPM5)
56 FIND_PACKAGE (PkgConfig REQUIRED)
57 PKG_CHECK_MODULES (RPM REQUIRED rpm)
58 INCLUDE_DIRECTORIES (${RPM_INCLUDE_DIRS})
62 IF (RPM5 OR NOT DEBIAN)
63 FIND_LIBRARY (RPMDB_LIBRARY NAMES rpmdb)
65 IF (NOT RPMDB_LIBRARY)
66 FIND_LIBRARY (RPMDB_LIBRARY NAMES rpm)
67 ENDIF (NOT RPMDB_LIBRARY)
69 FIND_LIBRARY (RPMIO_LIBRARY NAMES rpmio)
71 SET(RPMDB_LIBRARY ${RPMIO_LIBRARY} ${RPMDB_LIBRARY})
75 FIND_LIBRARY (RPMMISC_LIBRARY NAMES rpmmisc)
77 SET (RPMDB_LIBRARY ${RPMMISC_LIBRARY} ${RPMDB_LIBRARY})
78 ENDIF (RPMMISC_LIBRARY)
82 FIND_LIBRARY (DB_LIBRARY NAMES db)
84 SET (RPMDB_LIBRARY ${DB_LIBRARY} ${RPMDB_LIBRARY})
86 ENDIF (RPM5 OR FEDORA)
88 ENDIF (RPM5 OR NOT DEBIAN)
90 INCLUDE (CheckFunctionExists)
91 INCLUDE (TestBigEndian)
93 CHECK_FUNCTION_EXISTS (strchrnul HAVE_STRCHRNUL)
94 CHECK_FUNCTION_EXISTS (fopencookie HAVE_FOPENCOOKIE)
95 CHECK_FUNCTION_EXISTS (funopen HAVE_FUNOPEN)
96 TEST_BIG_ENDIAN (WORDS_BIGENDIAN)
98 # should create config.h with #cmakedefine instead...
99 FOREACH (VAR HAVE_STRCHRNUL HAVE_FOPENCOOKIE HAVE_FUNOPEN WORDS_BIGENDIAN)
101 ADD_DEFINITIONS (-D${VAR}=1)
105 SET (PACKAGE "libsolv")
106 SET (VERSION "${LIBSOLV_MAJOR}.${LIBSOLV_MINOR}.${LIBSOLV_PATCH}")
108 ADD_DEFINITIONS (-D_FILE_OFFSET_BITS=64)
109 ADD_DEFINITIONS (-DVERSION=\\\"${VERSION}\\\")
110 CONFIGURE_FILE (src/satversion.h.in src/satversion.h)
112 SET (CPACK_PACKAGE_DESCRIPTION_SUMMARY "SAT Solver library")
113 SET (CPACK_PACKAGE_VENDOR "SUSE")
114 SET (CPACK_PACKAGE_VERSION_MAJOR ${LIBSOLV_MAJOR})
115 SET (CPACK_PACKAGE_VERSION_MINOR ${LIBSOLV_MINOR})
116 SET (CPACK_PACKAGE_VERSION_PATCH ${LIBSOLV_PATCH})
117 SET (CPACK_GENERATOR "TBZ2")
118 SET (CPACK_SOURCE_GENERATOR "TBZ2")
119 SET (CPACK_SOURCE_PACKAGE_FILE_NAME "${PACKAGE}-${VERSION}")
120 SET (CPACK_SOURCE_TOPLEVEL_TAG "Linux-Source:")
121 SET (CPACK_TOPLEVEL_TAG "Linux-Source:")
123 # The following components are regex's to match anywhere (unless anchored)
124 # in absolute path + filename to find files or directories to be excluded
125 # from source tarball.
126 SET (CPACK_SOURCE_IGNORE_FILES
151 "DartConfiguration.tcl$"
154 "cmake_install.cmake$"
155 "CMakeLists.txt.auto$"
156 "CTestTestfile.cmake"
158 "CPackSourceConfig.cmake$"
164 ####################################################################
167 "${CMAKE_INSTALL_PREFIX}/share/doc/packages/${PACKAGE}"
168 CACHE PATH "The install dir for documentation (default prefix/share/doc/packages/${PACKAGE})"
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 modules in ${CMAKE_MODULE_PATH}")
183 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wall")
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 ADD_SUBDIRECTORY (examples)
192 MESSAGE (STATUS "version: ${VERSION}")
194 ####################################################################
196 ####################################################################
199 MESSAGE (STATUS "Writing spec file...")
200 CONFIGURE_FILE (${CMAKE_SOURCE_DIR}/package/libsolv.spec.in ${CMAKE_BINARY_DIR}/package/libsolv.spec @ONLY)
205 SET (AUTOBUILD_COMMAND
206 COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_BINARY_DIR}/package/*.tar.bz2
207 COMMAND mkdir -p _CPack_Packages/${CPACK_TOPLEVEL_TAG}
208 COMMAND ${CMAKE_MAKE_PROGRAM} package_source
209 COMMAND ${CMAKE_COMMAND} -E copy ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2 ${CMAKE_BINARY_DIR}/package
210 COMMAND ${CMAKE_COMMAND} -E remove ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2
211 COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/package/libsolv.changes" "${CMAKE_BINARY_DIR}/package/libsolv.changes"
214 ADD_CUSTOM_TARGET (srcpackage