Commit 6f65467d authored by Harris Hancock's avatar Harris Hancock Committed by Harris Hancock

Make CMake package config backward compatible with FindCapnProto module

parent dd2430ce
# Cap'n Proto CMake Package Configuration
#
# When configured and installed, this file enables client projects to find Cap'n Proto using
# CMake's find_package() command. It adds imported targets in the CapnProto:: namespace, such as
# CapnProto::kj, CapnProto::capnp, etc. (one target for each file in pkgconfig/*.pc.in), defines
# the capnp_generate_cpp() function, and exposes some variables for compatibility with the original
# FindCapnProto.cmake module.
#
# Example usage:
# find_package(CapnProto)
# capnp_generate_cpp(CAPNP_SRCS CAPNP_HDRS schema.capnp)
......@@ -5,8 +13,26 @@
# 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.
# If you are using RPC features, use 'CapnProto::capnp-rpc' in the target_link_libraries() call.
#
# Paths to `capnp` and `capnpc-c++` are exposed in the following variables:
# CAPNP_EXECUTABLE
# Path to the `capnp` tool (can be set to override).
# CAPNPC_CXX_EXECUTABLE
# Path to the `capnpc-c++` tool (can be set to override).
#
# For FindCapnProto.cmake compatibility, the following variables are also provided. Please prefer
# using the imported targets in new CMake code.
# CAPNP_INCLUDE_DIRS
# Include directories for the library's headers.
# CANP_LIBRARIES
# The Cap'n Proto library paths.
# CAPNP_LIBRARIES_LITE
# Paths to only the 'lite' libraries.
# CAPNP_DEFINITIONS
# Compiler definitions required for building with the library.
# CAPNP_FOUND
# Set if the libraries have been located (prefer using CapnProto_FOUND in new code).
#
@PACKAGE_INIT@
......@@ -25,3 +51,23 @@ endif()
include("${CMAKE_CURRENT_LIST_DIR}/CapnProtoTargets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/CapnProtoMacros.cmake")
# FindCapnProto.cmake provides dependency information via several CAPNP_-prefixed variables. New
# code should not rely on these variables, but prefer linking directly to the imported targets we
# now provide. However, we should still set these variables to ease the transition for projects
# which currently depend on the find-module.
set(CAPNP_INCLUDE_DIRS ${CAPNP_INCLUDE_DIRECTORY})
# No need to list all libraries, just the leaves of the dependency tree.
set(CAPNP_LIBRARIES_LITE CapnProto::capnp)
set(CAPNP_LIBRARIES CapnProto::capnp-rpc CapnProto::capnp-json
CapnProto::kj-http CapnProto::kj-test)
set(CAPNP_DEFINITIONS)
if(TARGET CapnProto::capnp AND NOT TARGET CapnProto::capnp-rpc)
set(CAPNP_DEFINITIONS -DCAPNP_LITE)
endif()
set(CAPNP_FOUND ${CapnProto_FOUND})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment