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