Revision 8904
[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 ENDIF( NOT RPM_FOUND)
47
48 FIND_PACKAGE(Boost REQUIRED)
49 IF (Boost_FOUND)
50   MESSAGE( STATUS "boost found: includes in ${Boost_INCLUDE_DIRS}, library in ${Boost_LIBRARY_DIRS}")
51   INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
52   LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
53 ENDIF(Boost_FOUND)
54
55 FIND_PACKAGE(Gettext REQUIRED)
56 IF (GETTEXT_FOUND)
57   MESSAGE(STATUS "Found Gettext: ${GETTEXT_SOURCE}")
58   INCLUDE_DIRECTORIES(${GETTEXT_INCLUDE_DIR})
59 ELSE (GETTEXT_FOUND)
60   MESSAGE( FATAL_ERROR "Gettext not found" )
61 ENDIF (GETTEXT_FOUND)
62
63 FIND_PACKAGE(Hal REQUIRED)
64 IF ( NOT HAL_FOUND)
65   MESSAGE( FATAL_ERROR " Hal not found" )
66 ELSE ( NOT HAL_FOUND)
67   INCLUDE_DIRECTORIES(${HAL_INCLUDE_DIR})
68 # hal/libhal-storage.h is broken grrr
69   INCLUDE_DIRECTORIES(${HAL_INCLUDE_DIR}/hal)
70 ENDIF( NOT HAL_FOUND)
71
72 FIND_PACKAGE(Dbus REQUIRED)
73 IF ( NOT DBUS_FOUND)
74   MESSAGE( FATAL_ERROR " dbus not found" )
75 ELSE ( NOT DBUS_FOUND)
76   INCLUDE_DIRECTORIES(${DBUS_INCLUDE_DIR})
77   INCLUDE_DIRECTORIES(${DBUS_ARCH_INCLUDE_DIR})
78 ENDIF( NOT DBUS_FOUND)
79
80 FIND_PACKAGE(Glib REQUIRED)
81 IF (GLIB_FOUND)
82   MESSAGE( STATUS "glib found: includes in ${GLIB_INCLUDE_DIR}, library in ${GLIB_LIBRARY}")
83   INCLUDE_DIRECTORIES(${GLIB_INCLUDE_DIR})
84   INCLUDE_DIRECTORIES(${GLIB_CONFIG_INCLUDE_DIR})
85 ELSE(GLIB_FOUND)
86   MESSAGE( FATAL_ERROR "glib not found" )
87 ENDIF(GLIB_FOUND)
88
89 FIND_PACKAGE(Curl REQUIRED)
90 IF ( NOT CURL_FOUND)
91   MESSAGE( FATAL_ERROR " curl not found" )
92 ELSE ( NOT CURL_FOUND)
93   INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIR})
94 ENDIF( NOT CURL_FOUND)
95
96 FIND_PACKAGE(Libxml REQUIRED)
97 IF ( NOT LIBXML_FOUND)
98   MESSAGE( FATAL_ERROR " libxml not found" )
99 ELSE ( NOT LIBXML_FOUND)
100   INCLUDE_DIRECTORIES(${LIBXML_INCLUDE_DIR})
101 ENDIF( NOT LIBXML_FOUND)
102
103 FIND_PACKAGE(ZLIB REQUIRED)
104 IF ( NOT ZLIB_FOUND)
105   MESSAGE( FATAL_ERROR " zlib not found" )
106 ELSE ( NOT ZLIB_FOUND)
107   INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
108 ENDIF( NOT ZLIB_FOUND)
109
110 FIND_PACKAGE(Satsolver REQUIRED)
111 IF ( NOT SATSOLVER_FOUND )
112   MESSAGE( FATAL_ERROR " libsatsolver not found" )
113 ELSE ( NOT SATSOLVER_FOUND )
114   INCLUDE_DIRECTORIES( ${SATSOLVER_INCLUDE_DIR} )
115 ENDIF( NOT SATSOLVER_FOUND )
116
117 FIND_PROGRAM( DOXYGEN doxygen )
118 IF ( NOT DOXYGEN )
119   MESSAGE( FATAL_ERROR "doxygen not found: install doxygen to build the documentation." )
120 ELSE ( NOT DOXYGEN )
121   MESSAGE( STATUS "doxygen found: ${DOXYGEN}" )
122 ENDIF ( NOT DOXYGEN )
123
124 MESSAGE(STATUS "soname: ${LIBZYPP_VERSION_INFO}")
125 MESSAGE(STATUS "version: ${VERSION}")
126
127 MESSAGE(STATUS "Writing pkg-config file...")
128 CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/libzypp.pc.cmake ${CMAKE_BINARY_DIR}/libzypp.pc @ONLY)
129 INSTALL( FILES ${CMAKE_BINARY_DIR}/libzypp.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig )
130
131 MESSAGE(STATUS "FindZypp.cmake will be installed in ${CMAKE_INSTALL_PREFIX}/share/cmake/Modules")
132 INSTALL( FILES ${CMAKE_SOURCE_DIR}/cmake/modules/FindZypp.cmake DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cmake/Modules )
133 INSTALL( FILES ${CMAKE_SOURCE_DIR}/cmake/modules/ZyppCommon.cmake DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cmake/Modules )
134
135 MESSAGE(STATUS "zypp.conf will be installed in ${SYSCONFDIR}/zypp")
136 INSTALL( FILES ${CMAKE_SOURCE_DIR}/zypp.conf DESTINATION ${SYSCONFDIR}/zypp )
137
138 ####################################################################
139 # SUBDIRECTORIES                                                   #
140 ####################################################################
141
142 ADD_SUBDIRECTORY( zypp )
143 #ADD_SUBDIRECTORY( zypp2 )
144 # do not build devel by default
145 ADD_SUBDIRECTORY( devel EXCLUDE_FROM_ALL )
146 ADD_SUBDIRECTORY( tools )
147 #ADD_SUBDIRECTORY( examples )
148 ADD_SUBDIRECTORY( po EXCLUDE_FROM_ALL )
149 ADD_SUBDIRECTORY( doc EXCLUDE_FROM_ALL )
150 ADD_SUBDIRECTORY( tests EXCLUDE_FROM_ALL )
151