libimitator

This commit is contained in:
Andrei Astafev 2021-08-02 16:55:24 +03:00
parent 3bf9e8f148
commit 99716263c8
2 changed files with 85 additions and 0 deletions

45
FindImitator.cmake Normal file
View File

@ -0,0 +1,45 @@
if(NOT IMITATOR_IS_EXTERNAL_PROJECT)
set(IMITATOR_PREFIX "" CACHE PATH "The path to the prefix of an libimitator installation")
set(IMITATOR_INCLUDE_DIR "" CACHE PATH "The path to the headers of an libimitator installation")
set(IMITATOR_LIBRARY_DIR "" CACHE PATH "The path to the library of an libimitator installation")
set(_search_paths "")
if(IMITATOR_INCLUDE_DIR AND EXISTS ${IMITATOR_INCLUDE_DIR})
list(APPEND _search_paths ${IMITATOR_INCLUDE_DIR})
endif()
if(IMITATOR_PREFIX AND EXISTS ${IMITATOR_PREFIX})
list(APPEND _search_paths "${IMITATOR_PREFIX}/include")
endif()
find_path(
IMITATOR_INCLUDE_DIRS
NAMES imitator/imitator.hpp
PATHS ${_search_paths})
set(_search_paths "")
if(IMITATOR_LIBRARY_DIR AND EXISTS ${IMITATOR_LIBRARY_DIR})
list(APPEND _search_paths ${IMITATOR_LIBRARY_DIR})
endif()
if(IMITATOR_PREFIX AND EXISTS ${IMITATOR_PREFIX})
list(APPEND _search_paths "${IMITATOR_PREFIX}/lib")
endif()
find_library(
IMITATOR_LIBRARIES
NAMES imitator
PATHS ${_search_paths})
unset(_search_paths)
if(IMITATOR_INCLUDE_DIRS AND IMITATOR_LIBRARIES)
set(IMITATOR_FOUND TRUE)
endif()
if(IMITATOR_FOUND)
if(NOT IMITATOR_FIND_QUIETLY)
message(STATUS "Found libimitator")
endif()
set(HAVE_IMITATOR 1)
elseif(IMITATOR_FOUND)
if(IMITATOR_FIND_REQUIRED)
message(FATAL_ERROR "Could not find libimitator")
endif()
endif()
endif()

View File

@ -0,0 +1,40 @@
# Подключение внешних проектов
include(ExternalProject)
set(IMITATOR_PREFIX
${CMAKE_BINARY_DIR}
CACHE FILEPATH "" FORCE)
set(IMITATOR_INCLUDE_DIR
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}
CACHE PATH "" FORCE)
set(IMITATOR_INCLUDE_DIRS
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}
CACHE PATH "" FORCE)
set(IMITATOR_LIBRARY_DIR
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}
CACHE PATH "" FORCE)
set(IMITATOR_LIBRARIES
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/libimitator.a
CACHE FILEPATH "" FORCE)
# cmake-format: off
list(APPEND _ext_project_args
libimitator
SOURCE_DIR ${CMAKE_SOURCE_DIR}/thirdparty/libimitator
INSTALL_DIR ${CMAKE_BINARY_DIR}
CMAKE_ARGS ${CMLIB_EXT_PROJ_DEFAULT_ARGS}
<SOURCE_DIR>)
if(ImitatorThirdparty_FIND_COMPONENTS STREQUAL "headers")
list(APPEND _ext_project_args
BUILD_COMMAND true
INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} imitator-install-headers)
else()
list(APPEND _ext_project_args
BUILD_BYPRODUCTS ${IMITATOR_LIBRARIES})
endif()
ExternalProject_Add(${_ext_project_args})
unset(_ext_project_args)
set(IMITATOR_IS_EXTERNAL_PROJECT ON CACHE BOOL "" FORCE)
# cmake-format: on