# ============================================================================== # Findprotozero.cmake # ============================================================================== # This module fetches the protozero header-only protobuf reader library. # # Targets provided: # protozero::protozero - The protozero interface target # # Variables set: # protozero_FOUND - TRUE if protozero is available # protozero_LIBRARIES - The library target (protozero::protozero) # protozero_INCLUDE_DIR - Include directory for protozero headers # protozero_VERSION - Version of protozero # ============================================================================== if (DEFINED _FINDPROTOZERO_INCLUDED) return() endif() set(_FINDPROTOZERO_INCLUDED TRUE) if (DEFINED protozero_FIND_VERSION AND NOT protozero_FIND_VERSION STREQUAL "") set(PROTOZERO_VERSION "${protozero_FIND_VERSION}") else() set(PROTOZERO_VERSION "1.8.1") endif() message(STATUS "Fetching protozero ${PROTOZERO_VERSION}") include(FetchContent) find_program(GIT_EXECUTABLE git) if (NOT GIT_EXECUTABLE) message(FATAL_ERROR "Fetch with zip not supported.") endif() FetchContent_Declare( protozero GIT_REPOSITORY https://github.com/mapbox/protozero.git GIT_TAG v${PROTOZERO_VERSION} SOURCE_SUBDIR _unused # no CMakeLists.txt here; skips add_subdirectory ) # SOURCE_SUBDIR points to a non-existent directory so FetchContent_MakeAvailable # skips add_subdirectory (protozero's tests/tools/docs are never configured). FetchContent_MakeAvailable(protozero) add_library(protozero INTERFACE) target_include_directories(protozero SYSTEM INTERFACE "${protozero_SOURCE_DIR}/include") add_library(protozero::protozero ALIAS protozero) set(protozero_FOUND TRUE) set(protozero_LIBRARIES protozero::protozero) set(protozero_VERSION "${PROTOZERO_VERSION}") get_target_property(_protozero_inc protozero::protozero INTERFACE_INCLUDE_DIRECTORIES) set(protozero_INCLUDE_DIR "${_protozero_inc}") set(PROTOZERO_LICENSE_FILE "${protozero_SOURCE_DIR}/LICENSE" CACHE FILEPATH "Path to protozero license file")