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