void-packages/srcpkgs/capnproto/patches/autotools-install-cmake-fil...

204 lines
7.2 KiB
Diff

Source: Debian
Upstream: yes in a different form
Reason: install cmake files required by mir
--- Makefile.am
+++ Makefile.am
@@ -32,14 +32,18 @@
src/capnp/testdata/lists.binary \
src/capnp/testdata/packedflat \
CMakeLists.txt \
- cmake/FindCapnProto.cmake \
- cmake/CapnProtoConfig.cmake.in \
- cmake/CapnProtoMacros.cmake \
+ cmake/CapnProtoConfig.cmake \
+ cmake/CapnProtoConfigVersion.cmake \
src/CMakeLists.txt \
src/kj/CMakeLists.txt \
src/capnp/CMakeLists.txt
-CLEANFILES = $(test_capnpc_outputs) test_capnpc_middleman distcheck-cmake
+CLEANFILES = \
+ $(test_capnpc_outputs) \
+ test_capnpc_middleman \
+ distcheck-cmake \
+ cmake/CapnProtoConfig.cmake \
+ cmake/CapnProtoVersion.cmake
# Deletes all the files generated by autoreconf.
MAINTAINERCLEANFILES = \
@@ -116,6 +120,23 @@
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = capnp.pc capnp-rpc.pc kj.pc kj-async.pc
+cmakeconfigdir = $(libdir)/cmake/CapnProto
+cmakeconfig_DATA = cmake/CapnProtoConfig.cmake cmake/CapnProtoConfigVersion.cmake
+
+cmake/CapnProtoConfig.cmake: cmake/CapnProtoConfig.cmake.in
+ sed -e "s,@CAPNP_INCLUDE_DIR@,$(includedir),g" \
+ -e "s,@CAPNP_LIB_DIR@,$(libdir),g" \
+ -e "s,@CAPNP_BIN_DIR@,$(bindir),g" \
+ -e "s,@CAPNP_VERSION@,$(VERSION),g" \
+ $< >$@
+
+cmake/CapnProtoConfigVersion.cmake: cmake/CapnProtoConfigVersion.cmake.in
+ sed -e "s,@CAPNP_INCLUDE_DIR@,$(includedir),g" \
+ -e "s,@CAPNP_LIB_DIR@,$(libdir),g" \
+ -e "s,@CAPNP_BIN_DIR@,$(bindir),g" \
+ -e "s,@CAPNP_VERSION@,$(VERSION),g" \
+ $< >$@
+
noinst_HEADERS = \
src/kj/miniposix.h
--- cmake/CapnProtoConfig.cmake.in
+++ cmake/CapnProtoConfig.cmake.in
@@ -1,27 +1,106 @@
-# Example usage:
-# find_package(CapnProto)
-# capnp_generate_cpp(CAPNP_SRCS CAPNP_HDRS schema.capnp)
-# include_directories(${CMAKE_CURRENT_BINARY_DIR})
-# add_executable(foo main.cpp ${CAPNP_SRCS})
-# target_link_libraries(foo CapnProto::capnp)
-#
-# If you are using RPC features, use 'CapnProto::capnp-rpc'
-# in target_link_libraries call.
-#
-@PACKAGE_INIT@
-
-set(CapnProto_VERSION @VERSION@)
-
-set(CAPNP_EXECUTABLE $<TARGET_FILE:CapnProto::capnp_tool>)
-set(CAPNPC_CXX_EXECUTABLE $<TARGET_FILE:CapnProto::capnpc_cpp>)
-set(CAPNP_INCLUDE_DIRECTORY "@PACKAGE_CMAKE_INSTALL_FULL_INCLUDEDIR@")
-
-# work around http://public.kitware.com/Bug/view.php?id=15258
-if(NOT _IMPORT_PREFIX)
- set(_IMPORT_PREFIX ${PACKAGE_PREFIX_DIR})
-endif()
-
-
-
-include("${CMAKE_CURRENT_LIST_DIR}/CapnProtoTargets.cmake")
-include("${CMAKE_CURRENT_LIST_DIR}/CapnProtoMacros.cmake")
+find_path(CAPNP_INCLUDE_DIRS capnp/generated-header-support.h HINTS "@CAPNP_INCLUDE_DIR@")
+find_library(CAPNP_LIB_KJ NAMES kj HINTS "@CAPNP_LIB_DIR@")
+find_library(CAPNP_LIB_KJ-ASYNC NAMES kj-async HINTS "@CAPNP_LIB_DIR@")
+find_library(CAPNP_LIB_CAPNP NAMES capnp HINTS "@CAPNP_LIB_DIR@")
+find_library(CAPNP_LIB_CAPNP-RPC NAMES capnp-rpc "@CAPNP_LIB_DIR@")
+mark_as_advanced(CAPNP_LIB_KJ CAPNP_LIB_KJ-ASYNC CAPNP_LIB_CAPNP CAPNP_LIB_CAPNP-RPC)
+
+set(CAPNP_LIBRARIES_LITE
+ ${CAPNP_LIB_KJ}
+ ${CAPNP_LIB_CAPNP})
+
+set(CAPNP_LIBRARIES
+ ${CAPNP_LIBRARIES_LITE}
+ ${CAPNP_LIB_KJ-ASYNC}
+ ${CAPNP_LIB_CAPNP-RPC})
+
+find_program(CAPNP_EXECUTABLE
+ NAMES capnp
+ DOC "Cap'n Proto Command-line Tool"
+ HINTS "@CAPNP_BIN_DIR@")
+
+find_program(CAPNPC_CXX_EXECUTABLE
+ NAMES capnpc-c++
+ DOC "Cap'n Proto C++ Compiler"
+ HINTS "@CAPNP_BIN_DIR@")
+
+function(CAPNP_GENERATE_CPP SOURCES HEADERS)
+ if(NOT ARGN)
+ message(SEND_ERROR "CAPNP_GENERATE_CPP() called without any source files.")
+ endif()
+ if(NOT CAPNP_EXECUTABLE)
+ message(SEND_ERROR "Could not locate capnp executable (CAPNP_EXECUTABLE).")
+ endif()
+ if(NOT CAPNPC_CXX_EXECUTABLE)
+ message(SEND_ERROR "Could not locate capnpc-c++ executable (CAPNPC_CXX_EXECUTABLE).")
+ endif()
+ if(NOT CAPNP_INCLUDE_DIRS)
+ message(SEND_ERROR "Could not locate capnp header files (CAPNP_INCLUDE_DIRS).")
+ endif()
+
+ # Default compiler includes
+ set(include_path -I ${CMAKE_CURRENT_SOURCE_DIR} -I ${CAPNP_INCLUDE_DIRS})
+
+ if(DEFINED CAPNPC_IMPORT_DIRS)
+ # Append each directory as a series of '-I' flags in ${include_path}
+ foreach(directory ${CAPNPC_IMPORT_DIRS})
+ get_filename_component(absolute_path "${directory}" ABSOLUTE)
+ list(APPEND include_path -I ${absolute_path})
+ endforeach()
+ endif()
+
+ if(DEFINED CAPNPC_OUTPUT_DIR)
+ # Prepend a ':' to get the format for the '-o' flag right
+ set(output_dir ":${CAPNPC_OUTPUT_DIR}")
+ else()
+ set(output_dir ":.")
+ endif()
+
+ if(NOT DEFINED CAPNPC_SRC_PREFIX)
+ set(CAPNPC_SRC_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}")
+ endif()
+ get_filename_component(CAPNPC_SRC_PREFIX "${CAPNPC_SRC_PREFIX}" ABSOLUTE)
+
+ set(${SOURCES})
+ set(${HEADERS})
+ foreach(schema_file ${ARGN})
+ get_filename_component(file_path "${schema_file}" ABSOLUTE)
+ get_filename_component(file_dir "${file_path}" PATH)
+
+ # Figure out where the output files will go
+ if (NOT DEFINED CAPNPC_OUTPUT_DIR)
+ set(output_base "${file_path}")
+ else()
+ # Output files are placed in CAPNPC_OUTPUT_DIR, at a location as if they were
+ # relative to CAPNPC_SRC_PREFIX.
+ string(LENGTH "${CAPNPC_SRC_PREFIX}" prefix_len)
+ string(SUBSTRING "${file_path}" 0 ${prefix_len} output_prefix)
+ if(NOT "${CAPNPC_SRC_PREFIX}" STREQUAL "${output_prefix}")
+ message(SEND_ERROR "Could not determine output path for '${schema_file}' ('${file_path}') with source prefix '${CAPNPC_SRC_PREFIX}' into '${CAPNPC_OUTPUT_DIR}'.")
+ endif()
+
+ string(SUBSTRING "${file_path}" ${prefix_len} -1 output_path)
+ set(output_base "${CAPNPC_OUTPUT_DIR}${output_path}")
+ endif()
+
+ add_custom_command(
+ OUTPUT "${output_base}.c++" "${output_base}.h"
+ COMMAND "${CAPNP_EXECUTABLE}"
+ ARGS compile
+ -o ${CAPNPC_CXX_EXECUTABLE}${output_dir}
+ --src-prefix ${CAPNPC_SRC_PREFIX}
+ ${include_path}
+ ${CAPNPC_FLAGS}
+ ${file_path}
+ DEPENDS "${schema_file}"
+ COMMENT "Compiling Cap'n Proto schema ${schema_file}"
+ VERBATIM
+ )
+ list(APPEND ${SOURCES} "${output_base}.c++")
+ list(APPEND ${HEADERS} "${output_base}.h")
+ endforeach()
+
+ set_source_files_properties(${${SOURCES}} ${${HEADERS}} PROPERTIES GENERATED TRUE)
+ set(${SOURCES} ${${SOURCES}} PARENT_SCOPE)
+ set(${HEADERS} ${${HEADERS}} PARENT_SCOPE)
+endfunction()
--- /dev/null
+++ cmake/CapnProtoConfigVersion.cmake.in
@@ -0,0 +1,11 @@
+set(PACKAGE_VERSION "@CAPNP_VERSION@")
+
+if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else()
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
+ if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
+ set(PACKAGE_VERSION_EXACT TRUE)
+ endif()
+endif()
+