adapt to cmake 2.6:
[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 )
87
88 INCLUDE(CPack)
89
90 ####################################################################
91
92 SET( DOC_INSTALL_DIR
93    "${CMAKE_INSTALL_PREFIX}/share/doc/packages/${PACKAGE}"
94    CACHE PATH "The install dir for documentation (default prefix/share/doc/packages/${PACKAGE})"
95    FORCE
96 )
97
98 ####################################################################
99 # INCLUDES                                                         #
100 ####################################################################
101
102 #SET (CMAKE_INCLUDE_DIRECTORIES_BEFORE ON)
103 INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR} SYSTEM )
104
105 ####################################################################
106
107 MESSAGE(STATUS "Looking modules in ${CMAKE_MODULE_PATH}")
108 FIND_PROGRAM(SWIG_EXECUTABLE
109   NAMES swig-1.3 swig
110   PATHS ${SWIG_DIR} ${SWIG_DIR}/.. ${SWIG_DIR}/../../bin /usr/bin /usr/local/bin ${CMAKE_INSTALL_PREFIX}/bin
111 )
112
113 set ( CMAKE_C_FLAGS     "${CMAKE_C_FLAGS} -Werror -Wall" )
114 set ( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -g -O3" )
115 set ( CMAKE_C_FLAGS_DEBUG     "${CMAKE_C_FLAGS} -g3 -O0" )
116
117 ADD_SUBDIRECTORY(src)
118 ADD_SUBDIRECTORY(tools)
119 ADD_SUBDIRECTORY(applayer)
120 ADD_SUBDIRECTORY(testsuite)
121
122 IF ( NOT SWIG_EXECUTABLE )
123   MESSAGE( FATAL "SWIG not found." )
124 ELSE ( NOT SWIG_EXECUTABLE )
125   MESSAGE( STATUS "SWIG found at ${SWIG_EXECUTABLE}" )
126   ADD_SUBDIRECTORY(bindings)
127 ENDIF ( NOT SWIG_EXECUTABLE )
128
129 MESSAGE(STATUS "version: ${VERSION}")
130
131 ####################################################################
132 # RPM SPEC                                                         #
133 ####################################################################
134
135 MACRO(SPECFILE)
136   MESSAGE(STATUS "Writing spec file...")
137   CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/package/libsatsolver.spec.in ${CMAKE_BINARY_DIR}/package/libsatsolver.spec @ONLY)
138   #MESSAGE(STATUS "I hate you rpm-lint...!!!")
139   #CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/package/libsatsolver-rpmlint.cmake ${CMAKE_BINARY_DIR}/package/libsatsolver-rpmlintrc @ONLY)
140 ENDMACRO(SPECFILE)
141
142 SPECFILE()
143
144 ADD_CUSTOM_TARGET( svncheck
145   COMMAND cd $(CMAKE_SOURCE_DIR) && ! LC_ALL=C svn status --show-updates --quiet | grep -v '^Status against revision'
146 )
147
148 SET( AUTOBUILD_COMMAND
149   COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_BINARY_DIR}/package/*.tar.bz2
150   COMMAND ${CMAKE_MAKE_PROGRAM} package_source
151   COMMAND ${CMAKE_COMMAND} -E copy ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2 ${CMAKE_BINARY_DIR}/package
152   COMMAND ${CMAKE_COMMAND} -E remove ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2
153   COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/package/libsatsolver.changes" "${CMAKE_BINARY_DIR}/package/libsatsolver.changes"
154 )
155
156 ADD_CUSTOM_TARGET( srcpackage_local
157   ${AUTOBUILD_COMMAND}
158 )
159
160 ADD_CUSTOM_TARGET( srcpackage
161   COMMAND ${CMAKE_MAKE_PROGRAM} svncheck
162   ${AUTOBUILD_COMMAND}
163 )