This commit is contained in:
Andrei Astafev 2021-06-23 07:34:59 +03:00
parent ba94a2f8b7
commit 82fd36e58b
2 changed files with 68 additions and 0 deletions

29
FindPreproc.cmake Normal file
View File

@ -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()

View File

@ -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}
<SOURCE_DIR>
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}
<SOURCE_DIR>)
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)