From 82fd36e58b936fc3030ba2cc838759322e1fe362 Mon Sep 17 00:00:00 2001 From: Andrey Astafyev Date: Wed, 23 Jun 2021 07:34:59 +0300 Subject: [PATCH] Preproc --- FindPreproc.cmake | 29 +++++++++++++++++++++++++++ FindPreprocThirdparty.cmake | 39 +++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 FindPreproc.cmake create mode 100644 FindPreprocThirdparty.cmake diff --git a/FindPreproc.cmake b/FindPreproc.cmake new file mode 100644 index 0000000..cffb441 --- /dev/null +++ b/FindPreproc.cmake @@ -0,0 +1,29 @@ +if(NOT LIBPREPROC_PREFIX STREQUAL CMAKE_BINARY_DIR) + set(LIBPREPROC_PREFIX "" CACHE PATH "The path to the previx of an libpreproc installation") + + find_path( + LIBPREPROC_INCLUDE_DIRS + NAMES preproc/mark.hpp + PATHS ${LIBPREPROC_PREFIX}/include) + find_library( + LIBPREPROC_LIBRARY + NAMES preproc + PATHS ${LIBPREPROC_PREFIX}/lib) + + if(LIBPREPROC_INCLUDE_DIRS AND LIBPREPROC_LIBRARY) + get_filename_component(LIBPREPROC_LIBRARY_DIR ${LIBPREPROC_LIBRARY} + DIRECTORY CACHE) + set(LIBPREPROC_FOUND TRUE) + endif() + + if(LIBPREPROC_FOUND) + if(NOT LIBPREPROC_FIND_QUIETLY) + message(STATUS "Found libpreproc") + endif() + set(HAVE_LIBPREPROC 1) + elseif(LIBPREPROC_FOUND) + if(LIBPREPROC_FIND_REQUIRED) + message(FATAL_ERROR "Could not find libpreproc") + endif() + endif() +endif() diff --git a/FindPreprocThirdparty.cmake b/FindPreprocThirdparty.cmake new file mode 100644 index 0000000..821a7b0 --- /dev/null +++ b/FindPreprocThirdparty.cmake @@ -0,0 +1,39 @@ +# Подключение внешних проектов +include(ExternalProject) + +if(PreprocThirdparty_FIND_COMPONENTS STREQUAL "headers") + ExternalProject_Add( + libpreproc + SOURCE_DIR ${CMAKE_SOURCE_DIR}/thirdparty/libpreproc + 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 preproc-install-headers) +else() + ExternalProject_Add( + libpreproc + SOURCE_DIR ${CMAKE_SOURCE_DIR}/thirdparty/libpreproc + 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(LIBPREPROC_PREFIX + ${CMAKE_BINARY_DIR} + CACHE FILEPATH "" FORCE) +set(LIBPREPROC_INCLUDE_DIRS + ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR} + CACHE PATH "" FORCE) +set(LIBPREPROC_LIBRARY_DIR + ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR} + CACHE PATH "" FORCE) +set(LIBPREPROC_LIBRARY + ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/libpreproc.a + CACHE FILEPATH "" FORCE)