- forgot to adapt ruby/python bindings
[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 # Library
14 IF ( DEFINED LIB )
15   SET ( LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${LIB}" )
16 ELSE ( DEFINED  LIB )
17   IF (CMAKE_SIZEOF_VOID_P MATCHES "8")
18     SET( LIB_SUFFIX "64" )
19   ENDIF(CMAKE_SIZEOF_VOID_P MATCHES "8")
20   SET ( LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" )
21 ENDIF ( DEFINED  LIB )
22 MESSAGE(STATUS "Libraries will be installed in ${LIB_INSTALL_DIR}" )
23 SET( BIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin" )
24
25 ####################################################################
26 # CONFIGURATION                                                    #
27 ####################################################################
28
29 # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
30 SET( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules )
31
32 INCLUDE( ${CMAKE_SOURCE_DIR}/VERSION.cmake )
33
34 FIND_PACKAGE(EXPAT REQUIRED)
35 FIND_PACKAGE(Check REQUIRED)
36 FIND_PACKAGE(ZLIB REQUIRED)
37
38 IF ( FEDORA )
39 MESSAGE(STATUS "Building for Fedora")
40 ADD_DEFINITIONS( -DFEDORA )
41 FIND_LIBRARY(RPMDB_LIBRARY NAMES rpm)
42 ELSE ( FEDORA )
43 FIND_LIBRARY(RPMDB_LIBRARY NAMES rpmdb)
44 ENDIF ( FEDORA)
45
46 SET( PACKAGE "satsolver" )
47 SET( VERSION "${LIBSATSOLVER_MAJOR}.${LIBSATSOLVER_MINOR}.${LIBSATSOLVER_PATCH}" )
48
49 ADD_DEFINITIONS( -D_FILE_OFFSET_BITS=64 )
50 ADD_DEFINITIONS( -DVERSION=\\\"${VERSION}\\\" )
51
52 SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "SAT Solver library")
53 SET(CPACK_PACKAGE_VENDOR "Novell Inc.")
54 SET(CPACK_PACKAGE_VERSION_MAJOR ${LIBSATSOLVER_MAJOR})
55 SET(CPACK_PACKAGE_VERSION_MINOR ${LIBSATSOLVER_MINOR})
56 SET(CPACK_PACKAGE_VERSION_PATCH ${LIBSATSOLVER_PATCH})
57 SET(CPACK_GENERATOR "TBZ2")
58 SET(CPACK_SOURCE_GENERATOR "TBZ2")
59 SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${PACKAGE}-${VERSION}")
60 SET(CPACK_SOURCE_TOPLEVEL_TAG "Linux-Source:")
61 SET(CPACK_TOPLEVEL_TAG "Linux-Source:")
62
63 # The following components are regex's to match anywhere (unless anchored)
64 # in absolute path + filename to find files or directories to be excluded
65 # from source tarball.
66 SET (CPACK_SOURCE_IGNORE_FILES
67 #svn files
68 "\\\\.svn/"
69 "\\\\.cvsignore$"
70 # temporary files
71 "\\\\.swp$"
72 # backup files
73 "~$"
74 # eclipse files
75 "\\\\.cdtproject$"
76 "\\\\.cproject$"
77 "\\\\.project$"
78 "\\\\.settings/"
79 # others
80 "\\\\.#"
81 "/#"
82 "/build/"
83 "/_build/"
84 "/\\\\.git/"
85 # used before
86 "/CVS/"
87 "/\\\\.libs/"
88 "/\\\\.deps/"
89 "\\\\.o$"
90 "\\\\.lo$"
91 "\\\\.la$"
92 "Makefile$"
93 "Makefile\\\\.in$"
94 # cmake cache files
95 "DartConfiguration.tcl$"
96 "CMakeCache.txt"
97 "CMakeFiles"
98 "cmake_install.cmake$"
99 "CMakeLists.txt.auto$"
100 "CTestTestfile.cmake"
101 "CPackConfig.cmake$"
102 "CPackSourceConfig.cmake$"
103 "libsatsolver.spec$"
104 )
105
106 INCLUDE(CPack)
107
108 ####################################################################
109
110 SET( DOC_INSTALL_DIR
111    "${CMAKE_INSTALL_PREFIX}/share/doc/packages/${PACKAGE}"
112    CACHE PATH "The install dir for documentation (default prefix/share/doc/packages/${PACKAGE})"
113    FORCE
114 )
115
116 ####################################################################
117 # INCLUDES                                                         #
118 ####################################################################
119
120 #SET (CMAKE_INCLUDE_DIRECTORIES_BEFORE ON)
121 INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/ext ${CMAKE_CURRENT_BINARY_DIR} SYSTEM )
122
123 ####################################################################
124
125 MESSAGE(STATUS "Looking modules in ${CMAKE_MODULE_PATH}")
126
127 set ( CMAKE_C_FLAGS     "${CMAKE_C_FLAGS} -Werror -Wall" )
128 set ( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -g -O3" )
129 set ( CMAKE_C_FLAGS_DEBUG     "${CMAKE_C_FLAGS} -g3 -O0" )
130
131 ADD_SUBDIRECTORY(src)
132 ADD_SUBDIRECTORY(ext)
133 ADD_SUBDIRECTORY(tools)
134 ADD_SUBDIRECTORY(applayer)
135 ADD_SUBDIRECTORY(tests)
136 ADD_SUBDIRECTORY(doc)
137
138 FIND_PACKAGE(SWIG)
139
140 IF ( SWIG_FOUND )
141   ADD_SUBDIRECTORY(bindings)
142 ELSE ( SWIG_FOUND )
143  # for older version of swig/cmake
144  FIND_PROGRAM(SWIG_EXECUTABLE
145    NAMES swig-1.3 swig
146   PATHS ${SWIG_DIR} ${SWIG_DIR}/.. ${SWIG_DIR}/../../bin /usr/bin /usr/local/bin ${CMAKE_INSTALL_PREFIX}/bin
147  )
148  IF ( SWIG_EXECUTABLE )
149   ADD_SUBDIRECTORY(bindings)
150  ENDIF ( SWIG_EXECUTABLE )
151 ENDIF ( SWIG_FOUND )
152
153 MESSAGE(STATUS "version: ${VERSION}")
154
155 ####################################################################
156 # RPM SPEC                                                         #
157 ####################################################################
158
159 MACRO(SPECFILE)
160   MESSAGE(STATUS "Writing spec file...")
161   CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/package/libsatsolver.spec.in ${CMAKE_BINARY_DIR}/package/libsatsolver.spec @ONLY)
162   #MESSAGE(STATUS "I hate you rpm-lint...!!!")
163   #CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/package/libsatsolver-rpmlint.cmake ${CMAKE_BINARY_DIR}/package/libsatsolver-rpmlintrc @ONLY)
164 ENDMACRO(SPECFILE)
165
166 SPECFILE()
167
168 ADD_CUSTOM_TARGET( svncheck
169   COMMAND cd $(CMAKE_SOURCE_DIR) && ! LC_ALL=C svn status --show-updates --quiet | grep -v '^Status against revision'
170 )
171
172 SET( AUTOBUILD_COMMAND
173   COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_BINARY_DIR}/package/*.tar.bz2
174   COMMAND mkdir -p _CPack_Packages/${CPACK_TOPLEVEL_TAG}
175   COMMAND ${CMAKE_MAKE_PROGRAM} package_source
176   COMMAND ${CMAKE_COMMAND} -E copy ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2 ${CMAKE_BINARY_DIR}/package
177   COMMAND ${CMAKE_COMMAND} -E remove ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2
178   COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/package/libsatsolver.changes" "${CMAKE_BINARY_DIR}/package/libsatsolver.changes"
179 )
180
181 ADD_CUSTOM_TARGET( srcpackage_local
182   ${AUTOBUILD_COMMAND}
183 )
184
185 ADD_CUSTOM_TARGET( srcpackage
186   COMMAND ${CMAKE_MAKE_PROGRAM} svncheck
187   ${AUTOBUILD_COMMAND}
188 )
189
190 INCLUDE(CTest)
191 ENABLE_TESTING()
192
193