1 # Include apt-pkg directly, as some files have #include <system.h>
2 include_directories(${PROJECT_BINARY_DIR}/include/apt-pkg)
4 add_definitions("-DAPT_PKG_EXPOSE_STRING_VIEW")
6 # Set the version of the library
7 execute_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)
11 execute_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)
16 message(STATUS "Building libapt-pkg ${MAJOR} (release ${MINOR})")
17 set(APT_PKG_MAJOR ${MAJOR} PARENT_SCOPE) # exporting for methods/CMakeLists.txt
19 # Definition of the C++ files used to build the library
20 file(GLOB_RECURSE library "*.cc")
21 file(GLOB_RECURSE headers "*.h")
23 # Create a library using the C++ files
24 add_library(apt-pkg SHARED ${library})
25 add_dependencies(apt-pkg apt-pkg-versionscript)
26 # Link the library and set the SONAME
27 target_include_directories(apt-pkg
28 PRIVATE ${ZLIB_INCLUDE_DIRS}
35 target_link_libraries(apt-pkg
36 PRIVATE -lutil ${CMAKE_DL_LIBS} ${RESOLV_LIBRARIES}
37 ${CMAKE_THREAD_LIBS_INIT}
44 set_target_properties(apt-pkg PROPERTIES VERSION ${MAJOR}.${MINOR})
45 set_target_properties(apt-pkg PROPERTIES SOVERSION ${MAJOR})
46 add_version_script(apt-pkg)
48 # Install the library and the header files
49 install(TARGETS apt-pkg LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
50 install(FILES ${headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/apt-pkg)
51 flatify(${PROJECT_BINARY_DIR}/include/apt-pkg/ "${headers}")