Как использовать библиотеки Boost непосредственно из github, используя cmake FetchContent или любое более простое решениC++

Программы на C++. Форум разработчиков
Ответить Пред. темаСлед. тема
Anonymous
 Как использовать библиотеки Boost непосредственно из github, используя cmake FetchContent или любое более простое решени

Сообщение Anonymous »

Предположим, мы хотим использовать библиотеку boost::file_system в нашем многоплатформенном проекте cmake (ios, macos, android, windows, linux). Один из способов сделать это — напрямую скопировать исходный код boost в наш проект. Это увеличивает размер проекта и добавляет множество проблем с обслуживанием, исправлениями, обновлениями и т. д. Что, если мы загрузим источники повышения на этапе настройки cmake. Поэтому я добавляю минимальный пример (файл - main.cxx):

Код: Выделить всё

    #include 

#include 

int main(int, char**)
{
std::cout          } < b r   / > < / c o d e > < b r   / > Д а л е е   и д е т   п о л н ы й   ф а й л   C M a k e L i s t s . t x t   д л я   с б о р к и   э т о г о   м и н и м а л ь н о г о   п р и м е р а   и з   и с х о д н о г о   к о д а   б е з   у с т а н о в к и   b o o s t   в   с и с т е м у . < / p > < b r   / > < c o d e > c m a k e _ m i n i m u m _ r e q u i r e d ( V E R S I O N   3 . 2 0 . . . 3 . 2 3 ) < b r   / > < b r   / > p r o j e c t ( 1 9 - b o o s t - f i l e - s y s t e m   C X X ) < b r   / > < b r   / > s e t ( C M A K E _ C X X _ S T A N D A R D   2 3 ) < b r   / > s e t ( C M A K E _ C X X _ E X T E N S I O N S   O F F ) < b r   / > s e t ( C M A K E _ C X X _ S T A N D A R D _ R E Q U I R E D   O N ) < b r   / > < b r   / > s e t ( C M A K E _ C X X _ V I S I B I L I T Y _ P R E S E T   h i d d e n ) < b r   / > s e t ( C M A K E _ V I S I B I L I T Y _ I N L I N E S _ H I D D E N   O N ) < b r   / > s e t ( C M A K E _ E N A B L E _ E X P O R T S   O F F ) < b r   / > < b r   / > i n c l u d e ( F e t c h C o n t e n t ) < b r   / > < b r   / > f e t c h c o n t e n t _ d e c l a r e ( < b r   / >         B o o s t A s s e r t   G I T _ R E P O S I T O R Y   h t t p s : / / g i t h u b . c o m / b o o s t o r g / a s s e r t . g i t < b r   / >         G I T _ T A G   b o o s t - 1 . 7 9 . 0 ) < b r   / > f e t c h c o n t e n t _ d e c l a r e ( < b r   / >         B o o stConfig GIT_REPOSITORY https://github.com/boostorg/config.git
GIT_TAG boost-1.79.0)
fetchcontent_declare(
BoostContainerHash
GIT_REPOSITORY https://github.com/boostorg/container_hash.git
GIT_TAG boost-1.79.0)
fetchcontent_declare(
BoostCore GIT_REPOSITORY https://github.com/boostorg/core.git
GIT_TAG boost-1.79.0)
fetchcontent_declare(
BoostDetail GIT_REPOSITORY https://github.com/boostorg/detail.git
GIT_TAG boost-1.79.0)
fetchcontent_declare(
BoostInteger GIT_REPOSITORY https://github.com/boostorg/integer.git
GIT_TAG boost-1.79.0)
fetchcontent_declare(
BoostStaticAssert
GIT_REPOSITORY https://github.com/boostorg/static_assert.git
GIT_TAG boost-1.79.0)
fetchcontent_declare(
BoostThrowException
GIT_REPOSITORY https://github.com/boostorg/throw_exception.git
GIT_TAG boost-1.79.0)
fetchcontent_declare(
BoostTypeTraits GIT_REPOSITORY https://github.com/boostorg/type_traits.git
GIT_TAG boost-1.79.0)
fetchcontent_declare(
BoostPreprocessor
GIT_REPOSITORY https://github.com/boostorg/preprocessor.git
GIT_TAG boost-1.79.0)
fetchcontent_declare(
BoostIterator GIT_REPOSITORY https://github.com/boostorg/iterator.git
GIT_TAG boost-1.79.0)
fetchcontent_declare(BoostIo GIT_REPOSITORY https://github.com/boostorg/io.git
GIT_TAG boost-1.79.0)
fetchcontent_declare(
BoostConceptCheck
GIT_REPOSITORY https://github.com/boostorg/concept_check.git
GIT_TAG boost-1.79.0)
fetchcontent_declare(
BoostConversion GIT_REPOSITORY https://github.com/boostorg/conversion.git
GIT_TAG boost-1.79.0)
fetchcontent_declare(
BoostFunctionTypes
GIT_REPOSITORY https://github.com/boostorg/function_types.git
GIT_TAG boost-1.79.0)
fetchcontent_declare(
BoostFusion GIT_REPOSITORY https://github.com/boostorg/fusion.git
GIT_TAG boost-1.79.0)
fetchcontent_declare(BoostMpl GIT_REPOSITORY https://github.com/boostorg/mpl.git
GIT_TAG boost-1.79.0)
fetchcontent_declare(
BoostOptional GIT_REPOSITORY https://github.com/boostorg/optional.git
GIT_TAG boost-1.79.0)
fetchcontent_declare(
BoostSmartPtr GIT_REPOSITORY https://github.com/boostorg/smart_ptr.git
GIT_TAG boost-1.79.0)
fetchcontent_declare(
BoostUtility GIT_REPOSITORY https://github.com/boostorg/utility.git
GIT_TAG boost-1.79.0)
fetchcontent_declare(
BoostTypeof GIT_REPOSITORY https://github.com/boostorg/typeof.git
GIT_TAG boost-1.79.0)
fetchcontent_declare(
BoostTuple GIT_REPOSITORY https://github.com/boostorg/tuple.git
GIT_TAG boost-1.79.0)
fetchcontent_declare(
BoostPredef GIT_REPOSITORY https://github.com/boostorg/predef.git
GIT_TAG boost-1.79.0)
fetchcontent_declare(
BoostMove GIT_REPOSITORY https://github.com/boostorg/move.git
GIT_TAG boost-1.79.0)
fetchcontent_declare(
BoostAtomic GIT_REPOSITORY https://github.com/boostorg/atomic.git
GIT_TAG boost-1.79.0)
fetchcontent_declare(
BoostVariant2 GIT_REPOSITORY https://github.com/boostorg/variant2.git
GIT_TAG boost-1.79.0)
fetchcontent_declare(
BoostAlign GIT_REPOSITORY https://github.com/boostorg/align.git
GIT_TAG boost-1.79.0)
fetchcontent_declare(
BoostMp11 GIT_REPOSITORY https://github.com/boostorg/mp11.git
GIT_TAG boost-1.79.0)
fetchcontent_declare(
BoostWinapi GIT_REPOSITORY https://github.com/boostorg/winapi.git
GIT_TAG boost-1.79.0)
fetchcontent_declare(
BoostSystem GIT_REPOSITORY https://github.com/boostorg/system.git
GIT_TAG boost-1.79.0)
fetchcontent_declare(
BoostFileSystem GIT_REPOSITORY https://github.com/boostorg/filesystem.git
GIT_TAG boost-1.79.0)

fetchcontent_makeavailable(
BoostAssert
BoostConfig
BoostInteger
BoostStaticAssert
BoostThrowException
BoostTypeTraits
BoostPreprocessor
BoostIo
BoostIterator
BoostConceptCheck
BoostConversion
BoostFunctionTypes
BoostFusion
BoostMpl
BoostOptional
BoostSmartPtr
BoostUtility
BoostTypeof
BoostTuple
BoostPredef
BoostMove
BoostAlign
BoostMp11
BoostWinapi
BoostContainerHash
BoostCore
BoostDetail
BoostAtomic
BoostVariant2
BoostSystem
BoostFileSystem)

add_executable(main_boost main.cxx)
target_link_libraries(main_boost PRIVATE Boost::filesystem)
Может быть, вы знаете более простое решение? Как можно без проблем скомпилировать и связать библиотеки Boost прямо из GitHub с помощью cmake?


Подробнее здесь: https://stackoverflow.com/questions/729 ... ent-or-any
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «C++»