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