cmake_minimum_required(VERSION 3.10) if(NOT CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) endif() project( phxrpc LANGUAGES C CXX VERSION 0.0.1.0) set(CMAKE_POSITION_INDEPENDENT_CODE ON) include(FetchContent) set(protobuf_WITH_ZLIB OFF CACHE INTERNAL "without zlib") set(protobuf_BUILD_TESTS OFF CACHE INTERNAL "without tests") set(protobuf_protobuf_BUILD_SHARED_LIBS OFF CACHE INTERNAL "use static library") set(protobuf_BUILD_LIBPROTOC ON CACHE INTERNAL "build libprotoc") set(protobuf_BUILD_PROTOC_BINARIES ON CACHE INTERNAL "build binaries") FetchContent_Declare( protobuf SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/protobuf-21.12 DOWNLOAD_EXTRACT_TIMESTAMP EXCLUDE_FROM_ALL # URL # https://github.com/protocolbuffers/protobuf/archive/refs/tags/v6.31.1.zip # URL_HASH MD5=2e36cb724b5d50880002501e154a29f2 ) FetchContent_MakeAvailable(protobuf) FetchContent_GetProperties(protobuf) if(NOT protobuf_POPULATED) FetchContent_Populate(protobuf) add_subdirectory(${protobuf_SOURCE_DIR} ${protobuf_BINARY_DIR} EXCLUDE_FROM_ALL) endif() install( DIRECTORY ${protobuf_SOURCE_DIR}/src/google DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} FILES_MATCHING PATTERN "*.h" PATTERN "*.inc" PATTERN "*.proto") set_target_properties(protoc PROPERTIES EXCLUDE_FROM_ALL FALSE) install(TARGETS protoc DESTINATION ${CMAKE_INSTALL_BINDIR}) add_subdirectory(codegen) add_subdirectory(phxrpc)