From ba94a2f8b79095e1b01d4dc0b49ac85a76e93858 Mon Sep 17 00:00:00 2001 From: Andrey Astafyev Date: Wed, 23 Jun 2021 02:11:10 +0300 Subject: [PATCH] Ionobase --- FindIonobase.cmake | 29 +++++++++++++++++++++++++++ FindIonobaseThirdparty.cmake | 39 ++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 FindIonobase.cmake create mode 100644 FindIonobaseThirdparty.cmake diff --git a/FindIonobase.cmake b/FindIonobase.cmake new file mode 100644 index 0000000..33c566b --- /dev/null +++ b/FindIonobase.cmake @@ -0,0 +1,29 @@ +if(NOT LIBIONOBASE_PREFIX STREQUAL CMAKE_BINARY_DIR) + set(LIBIONOBASE_PREFIX "" CACHE PATH "The path to the previx of an libionobase installation") + + find_path( + LIBIONOBASE_INCLUDE_DIRS + NAMES preprocmath/params.hpp + PATHS ${LIBIONOBASE_PREFIX}/include) + find_library( + LIBIONOBASE_LIBRARY + NAMES preprocmath + PATHS ${LIBIONOBASE_PREFIX}/lib) + + if(LIBIONOBASE_INCLUDE_DIRS AND LIBIONOBASE_LIBRARY) + get_filename_component(LIBIONOBASE_LIBRARY_DIR ${LIBIONOBASE_LIBRARY} + DIRECTORY CACHE) + set(LIBIONOBASE_FOUND TRUE) + endif() + + if(LIBIONOBASE_FOUND) + if(NOT LIBIONOBASE_FIND_QUIETLY) + message(STATUS "Found libionobase") + endif() + set(HAVE_LIBIONOBASE 1) + elseif(LIBIONOBASE_FOUND) + if(LIBIONOBASE_FIND_REQUIRED) + message(FATAL_ERROR "Could not find libionobase") + endif() + endif() +endif() diff --git a/FindIonobaseThirdparty.cmake b/FindIonobaseThirdparty.cmake new file mode 100644 index 0000000..1124bef --- /dev/null +++ b/FindIonobaseThirdparty.cmake @@ -0,0 +1,39 @@ +# Подключение внешних проектов +include(ExternalProject) + +if(${IonobaseThirdparty_FIND_COMPONENTS} STREQUAL "headers") + ExternalProject_Add( + libionobase + SOURCE_DIR ${CMAKE_SOURCE_DIR}/thirdparty/libionobase + 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} + + BUILD_COMMAND true + INSTALL_COMMAND make ionobase-install-headers) +else() + ExternalProject_Add( + libionobase + SOURCE_DIR ${CMAKE_SOURCE_DIR}/thirdparty/libionobase + 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} + ) +endif() + +set(LIBIONOBASE_PREFIX + ${CMAKE_BINARY_DIR} + CACHE FILEPATH "" FORCE) +set(LIBIONOBASE_INCLUDE_DIRS + ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR} + CACHE PATH "" FORCE) +set(LIBIONOBASE_LIBRARY_DIR + ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR} + CACHE PATH "" FORCE) +set(LIBIONOBASE_LIBRARY + ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/libionobase.a + CACHE FILEPATH "" FORCE)