]> git.saurik.com Git - apt.git/blame - apt-pkg/CMakeLists.txt
try not to call memcpy with length 0 in hash calculations
[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
6# Set the version of the library
7execute_process(COMMAND awk -v ORS=. "/^\#define APT_PKG_M/ {print \$3}"
8 COMMAND sed "s/\\.\$//"
9 INPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/contrib/macros.h
10 OUTPUT_VARIABLE MAJOR OUTPUT_STRIP_TRAILING_WHITESPACE)
11execute_process(COMMAND grep "^#define APT_PKG_RELEASE"
12 COMMAND cut -d " " -f 3
13 INPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/contrib/macros.h
14 OUTPUT_VARIABLE MINOR OUTPUT_STRIP_TRAILING_WHITESPACE)
15
16message(STATUS "Building libapt-pkg ${MAJOR} (release ${MINOR})")
17set(APT_PKG_MAJOR ${MAJOR} PARENT_SCOPE) # exporting for methods/CMakeLists.txt
18
19# Definition of the C++ files used to build the library
20file(GLOB_RECURSE library "*.cc")
21file(GLOB_RECURSE headers "*.h")
22
23# Create a library using the C++ files
24add_library(apt-pkg SHARED ${library})
25add_dependencies(apt-pkg apt-pkg-versionscript)
26# Link the library and set the SONAME
27target_include_directories(apt-pkg
28 PRIVATE ${ZLIB_INCLUDE_DIRS}
ee60e00c 29 ${BZIP2_INCLUDE_DIR}
f3de2dba 30 ${LZMA_INCLUDE_DIRS}
01d207a5
JAK
31 ${LZ4_INCLUDE_DIRS}
32 ${ICONV_DIRECTORIES}
33)
34
f3de2dba 35target_link_libraries(apt-pkg
ad5282bb 36 PRIVATE -lutil ${CMAKE_DL_LIBS} ${RESOLV_LIBRARIES}
f3de2dba
JAK
37 ${CMAKE_THREAD_LIBS_INIT}
38 ${ZLIB_LIBRARIES}
39 ${BZIP2_LIBRARIES}
40 ${LZMA_LIBRARIES}
01d207a5
JAK
41 ${LZ4_LIBRARIES}
42 ${ICONV_LIBRARIES}
43)
f3de2dba
JAK
44set_target_properties(apt-pkg PROPERTIES VERSION ${MAJOR}.${MINOR})
45set_target_properties(apt-pkg PROPERTIES SOVERSION ${MAJOR})
46add_version_script(apt-pkg)
47
48# Install the library and the header files
49install(TARGETS apt-pkg LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
50install(FILES ${headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/apt-pkg)
51flatify(${PROJECT_BINARY_DIR}/include/apt-pkg/ "${headers}")