-
Notifications
You must be signed in to change notification settings - Fork 114
/
CMakeLists.txt
147 lines (123 loc) · 4.19 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
CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
PROJECT( ZYPPER C CXX )
SET( PACKAGE "zypper" )
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
IF (DEFINED ZYPP_PREFIX)
SET( CMAKE_MODULE_PATH
${ZYPP_PREFIX}/${LIB}/cmake/Zypp/
${CMAKE_MODULE_PATH}
)
ELSE (DEFINED ZYPP_PREFIX)
SET( CMAKE_MODULE_PATH
${CMAKE_INSTALL_PREFIX}/${LIB}/cmake/Zypp/
${CMAKE_MODULE_PATH}
)
ENDIF (DEFINED ZYPP_PREFIX)
SET( CMAKE_MODULE_PATH
${ZYPPER_SOURCE_DIR}/cmake/modules
${CMAKE_MODULE_PATH}
)
INCLUDE(ZyppCommon)
OPTION (ENABLE_BUILD_TRANS "Build translation files by default?" ON)
OPTION (ENABLE_BUILD_TESTS "Build and run test suite by default?" OFF)
# VERSION
INCLUDE( ${ZYPPER_SOURCE_DIR}/VERSION.cmake )
SET( VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" )
ADD_DEFINITIONS( -D_FILE_OFFSET_BITS=64 )
ADD_DEFINITIONS( -DVERSION="${VERSION}" )
SET( CMAKE_CXX_STANDARD ${ZYPPCOMMON_CXX_STANDARD} )
SET( CMAKE_CXX_EXTENSIONS OFF )
SET( CMAKE_CXX_FLAGS_RELEASE "-O3" )
SET( CMAKE_CXX_FLAGS_RELWITHDEBUGINFO "-g -O2" )
SET( CMAKE_C_FLAGS_RELEASE "-O3" )
SET( CMAKE_C_FLAGS_RELWITHDEBUGINFO "-g -O2" )
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpie -Wall -Woverloaded-virtual -Wnon-virtual-dtor -fvisibility=hidden" )
SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fpie -Wall" )
SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fpie -fvisibility=hidden" )
IF ( LEGACY_ENABLE_LONGOPT_ABBREV )
# Fixed in 1.14.34: Do not allow the abbreviation of cli arguments (bsc#1164543)
# On SLE15/Leap 15.0 and 15.1 we will stay bug-compatible and accept the
# abbreviations in order not to break tools. In 15.2 they must be fixed.
MESSAGE( STATUS "LEGACY_ENABLE_LONGOPT_ABBREV" )
ADD_DEFINITIONS( -DLEGACY_ENABLE_LONGOPT_ABBREV=1 )
ENDIF ( LEGACY_ENABLE_LONGOPT_ABBREV )
GENERATE_PACKAGING(${PACKAGE} ${VERSION})
FIND_PACKAGE( Zypp REQUIRED )
IF( ZYPP_FOUND )
INCLUDE_DIRECTORIES(${ZYPP_INCLUDE_DIR})
ELSE( ZYPP_FOUND )
MESSAGE( FATAL_ERROR "libzypp not found" )
ENDIF( ZYPP_FOUND )
FIND_PACKAGE( Gettext REQUIRED )
IF( GETTEXT_FOUND )
INCLUDE_DIRECTORIES(${GETTEXT_INCLUDE_DIR})
ELSE( GETTEXT_FOUND )
MESSAGE( FATAL_ERROR "gettext not found" )
ENDIF( GETTEXT_FOUND )
FIND_PACKAGE( Readline REQUIRED )
IF( READLINE_FOUND )
INCLUDE_DIRECTORIES(${READLINE_INCLUDE_DIR})
ELSE( READLINE_FOUND )
MESSAGE( FATAL_ERROR "readline not found" )
ENDIF( READLINE_FOUND )
FIND_PACKAGE( Augeas REQUIRED )
IF( AUGEAS_FOUND )
INCLUDE_DIRECTORIES(${AUGEAS_INCLUDE_DIR})
FIND_PACKAGE(LibXml2)
IF (LIBXML2_FOUND)
INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR})
ENDIF( LIBXML2_FOUND)
ELSE( AUGEAS_FOUND )
MESSAGE( FATAL_ERROR "augeas not found" )
ENDIF( AUGEAS_FOUND )
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_LIBRARY} boost_unit_test_framework zypper_lib zypper_test_utils)
ADD_TEST( ${loop_var}_test ${CMAKE_CURRENT_BINARY_DIR}/${loop_var}_test --catch_system_errors=no)
ENDFOREACH( loop_var )
ENDMACRO(ADD_TESTS)
ADD_SUBDIRECTORY( src )
ADD_SUBDIRECTORY( doc )
IF ( ENABLE_BUILD_TESTS )
ADD_SUBDIRECTORY( tests )
ELSE ( ENABLE_BUILD_TESTS )
ADD_SUBDIRECTORY( tests EXCLUDE_FROM_ALL )
ENDIF ( ENABLE_BUILD_TESTS )
IF ( ENABLE_BUILD_TRANS )
ADD_SUBDIRECTORY( po )
ELSE ( ENABLE_BUILD_TRANS )
ADD_SUBDIRECTORY( po EXCLUDE_FROM_ALL )
ENDIF ( ENABLE_BUILD_TRANS )
INCLUDE(CTest)
ENABLE_TESTING()
# documentation too important to be hidden in doc:
INSTALL(
FILES HACKING
DESTINATION ${INSTALL_PREFIX}/share/doc/packages/${PACKAGE}
)
# system-wide zypper.conf
INSTALL(
FILES zypper.conf
DESTINATION ${SYSCONFDIR}/zypp
)
# zypper-log tool
INSTALL(
PROGRAMS tools/zypper-log
DESTINATION ${INSTALL_PREFIX}/sbin
)
# needs-restarting tool
INSTALL(
PROGRAMS tools/needs-restarting
DESTINATION ${INSTALL_PREFIX}/bin
)
# zypper-aptitude compat tool
INSTALL(
PROGRAMS tools/aptitude tools/apt-get tools/apt
DESTINATION ${INSTALL_PREFIX}/bin
)
INSTALL(
DIRECTORY tools/apt-packagemap.d/
DESTINATION ${SYSCONFDIR}/zypp/apt-packagemap.d
)