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
|
CMAKE_MINIMUM_REQUIRED (VERSION 2.8.12)
PROJECT (createrepo_c C)
include(GNUInstallDirs)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -ggdb -g -Wall -Wextra -Og")
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
ENDIF(NOT CMAKE_BUILD_TYPE)
IF(CMAKE_BUILD_TYPE AND CMAKE_BUILD_TYPE STREQUAL "DEBUG")
MESSAGE("Build type is set do DEBUG! (Used flags: \"${CMAKE_C_FLAGS_DEBUG}\")")
ENDIF()
option(BUILD_LIBCREATEREPO_C_SHARED "Build libcreaterepo_c as a shared library" ON)
if(NOT BUILD_LIBCREATEREPO_C_SHARED)
set(CMAKE_POSITION_INDEPENDENT_CODE 1)
endif()
option(CREATEREPO_C_INSTALL_DEVELOPMENT "Install createrepo_c development files." ON)
option(CREATEREPO_C_INSTALL_MANPAGES "Install createrepo_c man-pages." ON)
# Add path with own cmake modules
INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
SET(G_LOG_DOMAIN "C_CREATEREPOLIB")
# Find necessary libraries
find_package(PkgConfig)
find_package(BZip2 REQUIRED)
find_package(CURL REQUIRED)
find_package(LibXml2 REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(ZLIB REQUIRED)
pkg_check_modules(GLIB2 REQUIRED glib-2.0)
pkg_check_modules(GIO REQUIRED gio-2.0)
pkg_check_modules(GTHREAD2 REQUIRED gthread-2.0)
pkg_check_modules(LZMA REQUIRED liblzma)
pkg_check_modules(SQLITE3 REQUIRED sqlite3>=3.6.18)
pkg_check_modules(RPM REQUIRED rpm)
pkg_check_modules(ZSTD REQUIRED libzstd)
# Add include dirs
include_directories(${BZIP2_INCLUDE_DIRS})
include_directories(${CURL_INCLUDE_DIRS})
include_directories(${GLIB2_INCLUDE_DIRS})
include_directories(${GIO_INCLUDE_DIRS})
include_directories(${LIBXML2_INCLUDE_DIR})
include_directories(${OPENSSL_INCLUDE_DIR})
include_directories(${ZLIB_INCLUDE_DIR})
include_directories(${ZSTD_INCLUDE_DIRS})
# SuSE/Mageia/Mandriva legacy weak deps support
OPTION (ENABLE_LEGACY_WEAKDEPS "Enable legacy SUSE/Mageia/Mandriva weakdeps support?" ON)
IF (ENABLE_LEGACY_WEAKDEPS)
ADD_DEFINITIONS("-DENABLE_LEGACY_WEAKDEPS=1")
ENDIF (ENABLE_LEGACY_WEAKDEPS)
# Legacy hash functions
OPTION (WITH_LEGACY_HASHES "Build with SHA-1 and MD5 support" OFF)
IF (WITH_LEGACY_HASHES)
ADD_DEFINITIONS("-DWITH_LEGACY_HASHES=1")
ENDIF (WITH_LEGACY_HASHES)
# drpm
OPTION (ENABLE_DRPM "Enable delta RPM support?" OFF)
IF (ENABLE_DRPM)
pkg_check_modules(DRPM REQUIRED drpm>=0.4.0)
include_directories (${DRPM_INCLUDE_DIRS})
ADD_DEFINITIONS("-DCR_DELTA_RPM_SUPPORT")
ENDIF (ENABLE_DRPM)
# option to enable/disable python support
OPTION (ENABLE_PYTHON "Enable python support?" ON)
OPTION (WITH_ZCHUNK "Build with zchunk support" ON)
IF (WITH_ZCHUNK)
pkg_check_modules(ZCK REQUIRED zck)
include_directories(${ZCK_INCLUDE_DIRS})
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWITH_ZCHUNK")
SET (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DWITH_ZCHUNK")
ENDIF (WITH_ZCHUNK)
OPTION (WITH_LIBMODULEMD "Build with libmodulemd support" ON)
IF (WITH_LIBMODULEMD)
pkg_check_modules(LIBMODULEMD REQUIRED modulemd-2.0)
include_directories(${LIBMODULEMD_INCLUDE_DIRS})
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWITH_LIBMODULEMD")
SET (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DWITH_LIBMODULEMD")
ENDIF (WITH_LIBMODULEMD)
if (WITH_SANITIZERS)
message(WARNING "Building with sanitizers enabled!")
add_compile_options(-fsanitize=address -fsanitize=undefined -fsanitize=leak)
link_libraries(asan ubsan)
endif()
# Threaded XZ Compression
# Note: This option is disabled by default, because Createrepo_c
# parallelize a lot of tasks (including compression) by default, this
# only adds extra threads on XZ library level which causes thread bloat
# and for most usecases doesn't bring any performance boost.
# On regular hardware (e.g. less-or-equal 4 cores) this option may even
# cause degradation of performance.
OPTION(ENABLE_THREADED_XZ_ENCODER "Enable threaded XZ encoder?" OFF)
IF (ENABLE_THREADED_XZ_ENCODER)
ADD_DEFINITIONS("-DENABLE_THREADED_XZ_ENCODER=1")
ENDIF (ENABLE_THREADED_XZ_ENCODER)
# Get package version
INCLUDE (${CMAKE_SOURCE_DIR}/VERSION.cmake)
SET (VERSION "${CR_MAJOR}.${CR_MINOR}.${CR_PATCH}")
message("Package version: ${VERSION}")
# Other files
OPTION(ENABLE_BASHCOMP "Install Bash autocompletions?" ON)
IF (ENABLE_BASHCOMP)
pkg_check_modules(BASHCOMP bash-completion)
IF (BASHCOMP_FOUND)
execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=completionsdir bash-completion OUTPUT_VARIABLE BASHCOMP_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
message("Bash completion directory: ${BASHCOMP_DIR}")
INSTALL(FILES createrepo_c.bash DESTINATION ${BASHCOMP_DIR} RENAME createrepo_c)
INSTALL(CODE "
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink createrepo_c \$ENV{DESTDIR}${BASHCOMP_DIR}/mergerepo_c)
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink createrepo_c \$ENV{DESTDIR}${BASHCOMP_DIR}/modifyrepo_c)
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink createrepo_c \$ENV{DESTDIR}${BASHCOMP_DIR}/sqliterepo_c)
")
ELSEIF (BASHCOMP_FOUND)
INSTALL(FILES createrepo_c.bash DESTINATION "/etc/bash_completion.d")
message("Bash completion directory: /etc/bash_completion.d")
ENDIF (BASHCOMP_FOUND)
ENDIF (ENABLE_BASHCOMP)
# Gen manpage
#message("Gen manpage")
#execute_process(COMMAND bash gen_manpage.sh src/cmd_parser.c ../doc/ WORKING_DIRECTORY utils/)
# Add custom target for tests
ADD_CUSTOM_TARGET(tests)
# Subdirs
ADD_SUBDIRECTORY (src)
ADD_SUBDIRECTORY (doc)
ENABLE_TESTING()
ADD_SUBDIRECTORY (tests EXCLUDE_FROM_ALL)
|