2 SET( PACKAGE "libzypp" )
3 # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
4 SET( CMAKE_MODULE_PATH ${LIBZYPP_SOURCE_DIR}/cmake/modules )
5 cmake_minimum_required(VERSION 2.6)
7 # allow name libraries by name mixed with full
9 if(COMMAND cmake_policy)
10 cmake_policy(SET CMP0003 NEW)
11 endif(COMMAND cmake_policy)
14 INCLUDE( ${LIBZYPP_SOURCE_DIR}/VERSION.cmake )
16 MATH( EXPR LIBZYPP_CURRENT "${LIBZYPP_MAJOR} * 100 + ${LIBZYPP_MINOR}" )
17 MATH( EXPR LIBZYPP_AGE "${LIBZYPP_MINOR} - ${LIBZYPP_COMPATMINOR}" )
18 # Libtool wanted current:patch:age
19 # But cmake is not libtool, it wants the verbatim suffix to libzypp.so
20 MATH( EXPR LIBZYPP_SO_FIRST "${LIBZYPP_CURRENT}-${LIBZYPP_AGE}" )
21 SET( VERSION "${LIBZYPP_MAJOR}.${LIBZYPP_MINOR}.${LIBZYPP_PATCH}" )
23 include(CheckCCompilerFlag)
24 include(CheckCXXCompilerFlag)
25 CHECK_C_COMPILER_FLAG("-Werror=format-security" CC_FORMAT_SECURITY)
26 CHECK_CXX_COMPILER_FLAG("-Werror=format-security" CXX_FORMAT_SECURITY)
28 SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing -fPIC -g -Wall -Woverloaded-virtual -Wnon-virtual-dtor -Wl,-as-needed -std=c++0x" )
29 SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-strict-aliasing -fPIC -g -Wall -Wl,-as-needed" )
31 set( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -O3" )
32 set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O3" )
34 IF(${CC_FORMAT_SECURITY})
35 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=format-security")
36 ENDIF(${CC_FORMAT_SECURITY})
38 IF(${CXX_FORMAT_SECURITY})
39 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=format-security")
40 ENDIF(${CXX_FORMAT_SECURITY})
42 INCLUDE(CheckFunctionExists)
43 CHECK_FUNCTION_EXISTS(pipe2 PIPE2_FOUND)
45 ADD_DEFINITIONS(-DHAVE_PIPE2)
48 ADD_DEFINITIONS( -D_FILE_OFFSET_BITS=64 )
49 ADD_DEFINITIONS( -DVERSION="${VERSION}" )
50 SET( LIBZYPP_VERSION_INFO "${LIBZYPP_SO_FIRST}.${LIBZYPP_AGE}.${LIBZYPP_PATCH}" )
51 SET( LIBZYPP_SOVERSION_INFO "${LIBZYPP_SO_FIRST}" )
53 GENERATE_PACKAGING(${PACKAGE} ${VERSION})
58 FOREACH( loop_var ${ARGV} )
59 SET_SOURCE_FILES_PROPERTIES( ${loop_var}_test.cc COMPILE_FLAGS "-DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN -DBOOST_AUTO_TEST_MAIN=\"\" " )
60 ADD_EXECUTABLE( ${loop_var}_test ${loop_var}_test.cc )
61 TARGET_LINK_LIBRARIES( ${loop_var}_test zypp boost_unit_test_framework zypp_test_utils)
62 ADD_TEST( ${loop_var}_test ${CMAKE_CURRENT_BINARY_DIR}/${loop_var}_test --catch_system_errors=no)
63 ENDFOREACH( loop_var )
66 ####################################################################
67 # prefer packages using the same install prefix as we do
68 SET(CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX} usr/localX /usr/local /usr)
70 FIND_PACKAGE(Rpm REQUIRED)
72 MESSAGE( FATAL_ERROR " rpm-devel not found" )
74 INCLUDE_DIRECTORIES(${RPM_INCLUDE_DIR})
75 # fix includes not relative to rpm
76 INCLUDE_DIRECTORIES(${RPM_INCLUDE_DIR}/rpm)
77 if ( RPM_SUSPECT_VERSION STREQUAL "5.x" )
78 MESSAGE( STATUS "rpm found: enable rpm-4 compat interface." )
79 ADD_DEFINITIONS(-D_RPM_5)
80 elseif ( RPM_SUSPECT_VERSION STREQUAL "4.x" )
81 MESSAGE( STATUS "rpm found: use rpm-4.x interface." )
82 ADD_DEFINITIONS(-D_RPM_4_X)
83 elseif ( RPM_SUSPECT_VERSION STREQUAL "4.4" )
84 MESSAGE( STATUS "rpm found: enable rpm-4.4 legacy interface." )
85 ADD_DEFINITIONS(-D_RPM_4_4)
86 endif ( RPM_SUSPECT_VERSION STREQUAL "5.x" )
89 FIND_PACKAGE(Boost REQUIRED COMPONENTS program_options unit_test_framework)
91 MESSAGE( STATUS "boost found: includes in ${Boost_INCLUDE_DIRS}, library in ${Boost_LIBRARY_DIRS}")
92 INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
93 LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
96 FIND_PACKAGE(Gettext REQUIRED)
98 MESSAGE(STATUS "Found Gettext: ${GETTEXT_SOURCE}")
99 INCLUDE_DIRECTORIES(${GETTEXT_INCLUDE_DIR})
101 MESSAGE( FATAL_ERROR "Gettext not found" )
102 ENDIF (GETTEXT_FOUND)
104 FIND_PACKAGE(Curl REQUIRED)
106 MESSAGE( FATAL_ERROR " curl not found" )
107 ELSE ( NOT CURL_FOUND)
108 INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIR})
109 ENDIF( NOT CURL_FOUND)
111 FIND_PACKAGE(Libxml REQUIRED)
112 IF ( NOT LIBXML_FOUND)
113 MESSAGE( FATAL_ERROR " libxml not found" )
114 ELSE ( NOT LIBXML_FOUND)
115 INCLUDE_DIRECTORIES(${LIBXML_INCLUDE_DIR})
116 ENDIF( NOT LIBXML_FOUND)
118 FIND_PACKAGE(ZLIB REQUIRED)
120 MESSAGE( FATAL_ERROR " zlib not found" )
121 ELSE ( NOT ZLIB_FOUND)
122 INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
123 ENDIF( NOT ZLIB_FOUND)
125 #SET(LibSolv_USE_STATIC_LIBS ON)
126 FIND_PACKAGE(LibSolv REQUIRED ext)
127 IF ( NOT LibSolv_FOUND )
128 MESSAGE( FATAL_ERROR " libsolv not found" )
130 INCLUDE_DIRECTORIES( ${LibSolv_INCLUDE_DIRS} )
133 # libsolv uses expat and has open references to it:
134 FIND_PACKAGE(EXPAT REQUIRED)
136 FIND_PACKAGE(OpenSSL REQUIRED)
139 IF ( NOT UDEV_FOUND )
142 MESSAGE(WARNING "No udev or HAL. CD device detection will be poor")
143 ELSE ( NOT HAL_FOUND )
144 ADD_DEFINITIONS(-DHAVE_HAL)
145 INCLUDE_DIRECTORIES(${HAL_INCLUDE_DIR})
146 INCLUDE_DIRECTORIES(${HAL_INCLUDE_DIR}/hal)
147 # HAL requires working dbus
148 FIND_PACKAGE(Dbus REQUIRED)
150 INCLUDE_DIRECTORIES(${DBUS_INCLUDE_DIR})
151 INCLUDE_DIRECTORIES(${DBUS_ARCH_INCLUDE_DIR})
153 ENDIF ( NOT HAL_FOUND )
154 ELSE ( NOT UDEV_FOUND )
155 ADD_DEFINITIONS(-DHAVE_UDEV)
156 ENDIF ( NOT UDEV_FOUND )
158 FIND_PACKAGE(libproxy)
159 IF ( NOT LIBPROXY_FOUND )
160 MESSAGE( STATUS " libproxy not found" )
161 ELSE ( NOT LIBPROXY_FOUND )
162 INCLUDE_DIRECTORIES( ${LIBPROXY_INCLUDE_DIR} )
163 ADD_DEFINITIONS(-D_WITH_LIBPROXY_SUPPORT_)
164 ENDIF( NOT LIBPROXY_FOUND )
166 FIND_PROGRAM( DOXYGEN doxygen )
168 MESSAGE( FATAL_ERROR "doxygen not found: install doxygen to build the documentation." )
170 MESSAGE( STATUS "doxygen found: ${DOXYGEN}" )
171 ENDIF ( NOT DOXYGEN )
173 MESSAGE(STATUS "soname: ${LIBZYPP_VERSION_INFO}")
174 MESSAGE(STATUS "version: ${VERSION}")
176 MESSAGE(STATUS "Writing pkg-config file...")
177 CONFIGURE_FILE(${LIBZYPP_SOURCE_DIR}/libzypp.pc.cmake ${LIBZYPP_BINARY_DIR}/libzypp.pc @ONLY)
178 INSTALL( FILES ${LIBZYPP_BINARY_DIR}/libzypp.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig )
180 MESSAGE(STATUS "FindZypp.cmake will be installed in ${CMAKE_INSTALL_PREFIX}/share/cmake/Modules")
181 INSTALL( FILES ${LIBZYPP_SOURCE_DIR}/cmake/modules/FindZypp.cmake DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cmake/Modules )
182 INSTALL( FILES ${LIBZYPP_SOURCE_DIR}/cmake/modules/ZyppCommon.cmake DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cmake/Modules )
184 ####################################################################
186 # (don't forget to mention them in the .spec file)
187 ####################################################################
189 MESSAGE(STATUS "zypp.conf will be installed in ${SYSCONFDIR}/zypp")
190 INSTALL( FILES ${LIBZYPP_SOURCE_DIR}/zypp.conf DESTINATION ${SYSCONFDIR}/zypp )
193 MESSAGE(STATUS "systemCheck will be installed in ${SYSCONFDIR}/zypp")
194 INSTALL( FILES ${LIBZYPP_SOURCE_DIR}/systemCheck DESTINATION ${SYSCONFDIR}/zypp )
196 # logrotate config file
197 INSTALL( FILES ${LIBZYPP_SOURCE_DIR}/zypp-history.lr DESTINATION ${SYSCONFDIR}/logrotate.d )
199 ####################################################################
201 ####################################################################
203 ADD_SUBDIRECTORY( zypp )
204 #ADD_SUBDIRECTORY( zypp2 )
205 # do not build devel by default
206 ADD_SUBDIRECTORY( devel EXCLUDE_FROM_ALL )
207 ADD_SUBDIRECTORY( tools )
208 ADD_SUBDIRECTORY( examples )
209 ADD_SUBDIRECTORY( po EXCLUDE_FROM_ALL )
210 ADD_SUBDIRECTORY( doc )
211 ADD_SUBDIRECTORY( vendor )
212 ADD_SUBDIRECTORY( tests EXCLUDE_FROM_ALL )