summaryrefslogtreecommitdiff
path: root/apt-pkg/CMakeLists.txt
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2016-08-06 21:03:43 +0200
committerJulian Andres Klode <jak@debian.org>2016-08-06 22:36:02 +0200
commitf3de2dbaf657f9040a4da448c57267de0fef7d33 (patch)
treed3b44456dd66f619f29671d56589f0257e986d7a /apt-pkg/CMakeLists.txt
parentcc1b834fe966d40206d148e1f27f0502463ac69f (diff)
CMake: Add basic CMake build system
Introduce an initial CMake buildsystem. This build system can build a fully working apt system without translation or documentation. The FindBerkelyDB module is from kdelibs, with some small adjustements to also look in db5 directories. Initial work on this CMake build system started in 2009, and was resumed in August 2016.
Diffstat (limited to 'apt-pkg/CMakeLists.txt')
-rw-r--r--apt-pkg/CMakeLists.txt46
1 files changed, 46 insertions, 0 deletions
diff --git a/apt-pkg/CMakeLists.txt b/apt-pkg/CMakeLists.txt
new file mode 100644
index 000000000..ec78f49c4
--- /dev/null
+++ b/apt-pkg/CMakeLists.txt
@@ -0,0 +1,46 @@
+# Include apt-pkg directly, as some files have #include <system.h>
+include_directories(${PROJECT_BINARY_DIR}/include/apt-pkg)
+
+add_definitions("-DAPT_PKG_EXPOSE_STRING_VIEW")
+
+# Set the version of the library
+execute_process(COMMAND awk -v ORS=. "/^\#define APT_PKG_M/ {print \$3}"
+ COMMAND sed "s/\\.\$//"
+ INPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/contrib/macros.h
+ OUTPUT_VARIABLE MAJOR OUTPUT_STRIP_TRAILING_WHITESPACE)
+execute_process(COMMAND grep "^#define APT_PKG_RELEASE"
+ COMMAND cut -d " " -f 3
+ INPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/contrib/macros.h
+ OUTPUT_VARIABLE MINOR OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+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 headers "*.h")
+
+# Create a library using the C++ files
+add_library(apt-pkg SHARED ${library})
+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}
+ ${LZMA_INCLUDE_DIRS}
+ ${LZ4_INCLUDE_DIRS})
+target_link_libraries(apt-pkg
+ PRIVATE -lutil -ldl -lresolv
+ ${CMAKE_THREAD_LIBS_INIT}
+ ${ZLIB_LIBRARIES}
+ ${BZIP2_LIBRARIES}
+ ${LZMA_LIBRARIES}
+ ${LZ4_LIBRARIES})
+set_target_properties(apt-pkg PROPERTIES VERSION ${MAJOR}.${MINOR})
+set_target_properties(apt-pkg PROPERTIES SOVERSION ${MAJOR})
+add_version_script(apt-pkg)
+
+# Install the library and the header files
+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}")