- is searching for REPOENTRY POS, select the right repo and repodata
[platform/upstream/libsolv.git] / CMakeLists.txt
1 PROJECT(satsolver)
2
3 cmake_minimum_required(VERSION 2.4)
4
5 #IF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERISION} GREATER 2.4)
6 #ENDIF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERISION} GREATER 2.4)
7
8 if(COMMAND cmake_policy)
9   # escape preprocessor, see -DVERSION below
10   cmake_policy(SET CMP0005 OLD)
11 endif(COMMAND cmake_policy)
12
13
14 # Library
15 IF ( DEFINED LIB )
16   SET ( LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${LIB}" )
17 ELSE ( DEFINED  LIB )
18   IF (CMAKE_SIZEOF_VOID_P MATCHES "8")
19     SET( LIB_SUFFIX "64" )
20   ENDIF(CMAKE_SIZEOF_VOID_P MATCHES "8")
21   SET ( LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" )
22 ENDIF ( DEFINED  LIB )
23 MESSAGE(STATUS "Libraries will be installed in ${LIB_INSTALL_DIR}" )
24 SET( BIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin" )
25
26 ####################################################################
27 # CONFIGURATION                                                    #
28 ####################################################################
29
30 # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
31 SET( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules )
32
33 INCLUDE( ${CMAKE_SOURCE_DIR}/VERSION.cmake )
34
35 FIND_PACKAGE(EXPAT REQUIRED)
36 FIND_LIBRARY(RPMDB_LIBRARY NAMES rpmdb)
37 FIND_LIBRARY(ZLIB_LIBRARY NAMES z)
38
39 SET( PACKAGE "satsolver" )
40 SET( VERSION "${LIBSATSOLVER_MAJOR}.${LIBSATSOLVER_MINOR}.${LIBSATSOLVER_PATCH}" )
41
42 ADD_DEFINITIONS( -D_FILE_OFFSET_BITS=64 )
43 ADD_DEFINITIONS( -DVERSION=\\\"${VERSION}\\\" )
44
45 SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "mls solver")
46 SET(CPACK_PACKAGE_VENDOR "Novell Inc.")
47 SET(CPACK_PACKAGE_VERSION_MAJOR ${LIBSATSOLVER_MAJOR})
48 SET(CPACK_PACKAGE_VERSION_MINOR ${LIBSATSOLVER_MINOR})
49 SET(CPACK_PACKAGE_VERSION_PATCH ${LIBSATSOLVER_PATCH})
50 SET( CPACK_GENERATOR "TBZ2")
51 SET( CPACK_SOURCE_GENERATOR "TBZ2")
52 SET( CPACK_SOURCE_PACKAGE_FILE_NAME "${PACKAGE}-${VERSION}" )
53
54 # The following components are regex's to match anywhere (unless anchored)
55 # in absolute path + filename to find files or directories to be excluded
56 # from source tarball.
57 SET (CPACK_SOURCE_IGNORE_FILES
58 #svn files
59 "\\\\.svn/"
60 "\\\\.cvsignore$"
61 # temporary files
62 "\\\\.swp$"
63 # backup files
64 "~$"
65 # eclipse files
66 "\\\\.cdtproject$"
67 "\\\\.cproject$"
68 "\\\\.project$"
69 "\\\\.settings/"
70 # others
71 "\\\\.#"
72 "/#"
73 "/build/"
74 "/_build/"
75 "/\\\\.git/"
76 # used before
77 "/CVS/"
78 "/\\\\.libs/"
79 "/\\\\.deps/"
80 "\\\\.o$"
81 "\\\\.lo$"
82 "\\\\.la$"
83 "Makefile\\\\.in$"
84 "testsuite/data.libzypp/kernel-tests/kernel-hardware"
85 "testsuite/data.libzypp/yast-tests/kernel3-hardware"
86 # cmake cache files
87 "CMakeCache.txt"
88 "CMakeFiles"
89 )
90
91 INCLUDE(CPack)
92
93 ####################################################################
94
95 SET( DOC_INSTALL_DIR
96    "${CMAKE_INSTALL_PREFIX}/share/doc/packages/${PACKAGE}"
97    CACHE PATH "The install dir for documentation (default prefix/share/doc/packages/${PACKAGE})"
98    FORCE
99 )
100
101 ####################################################################
102 # INCLUDES                                                         #
103 ####################################################################
104
105 #SET (CMAKE_INCLUDE_DIRECTORIES_BEFORE ON)
106 INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR} SYSTEM )
107
108 ####################################################################
109
110 MESSAGE(STATUS "Looking modules in ${CMAKE_MODULE_PATH}")
111 FIND_PROGRAM(SWIG_EXECUTABLE
112   NAMES swig-1.3 swig
113   PATHS ${SWIG_DIR} ${SWIG_DIR}/.. ${SWIG_DIR}/../../bin /usr/bin /usr/local/bin ${CMAKE_INSTALL_PREFIX}/bin
114 )
115
116 set ( CMAKE_C_FLAGS     "${CMAKE_C_FLAGS} -Werror -Wall" )
117 set ( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -g -O3" )
118 set ( CMAKE_C_FLAGS_DEBUG     "${CMAKE_C_FLAGS} -g3 -O0" )
119
120 ADD_SUBDIRECTORY(src)
121 ADD_SUBDIRECTORY(tools)
122 ADD_SUBDIRECTORY(applayer)
123 ADD_SUBDIRECTORY(testsuite)
124
125 IF ( NOT SWIG_EXECUTABLE )
126   MESSAGE( FATAL "SWIG not found." )
127 ELSE ( NOT SWIG_EXECUTABLE )
128   MESSAGE( STATUS "SWIG found at ${SWIG_EXECUTABLE}" )
129   ADD_SUBDIRECTORY(bindings)
130 ENDIF ( NOT SWIG_EXECUTABLE )
131
132 MESSAGE(STATUS "version: ${VERSION}")
133
134 ####################################################################
135 # RPM SPEC                                                         #
136 ####################################################################
137
138 MACRO(SPECFILE)
139   MESSAGE(STATUS "Writing spec file...")
140   CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/package/libsatsolver.spec.in ${CMAKE_BINARY_DIR}/package/libsatsolver.spec @ONLY)
141   #MESSAGE(STATUS "I hate you rpm-lint...!!!")
142   #CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/package/libsatsolver-rpmlint.cmake ${CMAKE_BINARY_DIR}/package/libsatsolver-rpmlintrc @ONLY)
143 ENDMACRO(SPECFILE)
144
145 SPECFILE()
146
147 ADD_CUSTOM_TARGET( svncheck
148   COMMAND cd $(CMAKE_SOURCE_DIR) && ! LC_ALL=C svn status --show-updates --quiet | grep -v '^Status against revision'
149 )
150
151 SET( AUTOBUILD_COMMAND
152   COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_BINARY_DIR}/package/*.tar.bz2
153   COMMAND ${CMAKE_MAKE_PROGRAM} package_source
154   COMMAND ${CMAKE_COMMAND} -E copy ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2 ${CMAKE_BINARY_DIR}/package
155   COMMAND ${CMAKE_COMMAND} -E remove ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2
156   COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/package/libsatsolver.changes" "${CMAKE_BINARY_DIR}/package/libsatsolver.changes"
157 )
158
159 ADD_CUSTOM_TARGET( srcpackage_local
160   ${AUTOBUILD_COMMAND}
161 )
162
163 ADD_CUSTOM_TARGET( srcpackage
164   COMMAND ${CMAKE_MAKE_PROGRAM} svncheck
165   ${AUTOBUILD_COMMAND}
166 )
167
168 INCLUDE(CTest)
169 ENABLE_TESTING()