Wie verwende ich Boost-Bibliotheken direkt von Github aus mit cmake FetchContent oder einer einfacheren Lösung?

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Wie verwende ich Boost-Bibliotheken direkt von Github aus mit cmake FetchContent oder einer einfacheren Lösung?

by Guest » 20 Jan 2025, 17:01

Nehmen wir an, wir möchten die Bibliothek boost::file_system in unserem cmake-Multiplattformprojekt (ios, macos, android, windows, linux) verwenden. Eine Möglichkeit besteht darin, den Boost-Quellcode direkt in unser Projekt zu kopieren. Es erhöht die Projektgröße und bringt viele Wartungsprobleme, Patches, Aktualisierungen usw. mit sich. Was wäre, wenn wir Boost-Quellen während des cmake-configure-Schritts herunterladen? Also füge ich ein minimales Beispiel hinzu (Datei - main.cxx):

Code: Select all

    #include 

#include 

int main(int, char**)
{
std::cout  < 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 s t C o n f i g   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 / c o n f i g . 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 s t C o n t a i n e r H a s h < br />    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)

Vielleicht kennen Sie eine einfachere Lösung? Wie kann man Boost-Bibliotheken ohne großen Aufwand direkt von GitHub aus mit cmake kompilieren und verknüpfen?

Top