forked from openSUSE/libzypp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
288 lines (239 loc) · 10.8 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
PROJECT(LIBZYPP)
SET( PACKAGE "libzypp" )
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
SET( CMAKE_MODULE_PATH ${LIBZYPP_SOURCE_DIR}/cmake/modules )
cmake_minimum_required(VERSION 2.6)
OPTION (ENABLE_BUILD_DOCS "Build documentation by default?" OFF)
OPTION (ENABLE_BUILD_TRANS "Build translation files by default?" OFF)
OPTION (ENABLE_BUILD_TESTS "Build and run test suite by default?" OFF)
OPTION (ENABLE_USE_THREADS "Enable using threads (NOT being used by threads!)?" OFF)
OPTION (DISABLE_LIBPROXY "Build without libproxy support even if package is installed?" OFF)
OPTION (DISABLE_AUTODOCS "Do not require doxygen being installed (required to build autodocs)?" OFF)
#--------------------------------------------------------------------------------
SET (have_system x)
IF (DEBIAN)
MESSAGE (STATUS "Building for Debian")
SET (ENABLE_BUILD_DOCS ON)
SET (ENABLE_BUILD_TRANS ON)
SET (ENABLE_BUILD_TESTS ON)
SET (have_system ${have_system}x)
ENDIF (DEBIAN)
IF (${have_system} STREQUAL x)
MESSAGE (STATUS "Building for SUSE")
ENDIF (${have_system} STREQUAL x)
IF (${have_system} STRGREATER xx)
MESSAGE (FATAL_ERROR "Can only build for one system type.")
ENDIF (${have_system} STRGREATER xx)
#--------------------------------------------------------------------------------
# allow name libraries by name mixed with full
# paths
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)
INCLUDE(ZyppCommon)
INCLUDE( ${LIBZYPP_SOURCE_DIR}/VERSION.cmake )
MATH( EXPR LIBZYPP_CURRENT "${LIBZYPP_MAJOR} * 100 + ${LIBZYPP_MINOR}" )
MATH( EXPR LIBZYPP_AGE "${LIBZYPP_MINOR} - ${LIBZYPP_COMPATMINOR}" )
# Libtool wanted current:patch:age
# But cmake is not libtool, it wants the verbatim suffix to libzypp.so
MATH( EXPR LIBZYPP_SO_FIRST "${LIBZYPP_CURRENT}-${LIBZYPP_AGE}" )
SET( VERSION "${LIBZYPP_MAJOR}.${LIBZYPP_MINOR}.${LIBZYPP_PATCH}" )
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
CHECK_C_COMPILER_FLAG("-Werror=format-security" CC_FORMAT_SECURITY)
CHECK_CXX_COMPILER_FLAG("-Werror=format-security" CXX_FORMAT_SECURITY)
SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-strict-aliasing -fPIC -g -rdynamic -Wall -Wl,-as-needed -Wp,-D_GLIBCXX_ASSERTIONS" )
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing -fPIC -g -rdynamic -Wall -Wl,-as-needed -Wp,-D_GLIBCXX_ASSERTIONS" )
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden -Woverloaded-virtual -Wnon-virtual-dtor" )
set( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -O3 -DZYPP_NDEBUG" )
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O3 -DZYPP_NDEBUG" )
IF(${CC_FORMAT_SECURITY})
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=format-security")
ENDIF(${CC_FORMAT_SECURITY})
IF(${CXX_FORMAT_SECURITY})
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=format-security")
ENDIF(${CXX_FORMAT_SECURITY})
INCLUDE(CheckFunctionExists)
CHECK_FUNCTION_EXISTS(pipe2 PIPE2_FOUND)
IF(${PIPE2_FOUND})
ADD_DEFINITIONS(-DHAVE_PIPE2)
ENDIF(${PIPE2_FOUND})
ADD_DEFINITIONS( -D_FILE_OFFSET_BITS=64 )
ADD_DEFINITIONS( -DVERSION="${VERSION}" )
SET( LIBZYPP_VERSION_INFO "${LIBZYPP_SO_FIRST}.${LIBZYPP_AGE}.${LIBZYPP_PATCH}" )
SET( LIBZYPP_SOVERSION_INFO "${LIBZYPP_SO_FIRST}" )
GENERATE_PACKAGING(${PACKAGE} ${VERSION})
INCLUDE(CPack)
MACRO(ADD_TESTS)
FOREACH( loop_var ${ARGV} )
SET_SOURCE_FILES_PROPERTIES( ${loop_var}_test.cc COMPILE_FLAGS "-DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN -DBOOST_AUTO_TEST_MAIN=\"\" " )
ADD_EXECUTABLE( ${loop_var}_test ${loop_var}_test.cc )
TARGET_LINK_LIBRARIES( ${loop_var}_test zypp ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} zypp_test_utils)
ADD_TEST( ${loop_var}_test ${CMAKE_CURRENT_BINARY_DIR}/${loop_var}_test --catch_system_errors=no)
ENDFOREACH( loop_var )
ENDMACRO(ADD_TESTS)
####################################################################
IF ( ENABLE_USE_THREADS )
SET( CMAKE_THREAD_PREFER_PTHREAD TRUE )
FIND_PACKAGE( Threads REQUIRED )
IF ( CMAKE_USE_PTHREADS_INIT )
MESSAGE( STATUS "May use threads." )
SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread -DZYPP_USE_THREADS" )
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -DZYPP_USE_THREADS" )
ENDIF ( CMAKE_USE_PTHREADS_INIT )
ENDIF ( ENABLE_USE_THREADS )
FIND_PACKAGE(Rpm REQUIRED)
IF ( NOT RPM_FOUND)
MESSAGE( FATAL_ERROR " rpm-devel not found" )
ELSE ( NOT RPM_FOUND)
INCLUDE_DIRECTORIES(${RPM_INCLUDE_DIR})
# fix includes not relative to rpm
INCLUDE_DIRECTORIES(${RPM_INCLUDE_DIR}/rpm)
if ( RPM_SUSPECT_VERSION STREQUAL "5.x" )
MESSAGE( STATUS "rpm found: enable rpm-4 compat interface." )
ADD_DEFINITIONS(-D_RPM_5)
endif ( RPM_SUSPECT_VERSION STREQUAL "5.x" )
ENDIF( NOT RPM_FOUND)
FIND_PACKAGE(Boost REQUIRED COMPONENTS program_options unit_test_framework thread)
IF (Boost_FOUND)
MESSAGE( STATUS "boost found: includes in ${Boost_INCLUDE_DIRS}, library in ${Boost_LIBRARY_DIRS}")
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
ENDIF(Boost_FOUND)
FIND_PACKAGE(Gettext REQUIRED)
IF (GETTEXT_FOUND)
MESSAGE(STATUS "Found Gettext: ${GETTEXT_SOURCE}")
INCLUDE_DIRECTORIES(${GETTEXT_INCLUDE_DIR})
ELSE (GETTEXT_FOUND)
MESSAGE( FATAL_ERROR "Gettext not found" )
ENDIF (GETTEXT_FOUND)
FIND_PACKAGE(CURL REQUIRED)
IF ( NOT CURL_FOUND)
MESSAGE( FATAL_ERROR " curl not found" )
ELSE ( NOT CURL_FOUND)
INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIRS})
ENDIF( NOT CURL_FOUND)
FIND_PACKAGE(LibXml2 REQUIRED)
IF ( NOT LIBXML2_FOUND)
MESSAGE( FATAL_ERROR " libxml not found" )
ELSE ( NOT LIBXML2_FOUND)
INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR})
ENDIF( NOT LIBXML2_FOUND)
FIND_PACKAGE(ZLIB REQUIRED)
IF ( NOT ZLIB_FOUND)
MESSAGE( FATAL_ERROR " zlib not found" )
ELSE ( NOT ZLIB_FOUND)
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
ENDIF( NOT ZLIB_FOUND)
#Allow to override the libsolv install location
IF( LIBSOLV_SRCDIR AND LIBSOLV_BUILDDIR )
execute_process(
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/libsolv
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/libsolv/include
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/libsolv/ext
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/libsolv/solvversion
COMMAND ${CMAKE_COMMAND} -E create_symlink ${LIBSOLV_SRCDIR}/src ${CMAKE_BINARY_DIR}/libsolv/include/solv
COMMAND ${CMAKE_COMMAND} -E create_symlink ${LIBSOLV_SRCDIR}/ext ${CMAKE_BINARY_DIR}/libsolv/ext/solv
COMMAND ${CMAKE_COMMAND} -E create_symlink ${LIBSOLV_BUILDDIR}/src ${CMAKE_BINARY_DIR}/libsolv/solvversion/solv
)
INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR}/libsolv/include ${CMAKE_BINARY_DIR}/libsolv/ext ${CMAKE_BINARY_DIR}/libsolv/solvversion ${CMAKE_BINARY_DIR}/libsolv/solvversion/solv ${CMAKE_BINARY_DIR}/libsolv/ext/solv ${CMAKE_BINARY_DIR}/libsolv/include/solv )
SET( LibSolv_LIBRARIES ${LIBSOLV_BUILDDIR}/src/libsolv.a ${LIBSOLV_BUILDDIR}/ext/libsolvext.a )
ELSE()
FIND_PACKAGE(LibSolv REQUIRED ext)
#SET(LibSolv_USE_STATIC_LIBS ON)
IF ( NOT LibSolv_FOUND )
MESSAGE( FATAL_ERROR " libsolv not found" )
ELSE()
INCLUDE_DIRECTORIES( ${LibSolv_INCLUDE_DIRS} )
ENDIF()
ENDIF( LIBSOLV_SRCDIR AND LIBSOLV_BUILDDIR )
FIND_PACKAGE(Gpgme REQUIRED)
IF ( NOT GPGME_PTHREAD_FOUND )
MESSAGE( FATAL_ERROR " gpgme not found" )
ELSE()
INCLUDE_DIRECTORIES( ${GPGME_INCLUDES} )
LINK_DIRECTORIES(${GPGME_LIBRARY_DIR})
ENDIF()
FIND_PACKAGE(OpenSSL REQUIRED)
FIND_PACKAGE(Udev)
IF ( NOT UDEV_FOUND )
FIND_PACKAGE(Hal)
IF ( NOT HAL_FOUND )
MESSAGE(WARNING "No udev or HAL. CD device detection will be poor")
ELSE ( NOT HAL_FOUND )
ADD_DEFINITIONS(-DHAVE_HAL)
INCLUDE_DIRECTORIES(${HAL_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${HAL_INCLUDE_DIR}/hal)
# HAL requires working dbus
FIND_PACKAGE(Dbus REQUIRED)
IF(DBUS_FOUND)
INCLUDE_DIRECTORIES(${DBUS_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${DBUS_ARCH_INCLUDE_DIR})
ENDIF(DBUS_FOUND)
ENDIF ( NOT HAL_FOUND )
ELSE ( NOT UDEV_FOUND )
ADD_DEFINITIONS(-DHAVE_UDEV)
ENDIF ( NOT UDEV_FOUND )
IF( DISABLE_LIBPROXY )
MESSAGE( STATUS "libproxy support disabled" )
ELSE( DISABLE_LIBPROXY )
FIND_PACKAGE(libproxy)
IF ( NOT LIBPROXY_FOUND )
MESSAGE( STATUS "libproxy not found" )
ELSE ( NOT LIBPROXY_FOUND )
INCLUDE_DIRECTORIES( ${LIBPROXY_INCLUDE_DIR} )
ADD_DEFINITIONS(-DWITH_LIBPROXY_SUPPORT)
ENDIF( NOT LIBPROXY_FOUND )
ENDIF( DISABLE_LIBPROXY )
FIND_PROGRAM( DOXYGEN doxygen )
IF ( NOT DOXYGEN )
IF ( DISABLE_AUTODOCS )
MESSAGE( STATUS "doxygen is not available. Can't build the documentation." )
ELSE ( DISABLE_AUTODOCS )
MESSAGE( FATAL_ERROR "doxygen not found: install doxygen to build the documentation!" )
ENDIF ( DISABLE_AUTODOCS )
ELSE ( NOT DOXYGEN )
MESSAGE( STATUS "doxygen found: ${DOXYGEN}" )
ENDIF ( NOT DOXYGEN )
MESSAGE(STATUS "soname: ${LIBZYPP_VERSION_INFO}")
MESSAGE(STATUS "version: ${VERSION}")
MESSAGE(STATUS "Writing pkg-config file...")
CONFIGURE_FILE(${LIBZYPP_SOURCE_DIR}/libzypp.pc.cmake ${LIBZYPP_BINARY_DIR}/libzypp.pc @ONLY)
INSTALL( FILES ${LIBZYPP_BINARY_DIR}/libzypp.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig )
MESSAGE(STATUS "FindZypp.cmake will be installed in ${CMAKE_INSTALL_PREFIX}/share/cmake/Modules")
INSTALL( FILES ${LIBZYPP_SOURCE_DIR}/cmake/modules/FindZypp.cmake DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cmake/Modules )
INSTALL( FILES ${LIBZYPP_SOURCE_DIR}/cmake/modules/ZyppCommon.cmake DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cmake/Modules )
####################################################################
# config templates
# (don't forget to mention them in the .spec file)
####################################################################
MESSAGE(STATUS "zypp.conf will be installed in ${SYSCONFDIR}/zypp")
INSTALL( FILES ${LIBZYPP_SOURCE_DIR}/zypp.conf DESTINATION ${SYSCONFDIR}/zypp )
MESSAGE(STATUS "needreboot will be installed in ${SYSCONFDIR}/zypp/")
INSTALL( FILES ${LIBZYPP_SOURCE_DIR}/needreboot DESTINATION ${SYSCONFDIR}/zypp )
#install systemCheck
MESSAGE(STATUS "systemCheck will be installed in ${SYSCONFDIR}/zypp")
INSTALL( FILES ${LIBZYPP_SOURCE_DIR}/systemCheck DESTINATION ${SYSCONFDIR}/zypp )
# logrotate config file
INSTALL( FILES ${LIBZYPP_SOURCE_DIR}/zypp-history.lr DESTINATION ${SYSCONFDIR}/logrotate.d )
####################################################################
# SUBDIRECTORIES #
####################################################################
ADD_SUBDIRECTORY( zypp )
# do not build devel by default
ADD_SUBDIRECTORY( devel EXCLUDE_FROM_ALL )
ADD_SUBDIRECTORY( tools )
ADD_SUBDIRECTORY( doc )
ADD_SUBDIRECTORY( vendor )
IF ( ENABLE_BUILD_TRANS )
ADD_SUBDIRECTORY( po )
ELSE ( ENABLE_BUILD_TRANS )
ADD_SUBDIRECTORY( po EXCLUDE_FROM_ALL )
ENDIF ( ENABLE_BUILD_TRANS )
IF ( ENABLE_BUILD_TESTS )
ADD_SUBDIRECTORY( tests )
ELSE ( ENABLE_BUILD_TESTS )
ADD_SUBDIRECTORY( tests EXCLUDE_FROM_ALL )
ENDIF ( ENABLE_BUILD_TESTS )
INCLUDE(CTest)
ENABLE_TESTING()