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