]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/CMakeLists.txt
Introduce tolower_ascii_unsafe() and use it for hashing
[apt.git] / apt-pkg / CMakeLists.txt
index ec78f49c404f05d232cb11eef33a57760c31d4e2..25ed13ec34b8dabed7ec1d4f695417f2baadb022 100644 (file)
@@ -3,6 +3,19 @@ include_directories(${PROJECT_BINARY_DIR}/include/apt-pkg)
 
 add_definitions("-DAPT_PKG_EXPOSE_STRING_VIEW")
 
+file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/include/apt-pkg/)
+execute_process(COMMAND ${PROJECT_SOURCE_DIR}/triehash/triehash.pl
+                        --ignore-case
+                         --header ${PROJECT_BINARY_DIR}/include/apt-pkg/tagfile-keys.h
+                         --code ${CMAKE_CURRENT_BINARY_DIR}/tagfile-keys.cc
+                         --enum-class
+                         --enum-name pkgTagSection::Key
+                         --function-name pkgTagHash
+                         --include "<apt-pkg/tagfile.h>"
+                         ${CMAKE_CURRENT_SOURCE_DIR}/tagfile-keys.list)
+set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "tagfile-keys.list")
+
+
 # Set the version of the library
 execute_process(COMMAND awk -v ORS=. "/^\#define APT_PKG_M/ {print \$3}"
                 COMMAND sed "s/\\.\$//"
@@ -17,7 +30,7 @@ message(STATUS "Building libapt-pkg ${MAJOR} (release ${MINOR})")
 set(APT_PKG_MAJOR ${MAJOR} PARENT_SCOPE) # exporting for methods/CMakeLists.txt
 
 # Definition of the C++ files used to build the library
-file(GLOB_RECURSE library "*.cc")
+file(GLOB_RECURSE library "*.cc"  "${CMAKE_CURRENT_BINARY_DIR}/tagfile-keys.cc")
 file(GLOB_RECURSE headers "*.h")
 
 # Create a library using the C++ files
@@ -26,16 +39,21 @@ add_dependencies(apt-pkg apt-pkg-versionscript)
 # Link the library and set the SONAME
 target_include_directories(apt-pkg
                            PRIVATE ${ZLIB_INCLUDE_DIRS}
-                                   ${BZIP2_INCLUDE_DIRS}
+                                   ${BZIP2_INCLUDE_DIR}
                                    ${LZMA_INCLUDE_DIRS}
-                                   ${LZ4_INCLUDE_DIRS})
+                                   ${LZ4_INCLUDE_DIRS}
+                                   ${ICONV_INCLUDE_DIRS}
+)
+
 target_link_libraries(apt-pkg
-                      PRIVATE -lutil -ldl -lresolv
+                      PRIVATE -lutil ${CMAKE_DL_LIBS} ${RESOLV_LIBRARIES}
                              ${CMAKE_THREAD_LIBS_INIT}
                              ${ZLIB_LIBRARIES}
                              ${BZIP2_LIBRARIES}
                              ${LZMA_LIBRARIES}
-                             ${LZ4_LIBRARIES})
+                             ${LZ4_LIBRARIES}
+                             ${ICONV_LIBRARIES}
+)
 set_target_properties(apt-pkg PROPERTIES VERSION ${MAJOR}.${MINOR})
 set_target_properties(apt-pkg PROPERTIES SOVERSION ${MAJOR})
 add_version_script(apt-pkg)
@@ -44,3 +62,7 @@ add_version_script(apt-pkg)
 install(TARGETS apt-pkg LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
 install(FILES ${headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/apt-pkg)
 flatify(${PROJECT_BINARY_DIR}/include/apt-pkg/ "${headers}")
+
+if(CMAKE_BUILD_TYPE STREQUAL "Coverage")
+  target_link_libraries(apt-pkg PUBLIC noprofile)
+endif()