fc-protocol

This commit is contained in:
Andrei Astafev 2021-06-30 14:19:23 +03:00
parent cac598e912
commit fef5cc42c8
2 changed files with 66 additions and 0 deletions

32
FindFcProtocol.cmake Normal file
View File

@ -0,0 +1,32 @@
if(NOT FC_PROTOCOL_IS_EXTERNAL_PROJECT)
set(FC_PROTOCOL_PREFIX "" CACHE PATH "The path to the prefix of an FC protocols installation")
set(FC_PROTOCOL_INCLUDE_DIR "" CACHE PATH "The path to the headers of an FC protocols installation")
set(_search_paths "")
if(EXISTS FC_PROTOCOL_INCLUDE_DIR)
list(APPEND _search_paths ${FC_PROTOCOL_INCLUDE_DIR})
endif()
if(EXISTS FC_PROTOCOL_PREFIX)
list(APPEND _search_paths "${FC_PROTOCOL_PREFIX}/include")
endif()
find_path(
FC_PROTOCOL_INCLUDE_DIRS
NAMES fc-protocol/hw/result.hpp
PATHS ${_search_paths})
unset(_search_paths)
if(FC_PROTOCOL_INCLUDE_DIRS)
set(FC_PROTOCOL_FOUND TRUE)
endif()
if(FC_PROTOCOL_FOUND)
if(NOT FC_PROTOCOL_FIND_QUIETLY)
message(STATUS "Found FC protocol")
endif()
set(HAVE_FC_PROTOCOL 1)
elseif(FC_PROTOCOL_FOUND)
if(FC_PROTOCOL_FIND_REQUIRED)
message(FATAL_ERROR "Could not find FC protocol")
endif()
endif()
endif()

View File

@ -0,0 +1,34 @@
# Подключение внешних проектов
include(ExternalProject)
# cmake-format: off
list(APPEND _ext_project_args
fc-protocol
SOURCE_DIR ${CMAKE_SOURCE_DIR}/thirdparty/fc-protocol
INSTALL_DIR ${CMAKE_BINARY_DIR}
DOWNLOAD_COMMAND ""
CONFIGURE_COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}"
-DCMLIB_MAIN_DIR=${CMLIB_MAIN_DIR}
${CMLIB_EXT_PROJ_DEFAULT_ARGS}
<SOURCE_DIR>)
if(FcProtocolThirdparty_FIND_COMPONENTS STREQUAL "headers")
list(APPEND _ext_project_args
BUILD_COMMAND true
INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} fc-protocol-install-headers)
endif()
ExternalProject_Add(${_ext_project_args})
unset(_ext_project_args)
set(FC_PROTOCOL_IS_EXTERNAL_PROJECT ON CACHE BOOL "" FORCE)
# cmake-format: on
set(FC_PROTOCOL_PREFIX
${CMAKE_BINARY_DIR}
CACHE FILEPATH "" FORCE)
set(FC_PROTOCOL_INCLUDE_DIR
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}
CACHE PATH "" FORCE)
set(FC_PROTOCOL_INCLUDE_DIRS
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}
CACHE PATH "" FORCE)