CapnProtoConfig.cmake.in (3430B)
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 @PACKAGE_INIT@ 38 39 set(CapnProto_VERSION @VERSION@) 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 "@PACKAGE_CMAKE_INSTALL_FULL_INCLUDEDIR@") 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 (@WITH_OPENSSL@) # 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 include("${CMAKE_CURRENT_LIST_DIR}/CapnProtoTargets.cmake") 66 include("${CMAKE_CURRENT_LIST_DIR}/CapnProtoMacros.cmake") 67 68 69 # FindCapnProto.cmake provides dependency information via several CAPNP_-prefixed variables. New 70 # code should not rely on these variables, but prefer linking directly to the imported targets we 71 # now provide. However, we should still set these variables to ease the transition for projects 72 # which currently depend on the find-module. 73 74 set(CAPNP_INCLUDE_DIRS ${CAPNP_INCLUDE_DIRECTORY}) 75 76 # No need to list all libraries, just the leaves of the dependency tree. 77 set(CAPNP_LIBRARIES_LITE CapnProto::capnp) 78 set(CAPNP_LIBRARIES CapnProto::capnp-rpc CapnProto::capnp-json 79 CapnProto::kj-http) 80 81 set(CAPNP_DEFINITIONS) 82 if(TARGET CapnProto::capnp AND NOT TARGET CapnProto::capnp-rpc) 83 set(CAPNP_DEFINITIONS -DCAPNP_LITE) 84 endif() 85 86 set(CAPNP_FOUND ${CapnProto_FOUND})