summaryrefslogtreecommitdiff
path: root/CMake
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 /CMake
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 'CMake')
-rw-r--r--CMake/FindBerkeleyDB.cmake48
-rw-r--r--CMake/Misc.cmake65
-rw-r--r--CMake/apti18n.h.in30
-rw-r--r--CMake/config.h.in54
4 files changed, 197 insertions, 0 deletions
diff --git a/CMake/FindBerkeleyDB.cmake b/CMake/FindBerkeleyDB.cmake
new file mode 100644
index 000000000..44cfd3ddb
--- /dev/null
+++ b/CMake/FindBerkeleyDB.cmake
@@ -0,0 +1,48 @@
+# - Try to find Berkeley DB
+# Once done this will define
+#
+# BERKELEY_DB_FOUND - system has Berkeley DB
+# BERKELEY_DB_INCLUDE_DIRS - the Berkeley DB include directory
+# BERKELEY_DB_LIBRARIES - Link these to use Berkeley DB
+# BERKELEY_DB_DEFINITIONS - Compiler switches required for using Berkeley DB
+
+# Copyright (c) 2006, Alexander Dymo, <adymo@kdevelop.org>
+# Copyright (c) 2016, Julian Andres Klode <jak@debian.org>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. The name of the author may not be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+find_path(BERKELEY_DB_INCLUDE_DIRS db.h
+ /usr/include/db5
+ /usr/local/include/db5
+ /usr/include/db4
+ /usr/local/include/db4
+)
+
+find_library(BERKELEY_DB_LIBRARIES NAMES db )
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(Berkeley "Could not find Berkeley DB >= 4.1" BERKELEY_DB_INCLUDE_DIRS BERKELEY_DB_LIBRARIES)
+# show the BERKELEY_DB_INCLUDE_DIRS and BERKELEY_DB_LIBRARIES variables only in the advanced view
+mark_as_advanced(BERKELEY_DB_INCLUDE_DIRS BERKELEY_DB_LIBRARIES)
diff --git a/CMake/Misc.cmake b/CMake/Misc.cmake
new file mode 100644
index 000000000..584a4da2a
--- /dev/null
+++ b/CMake/Misc.cmake
@@ -0,0 +1,65 @@
+include(CheckCXXCompilerFlag)
+
+# Flatten our header structure
+function(flatify target headers)
+ foreach(header ${headers})
+ get_filename_component(tgt ${header} NAME)
+ configure_file(${header} ${target}/${tgt} @ONLY)
+ endforeach(header ${headers})
+endfunction()
+
+
+function(add_optional_compile_options flags)
+ foreach(flag ${flags})
+ check_cxx_compiler_flag(-${flag} have-compiler-flag:-${flag})
+ if (have-compiler-flag:-${flag})
+ add_compile_options("-${flag}")
+ endif()
+ endforeach()
+endfunction()
+
+# Substitute vendor references in a file
+function(add_vendor_file)
+ set(options)
+ set(oneValueArgs OUTPUT INPUT MODE)
+ set(multiValueArgs VARIABLES)
+ cmake_parse_arguments(AVF "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+ message(STATUS "Configuring vendor file ${AVF_OUTPUT}")
+
+ FILE(READ ${CMAKE_CURRENT_SOURCE_DIR}/${AVF_INPUT} input)
+ foreach(variable ${AVF_VARIABLES})
+ execute_process(COMMAND ../vendor/getinfo ${variable} OUTPUT_VARIABLE value OUTPUT_STRIP_TRAILING_WHITESPACE)
+ string(REPLACE "&${variable};" "${value}" input "${input}")
+ endforeach()
+ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${AVF_OUTPUT} "${input}")
+
+ execute_process(COMMAND chmod ${AVF_MODE} ${CMAKE_CURRENT_BINARY_DIR}/${AVF_OUTPUT})
+endfunction()
+
+# Add symbolic links to a file
+function(add_slaves destination master)
+ set(slaves "")
+ foreach(slave ${ARGN})
+ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${slave}
+ COMMAND ${CMAKE_COMMAND} -E create_symlink ${master} ${CMAKE_CURRENT_BINARY_DIR}/${slave})
+ list(APPEND slaves ${CMAKE_CURRENT_BINARY_DIR}/${slave})
+ endforeach()
+
+ STRING(REPLACE "/" "-" master "${master}")
+ add_custom_target(${master}-slaves ALL DEPENDS ${slaves})
+ install(FILES ${slaves} DESTINATION ${destination})
+endfunction()
+
+# Generates a simple version script versioning everything with current SOVERSION
+function(add_version_script target)
+ get_target_property(soversion ${target} SOVERSION)
+ set(script "${CMAKE_CURRENT_BINARY_DIR}/${target}.versionscript")
+ string(REPLACE "-" "" name "${target}_${soversion}")
+ string(TOUPPER "${name}" name)
+ add_custom_command(OUTPUT "${script}"
+ COMMAND echo "${name} {global: *; };" > "${script}"
+ VERBATIM )
+ add_custom_target(${target}-versionscript DEPENDS "${script}")
+ target_link_libraries(${target} PRIVATE -Wl,-version-script="${script}")
+ add_dependencies(${target} ${target}-versionscript)
+endfunction()
diff --git a/CMake/apti18n.h.in b/CMake/apti18n.h.in
new file mode 100644
index 000000000..9c843b037
--- /dev/null
+++ b/CMake/apti18n.h.in
@@ -0,0 +1,30 @@
+// -*- mode: cpp; mode: fold -*-
+// $Id: apti18n.h.in,v 1.6 2003/01/11 07:18:18 jgg Exp $
+/* Internationalization macros for apt. This header should be included last
+ in each C file. */
+
+// Set by autoconf
+#cmakedefine USE_NLS
+
+#ifdef USE_NLS
+// apt will use the gettext implementation of the C library
+#include <libintl.h>
+#include <locale.h>
+# ifdef APT_DOMAIN
+# define _(x) dgettext(APT_DOMAIN,x)
+# define P_(msg,plural,n) dngettext(APT_DOMAIN,msg,plural,n)
+# else
+# define _(x) gettext(x)
+# define P_(msg,plural,n) ngettext(msg,plural,n)
+# endif
+# define N_(x) x
+#else
+// apt will not use any gettext
+# define setlocale(a, b)
+# define textdomain(a)
+# define bindtextdomain(a, b)
+# define _(x) x
+# define P_(msg,plural,n) (n == 1 ? msg : plural)
+# define N_(x) x
+# define dgettext(d, m) m
+#endif
diff --git a/CMake/config.h.in b/CMake/config.h.in
new file mode 100644
index 000000000..7515fc9a6
--- /dev/null
+++ b/CMake/config.h.in
@@ -0,0 +1,54 @@
+/* Define if your processor stores words with the most significant
+ byte first (like Motorola and SPARC, unlike Intel and VAX). */
+#cmakedefine WORDS_BIGENDIAN
+
+/* Define if we have the timegm() function */
+#cmakedefine HAVE_TIMEGM
+
+/* Define if we have the zlib library for gzip */
+#cmakedefine HAVE_ZLIB
+
+/* Define if we have the bz2 library for bzip2 */
+#cmakedefine HAVE_BZ2
+
+/* Define if we have the lzma library for lzma/xz */
+#cmakedefine HAVE_LZMA
+
+/* Define if we have the lz4 library for lz4 */
+#cmakedefine HAVE_LZ4
+
+/* These two are used by the statvfs shim for glibc2.0 and bsd */
+/* Define if we have sys/vfs.h */
+#cmakedefine HAVE_VFS_H
+#cmakedefine HAVE_STRUCT_STATFS_F_TYPE
+
+/* Define if we have sys/mount.h */
+#cmakedefine HAVE_MOUNT_H
+
+/* Define if we have enabled pthread support */
+#cmakedefine HAVE_PTHREAD
+
+/* Check for getresuid() function and similar ones */
+#cmakedefine HAVE_GETRESUID
+#cmakedefine HAVE_GETRESGID
+#cmakedefine HAVE_SETRESUID
+#cmakedefine HAVE_SETRESGID
+
+/* Define the arch name string */
+#define COMMON_ARCH "${COMMON_ARCH}"
+
+/* The package name string */
+#define PACKAGE "${PACKAGE}"
+
+/* The version number string */
+#define PACKAGE_VERSION "${PACKAGE_VERSION}"
+
+/* The mail address to reach upstream */
+#define PACKAGE_MAIL "deity@lists.debian.org"
+
+#define APT_8_CLEANER_HEADERS
+#define APT_9_CLEANER_HEADERS
+#define APT_10_CLEANER_HEADERS
+
+/* unrolling is faster combined with an optimizing compiler */
+#define SHA2_UNROLL_TRANSFORM