annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/lib/cmake/CapnProto/CapnProtoConfig.cmake @ 68:5028fdace37b

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 16:23:26 -0400
parents
children
rev   line source
jpayne@68 1 # Cap'n Proto CMake Package Configuration
jpayne@68 2 #
jpayne@68 3 # When configured and installed, this file enables client projects to find Cap'n Proto using
jpayne@68 4 # CMake's find_package() command. It adds imported targets in the CapnProto:: namespace, such as
jpayne@68 5 # CapnProto::kj, CapnProto::capnp, etc. (one target for each file in pkgconfig/*.pc.in), defines
jpayne@68 6 # the capnp_generate_cpp() function, and exposes some variables for compatibility with the original
jpayne@68 7 # FindCapnProto.cmake module.
jpayne@68 8 #
jpayne@68 9 # Example usage:
jpayne@68 10 # find_package(CapnProto)
jpayne@68 11 # capnp_generate_cpp(CAPNP_SRCS CAPNP_HDRS schema.capnp)
jpayne@68 12 # add_executable(foo main.cpp ${CAPNP_SRCS})
jpayne@68 13 # target_link_libraries(foo PRIVATE CapnProto::capnp)
jpayne@68 14 # target_include_directories(foo PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
jpayne@68 15 #
jpayne@68 16 # If you are using RPC features, use 'CapnProto::capnp-rpc' in the target_link_libraries() call.
jpayne@68 17 #
jpayne@68 18 # Paths to `capnp` and `capnpc-c++` are exposed in the following variables:
jpayne@68 19 # CAPNP_EXECUTABLE
jpayne@68 20 # Path to the `capnp` tool (can be set to override).
jpayne@68 21 # CAPNPC_CXX_EXECUTABLE
jpayne@68 22 # Path to the `capnpc-c++` tool (can be set to override).
jpayne@68 23 #
jpayne@68 24 # For FindCapnProto.cmake compatibility, the following variables are also provided. Please prefer
jpayne@68 25 # using the imported targets in new CMake code.
jpayne@68 26 # CAPNP_INCLUDE_DIRS
jpayne@68 27 # Include directories for the library's headers.
jpayne@68 28 # CANP_LIBRARIES
jpayne@68 29 # The Cap'n Proto library paths.
jpayne@68 30 # CAPNP_LIBRARIES_LITE
jpayne@68 31 # Paths to only the 'lite' libraries.
jpayne@68 32 # CAPNP_DEFINITIONS
jpayne@68 33 # Compiler definitions required for building with the library.
jpayne@68 34 # CAPNP_FOUND
jpayne@68 35 # Set if the libraries have been located (prefer using CapnProto_FOUND in new code).
jpayne@68 36 #
jpayne@68 37 set(CAPNP_PKG_CONFIG_FILES pkgconfig/capnp.pc pkgconfig/capnpc.pc pkgconfig/capnp-rpc.pc pkgconfig/capnp-json.pc pkgconfig/capnp-websocket.pc pkgconfig/kj.pc pkgconfig/kj-async.pc pkgconfig/kj-http.pc pkgconfig/kj-gzip.pc pkgconfig/kj-tls.pc pkgconfig/kj-test.pc )
jpayne@68 38
jpayne@68 39 set(CapnProto_VERSION 1.0.2)
jpayne@68 40
jpayne@68 41 set(CAPNP_EXECUTABLE $<TARGET_FILE:CapnProto::capnp_tool>
jpayne@68 42 CACHE FILEPATH "Location of capnp executable")
jpayne@68 43 set(CAPNPC_CXX_EXECUTABLE $<TARGET_FILE:CapnProto::capnpc_cpp>
jpayne@68 44 CACHE FILEPATH "Location of capnpc-c++ executable")
jpayne@68 45 set(CAPNP_INCLUDE_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/../../../include")
jpayne@68 46
jpayne@68 47 # work around http://public.kitware.com/Bug/view.php?id=15258
jpayne@68 48 if(NOT _IMPORT_PREFIX)
jpayne@68 49 set(_IMPORT_PREFIX ${PACKAGE_PREFIX_DIR})
jpayne@68 50 endif()
jpayne@68 51
jpayne@68 52 if (NO) # WITH_OPENSSL
jpayne@68 53 include(CMakeFindDependencyMacro)
jpayne@68 54 if (CMAKE_VERSION VERSION_LESS 3.9)
jpayne@68 55 # find_dependency() did not support COMPONENTS until CMake 3.9
jpayne@68 56 #
jpayne@68 57 # in practice, this call can be erroneous
jpayne@68 58 # if the user has only libcrypto installed, but not libssl
jpayne@68 59 find_dependency(OpenSSL)
jpayne@68 60 else()
jpayne@68 61 find_dependency(OpenSSL COMPONENTS Crypto SSL)
jpayne@68 62 endif()
jpayne@68 63 endif()
jpayne@68 64
jpayne@68 65 if (@WITH_ZLIB@) # WITH_ZLIB
jpayne@68 66 include(CMakeFindDependencyMacro)
jpayne@68 67 find_dependency(ZLIB)
jpayne@68 68 endif()
jpayne@68 69
jpayne@68 70 if (NO) # _WITH_LIBUCONTEXT
jpayne@68 71 set(forwarded_config_flags)
jpayne@68 72 if(CapnProto_FIND_QUIETLY)
jpayne@68 73 list(APPEND forwarded_config_flags QUIET)
jpayne@68 74 endif()
jpayne@68 75 if(CapnProto_FIND_REQUIRED)
jpayne@68 76 list(APPEND forwarded_config_flags REQUIRED)
jpayne@68 77 endif()
jpayne@68 78 # If the consuming project called find_package(CapnProto) with the QUIET or REQUIRED flags, forward
jpayne@68 79 # them to calls to find_package(PkgConfig) and pkg_check_modules(). Note that find_dependency()
jpayne@68 80 # would do this for us in the former case, but there is no such forwarding wrapper for
jpayne@68 81 # pkg_check_modules().
jpayne@68 82
jpayne@68 83 find_package(PkgConfig ${forwarded_config_flags})
jpayne@68 84 if(NOT ${PkgConfig_FOUND})
jpayne@68 85 # If we're here, the REQUIRED flag must not have been passed, else we would have had a fatal
jpayne@68 86 # error. Nevertheless, a diagnostic for this case is probably nice.
jpayne@68 87 if(NOT CapnProto_FIND_QUIETLY)
jpayne@68 88 message(WARNING "pkg-config cannot be found")
jpayne@68 89 endif()
jpayne@68 90 set(CapnProto_FOUND OFF)
jpayne@68 91 return()
jpayne@68 92 endif()
jpayne@68 93
jpayne@68 94 if (CMAKE_VERSION VERSION_LESS 3.6)
jpayne@68 95 # CMake >= 3.6 required due to the use of IMPORTED_TARGET
jpayne@68 96 message(SEND_ERROR "libucontext support requires CMake >= 3.6.")
jpayne@68 97 endif()
jpayne@68 98
jpayne@68 99 pkg_check_modules(libucontext IMPORTED_TARGET ${forwarded_config_flags} libucontext)
jpayne@68 100 endif()
jpayne@68 101
jpayne@68 102 include("${CMAKE_CURRENT_LIST_DIR}/CapnProtoTargets.cmake")
jpayne@68 103 include("${CMAKE_CURRENT_LIST_DIR}/CapnProtoMacros.cmake")
jpayne@68 104
jpayne@68 105
jpayne@68 106 # FindCapnProto.cmake provides dependency information via several CAPNP_-prefixed variables. New
jpayne@68 107 # code should not rely on these variables, but prefer linking directly to the imported targets we
jpayne@68 108 # now provide. However, we should still set these variables to ease the transition for projects
jpayne@68 109 # which currently depend on the find-module.
jpayne@68 110
jpayne@68 111 set(CAPNP_INCLUDE_DIRS ${CAPNP_INCLUDE_DIRECTORY})
jpayne@68 112
jpayne@68 113 # No need to list all libraries, just the leaves of the dependency tree.
jpayne@68 114 set(CAPNP_LIBRARIES_LITE CapnProto::capnp)
jpayne@68 115 set(CAPNP_LIBRARIES CapnProto::capnp-rpc CapnProto::capnp-json
jpayne@68 116 CapnProto::kj-http)
jpayne@68 117
jpayne@68 118 set(CAPNP_DEFINITIONS)
jpayne@68 119 if(TARGET CapnProto::capnp AND NOT TARGET CapnProto::capnp-rpc)
jpayne@68 120 set(CAPNP_DEFINITIONS -DCAPNP_LITE)
jpayne@68 121 endif()
jpayne@68 122
jpayne@68 123 set(CAPNP_FOUND ${CapnProto_FOUND})