]> git.saurik.com Git - apt.git/blame - apt-pkg/CMakeLists.txt
Optimize VersionHash() to not need temporary copy of input
[apt.git] / apt-pkg / CMakeLists.txt
CommitLineData
f3de2dba
JAK
1# Include apt-pkg directly, as some files have #include <system.h>
2include_directories(${PROJECT_BINARY_DIR}/include/apt-pkg)
3
4add_definitions("-DAPT_PKG_EXPOSE_STRING_VIEW")
5
abfd0770
JAK
6file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/include/apt-pkg/)
7execute_process(COMMAND ${PROJECT_SOURCE_DIR}/triehash/triehash.pl
8 --ignore-case
9 --header ${PROJECT_BINARY_DIR}/include/apt-pkg/tagfile-keys.h
10 --code ${CMAKE_CURRENT_BINARY_DIR}/tagfile-keys.cc
11 --enum-class
12 --enum-name pkgTagSection::Key
13 --function-name pkgTagHash
14 --include "<apt-pkg/tagfile.h>"
15 ${CMAKE_CURRENT_SOURCE_DIR}/tagfile-keys.list)
16set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "tagfile-keys.list")
17
18
f3de2dba
JAK
19# Set the version of the library
20execute_process(COMMAND awk -v ORS=. "/^\#define APT_PKG_M/ {print \$3}"
21 COMMAND sed "s/\\.\$//"
22 INPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/contrib/macros.h
23 OUTPUT_VARIABLE MAJOR OUTPUT_STRIP_TRAILING_WHITESPACE)
24execute_process(COMMAND grep "^#define APT_PKG_RELEASE"
25 COMMAND cut -d " " -f 3
26 INPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/contrib/macros.h
27 OUTPUT_VARIABLE MINOR OUTPUT_STRIP_TRAILING_WHITESPACE)
28
29message(STATUS "Building libapt-pkg ${MAJOR} (release ${MINOR})")
30set(APT_PKG_MAJOR ${MAJOR} PARENT_SCOPE) # exporting for methods/CMakeLists.txt
31
32# Definition of the C++ files used to build the library
abfd0770 33file(GLOB_RECURSE library "*.cc" "${CMAKE_CURRENT_BINARY_DIR}/tagfile-keys.cc")
f3de2dba
JAK
34file(GLOB_RECURSE headers "*.h")
35
36# Create a library using the C++ files
37add_library(apt-pkg SHARED ${library})
38add_dependencies(apt-pkg apt-pkg-versionscript)
39# Link the library and set the SONAME
40target_include_directories(apt-pkg
41 PRIVATE ${ZLIB_INCLUDE_DIRS}
ee60e00c 42 ${BZIP2_INCLUDE_DIR}
f3de2dba 43 ${LZMA_INCLUDE_DIRS}
01d207a5 44 ${LZ4_INCLUDE_DIRS}
544e1528 45 ${ICONV_INCLUDE_DIRS}
01d207a5
JAK
46)
47
f3de2dba 48target_link_libraries(apt-pkg
ad5282bb 49 PRIVATE -lutil ${CMAKE_DL_LIBS} ${RESOLV_LIBRARIES}
f3de2dba
JAK
50 ${CMAKE_THREAD_LIBS_INIT}
51 ${ZLIB_LIBRARIES}
52 ${BZIP2_LIBRARIES}
53 ${LZMA_LIBRARIES}
01d207a5
JAK
54 ${LZ4_LIBRARIES}
55 ${ICONV_LIBRARIES}
56)
f3de2dba
JAK
57set_target_properties(apt-pkg PROPERTIES VERSION ${MAJOR}.${MINOR})
58set_target_properties(apt-pkg PROPERTIES SOVERSION ${MAJOR})
59add_version_script(apt-pkg)
60
61# Install the library and the header files
62install(TARGETS apt-pkg LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
63install(FILES ${headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/apt-pkg)
64flatify(${PROJECT_BINARY_DIR}/include/apt-pkg/ "${headers}")
bccb3444
JAK
65
66if(CMAKE_BUILD_TYPE STREQUAL "Coverage")
67 target_link_libraries(apt-pkg PUBLIC noprofile)
68endif()