cleanup in return values of doUpgrade and doUpdate
[platform/upstream/libzypp.git] / CMakeLists.txt
1 PROJECT(libzypp)
2 SET( PACKAGE "libzypp" )
3 # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
4 SET( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules )
5
6 INCLUDE(ZyppCommon)
7 INCLUDE( ${CMAKE_SOURCE_DIR}/VERSION.cmake )
8
9 MATH( EXPR LIBZYPP_CURRENT "${LIBZYPP_MAJOR} * 100 + ${LIBZYPP_MINOR}" )
10 MATH( EXPR LIBZYPP_AGE     "${LIBZYPP_MINOR} - ${LIBZYPP_COMPATMINOR}" )
11 # Libtool wanted current:patch:age
12 # But cmake is not libtool, it wants the verbatim suffix to libzypp.so
13 MATH( EXPR LIBZYPP_SO_FIRST  "${LIBZYPP_CURRENT}-${LIBZYPP_AGE}" )
14 SET( VERSION "${LIBZYPP_MAJOR}.${LIBZYPP_MINOR}.${LIBZYPP_PATCH}" )
15
16 SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Woverloaded-virtual" )
17 SET( CMAKE_C_FLAGS   "${CMAKE_C_FLAGS}   -g -Wall" )
18 set( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -O3" )
19 set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O3" )
20
21 ADD_DEFINITIONS( -D_FILE_OFFSET_BITS=64 )
22 ADD_DEFINITIONS( -DVERSION=\\\"${VERSION}\\\" )
23 SET( LIBZYPP_VERSION_INFO "${LIBZYPP_SO_FIRST}.${LIBZYPP_AGE}.${LIBZYPP_PATCH}" )
24 SET( LIBZYPP_SOVERSION_INFO "${LIBZYPP_SO_FIRST}" )
25
26 GENERATE_PACKAGING(${PACKAGE} ${VERSION})
27
28 INCLUDE(CPack)
29
30 MACRO(ADD_TESTS)
31   FOREACH( loop_var ${ARGV} )
32     SET_SOURCE_FILES_PROPERTIES( ${loop_var}_test.cc COMPILE_FLAGS "-DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN -DBOOST_AUTO_TEST_MAIN=\"\" " )
33     ADD_EXECUTABLE( ${loop_var}_test ${loop_var}_test.cc )
34     TARGET_LINK_LIBRARIES( ${loop_var}_test  zypp boost_unit_test_framework)
35     ADD_TEST( ${loop_var}_test ${CMAKE_CURRENT_BINARY_DIR}/${loop_var}_test)
36   ENDFOREACH( loop_var )
37 ENDMACRO(ADD_TESTS)
38
39 ####################################################################
40
41 FIND_PACKAGE(Rpm REQUIRED)
42 IF ( NOT RPM_FOUND)
43   MESSAGE( FATAL_ERROR " rpm-devel not found" )
44 ELSE ( NOT RPM_FOUND)
45   INCLUDE_DIRECTORIES(${RPM_INCLUDE_DIR})
46   # fix includes not relative to rpm
47   INCLUDE_DIRECTORIES(${RPM_INCLUDE_DIR}/rpm)
48 ENDIF( NOT RPM_FOUND)
49
50 FIND_PACKAGE(Boost REQUIRED)
51 IF (Boost_FOUND)
52   MESSAGE( STATUS "boost found: includes in ${Boost_INCLUDE_DIRS}, library in ${Boost_LIBRARY_DIRS}")
53   INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
54   LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
55 ENDIF(Boost_FOUND)
56
57 FIND_PACKAGE(Gettext REQUIRED)
58 IF (GETTEXT_FOUND)
59   MESSAGE(STATUS "Found Gettext: ${GETTEXT_SOURCE}")
60   INCLUDE_DIRECTORIES(${GETTEXT_INCLUDE_DIR})
61 ELSE (GETTEXT_FOUND)
62   MESSAGE( FATAL_ERROR "Gettext not found" )
63 ENDIF (GETTEXT_FOUND)
64
65 FIND_PACKAGE(Hal REQUIRED)
66 IF ( NOT HAL_FOUND)
67   MESSAGE( FATAL_ERROR " Hal not found" )
68 ELSE ( NOT HAL_FOUND)
69   INCLUDE_DIRECTORIES(${HAL_INCLUDE_DIR})
70 # hal/libhal-storage.h is broken grrr
71   INCLUDE_DIRECTORIES(${HAL_INCLUDE_DIR}/hal)
72 ENDIF( NOT HAL_FOUND)
73
74 FIND_PACKAGE(Dbus REQUIRED)
75 IF ( NOT DBUS_FOUND)
76   MESSAGE( FATAL_ERROR " dbus not found" )
77 ELSE ( NOT DBUS_FOUND)
78   INCLUDE_DIRECTORIES(${DBUS_INCLUDE_DIR})
79   INCLUDE_DIRECTORIES(${DBUS_ARCH_INCLUDE_DIR})
80 ENDIF( NOT DBUS_FOUND)
81
82 FIND_PACKAGE(Curl REQUIRED)
83 IF ( NOT CURL_FOUND)
84   MESSAGE( FATAL_ERROR " curl not found" )
85 ELSE ( NOT CURL_FOUND)
86   INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIR})
87 ENDIF( NOT CURL_FOUND)
88
89 FIND_PACKAGE(Libxml REQUIRED)
90 IF ( NOT LIBXML_FOUND)
91   MESSAGE( FATAL_ERROR " libxml not found" )
92 ELSE ( NOT LIBXML_FOUND)
93   INCLUDE_DIRECTORIES(${LIBXML_INCLUDE_DIR})
94 ENDIF( NOT LIBXML_FOUND)
95
96 FIND_PACKAGE(ZLIB REQUIRED)
97 IF ( NOT ZLIB_FOUND)
98   MESSAGE( FATAL_ERROR " zlib not found" )
99 ELSE ( NOT ZLIB_FOUND)
100   INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
101 ENDIF( NOT ZLIB_FOUND)
102
103 FIND_PACKAGE(Satsolver REQUIRED)
104 IF ( NOT SATSOLVER_FOUND )
105   MESSAGE( FATAL_ERROR " libsatsolver not found" )
106 ELSE ( NOT SATSOLVER_FOUND )
107   INCLUDE_DIRECTORIES( ${SATSOLVER_INCLUDE_DIR} )
108 ENDIF( NOT SATSOLVER_FOUND )
109
110 FIND_PACKAGE(OpenSSL REQUIRED)
111
112 FIND_PROGRAM( DOXYGEN doxygen )
113 IF ( NOT DOXYGEN )
114   MESSAGE( FATAL_ERROR "doxygen not found: install doxygen to build the documentation." )
115 ELSE ( NOT DOXYGEN )
116   MESSAGE( STATUS "doxygen found: ${DOXYGEN}" )
117 ENDIF ( NOT DOXYGEN )
118
119 MESSAGE(STATUS "soname: ${LIBZYPP_VERSION_INFO}")
120 MESSAGE(STATUS "version: ${VERSION}")
121
122 MESSAGE(STATUS "Writing pkg-config file...")
123 CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/libzypp.pc.cmake ${CMAKE_BINARY_DIR}/libzypp.pc @ONLY)
124 INSTALL( FILES ${CMAKE_BINARY_DIR}/libzypp.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig )
125
126 MESSAGE(STATUS "FindZypp.cmake will be installed in ${CMAKE_INSTALL_PREFIX}/share/cmake/Modules")
127 INSTALL( FILES ${CMAKE_SOURCE_DIR}/cmake/modules/FindZypp.cmake DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cmake/Modules )
128 INSTALL( FILES ${CMAKE_SOURCE_DIR}/cmake/modules/ZyppCommon.cmake DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cmake/Modules )
129
130 MESSAGE(STATUS "zypp.conf will be installed in ${SYSCONFDIR}/zypp")
131 INSTALL( FILES ${CMAKE_SOURCE_DIR}/zypp.conf DESTINATION ${SYSCONFDIR}/zypp )
132
133 ####################################################################
134 # SUBDIRECTORIES                                                   #
135 ####################################################################
136
137 ADD_SUBDIRECTORY( zypp )
138 #ADD_SUBDIRECTORY( zypp2 )
139 # do not build devel by default
140 ADD_SUBDIRECTORY( devel EXCLUDE_FROM_ALL )
141 ADD_SUBDIRECTORY( tools )
142 #ADD_SUBDIRECTORY( examples )
143 ADD_SUBDIRECTORY( po EXCLUDE_FROM_ALL )
144 ADD_SUBDIRECTORY( doc EXCLUDE_FROM_ALL )
145 ADD_SUBDIRECTORY( tests EXCLUDE_FROM_ALL )
146