-
Notifications
You must be signed in to change notification settings - Fork 49
/
CMakeLists.txt
106 lines (84 loc) · 3.49 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
#
# Copyright (C) 2019-2023 VMware, Inc. All Rights Reserved.
#
# Licensed under the GNU General Public License v2 (the "License");
# you may not use this file except in compliance with the License. The terms
# of the License are located in the COPYING file of this distribution.
#
CMAKE_MINIMUM_REQUIRED(VERSION 3.0 FATAL_ERROR)
file(STRINGS VERSION PROJECT_VERSION)
project(tdnf VERSION ${PROJECT_VERSION} LANGUAGES C)
set(VERSION ${PROJECT_VERSION})
set(PROJECT_YEAR 2023)
# Ensure correct directory paths are used for installation
include(GNUInstallDirs)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(AddCCompilerFlag)
include(CreatePackages)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# Ensure that we don't accidentally install into /usr/etc
set(CMAKE_INSTALL_FULL_SYSCONDIR "/etc")
set(SYSCONFDIR /etc)
set(MOTGEN_DIR /etc/motdgen.d)
if(NOT SYSTEMD_DIR)
set(SYSTEMD_DIR /lib/systemd/system)
endif()
if(NOT HISTORY_DB_DIR)
set(HISTORY_DB_DIR /var/lib/tdnf)
endif()
##
## C Flags
##
add_c_compiler_flag(-Wall)
add_c_compiler_flag(-Wextra)
add_c_compiler_flag(-std=gnu99)
add_c_compiler_flag(-fPIC)
add_c_compiler_flag(-O3 RELEASE)
add_c_compiler_flag(-s RELEASE)
add_c_compiler_flag(-g DEBUG)
add_c_compiler_flag(-D_XOPEN_SOURCE=500)
add_c_compiler_flag(-D_DEFAULT_SOURCE)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
### External dependency: rpm-devel
find_package(PkgConfig REQUIRED)
pkg_check_modules(RPM REQUIRED rpm)
find_package(OpenSSL REQUIRED)
pkg_check_modules(EXPAT REQUIRED expat)
pkg_check_modules(SQLITE3 sqlite3)
include_directories(${RPM_INCLUDE_DIRS})
include_directories(${EXPAT_INCLUDE_DIRS})
### External dependency: libsolv
find_package(LibSolv REQUIRED ext)
### External dependency: libcurl
find_package(CURL REQUIRED)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/tdnf")
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/pytests/tests/" DESTINATION "${CMAKE_INSTALL_DATADIR}/tdnf/pytests/tests")
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/pytests/repo/" DESTINATION "${CMAKE_INSTALL_DATADIR}/tdnf/pytests/repo")
set(LIB_TDNF "tdnf")
set(LIB_TDNF_SOLV "tdnfsolv")
set(LIB_TDNF_COMMON "common")
set(LIB_TDNF_JSONDUMP "jsondump")
set(LIB_TDNF_HISTORY "history")
set(LIB_TDNF_CLI tdnfcli)
set(LIB_TDNF_LLCONF "llconf")
add_subdirectory("${PROJECT_SOURCE_DIR}/common")
add_subdirectory("${PROJECT_SOURCE_DIR}/client")
add_subdirectory("${PROJECT_SOURCE_DIR}/jsondump")
add_subdirectory("${PROJECT_SOURCE_DIR}/history")
add_subdirectory("${PROJECT_SOURCE_DIR}/llconf")
add_subdirectory("${PROJECT_SOURCE_DIR}/plugins")
add_subdirectory("${PROJECT_SOURCE_DIR}/python")
add_subdirectory("${PROJECT_SOURCE_DIR}/etc")
add_subdirectory("${PROJECT_SOURCE_DIR}/bin")
add_subdirectory("${PROJECT_SOURCE_DIR}/solv")
add_subdirectory("${PROJECT_SOURCE_DIR}/tools")
add_subdirectory("${PROJECT_SOURCE_DIR}/pytests")
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/bin/tdnf-automatic.in ${PROJECT_SOURCE_DIR}/bin/tdnf-automatic @ONLY)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/bin/tdnf-cache-updateinfo.in ${PROJECT_SOURCE_DIR}/bin/tdnf-cache-updateinfo @ONLY)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/tdnf.spec.in ${CMAKE_SOURCE_DIR}/tdnf.spec @ONLY)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/scripts/build-tdnf-rpms.in ${CMAKE_SOURCE_DIR}/scripts/build-tdnf-rpms @ONLY)