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