Using in your project

There are many ways to add libbase to your project. It is up to you to decide which one suits your needs the best. Below you will find a recommended (and probably the easiest) way to do so.

Alternative ways

If you don’t want to use vcpkg to resolve dependencies, you can replace step 3 and not export VCPKG_ROOT environment variable and use one of these methods instead:

  • Manually build and install libbase and all of its dependencies in your system. For more details on how to do that, please refer to the building page.

  • Use CMake’s FetchContent module to download and build libbase as part of your project. To do this, add below snippet to your CMake script:

    CMakeLists.txt
    include(FetchContent)
    FetchContent_Declare(
        libbase
        GIT_REPOSITORY https://github.com/ripper37/libbase.git
        GIT_TAG        <commit_or_tag_to_fetch>
    )
    FetchContent_MakeAvailable(libbase)
    

    Caution

    This doesn’t auto-resolve libbase required dependencies by itself. You will still need to build and install them manually or use FetchContent to declare and make them available in your CMake project before including the libbase library.

    Tip

    Simple example project using this method can be viewed here: RippeR37/libbase-example-fetchcontent.

  • Use CMake’s add_subdirectory() to add libbase to your project whil will work similarly to the above FetchContent method. To get libbase source files you can download them or add libbase as a Git submodule.

    Terminal
    $ git submodule add https://github.com/RippeR37/libbase
    $ git submodule update --init
    
    CMakeLists.txt
    add_subdirectory(libbase)
    

    Caution

    Similarly to the FetchContent method, this also doesn’t resolve libbase dependencies by itself. Furthermore, this type of dependency management is not recommended by many - please consider alternatives before choosing it.

    Tip

    Simple example project using this method can be viewed here: RippeR37/libbase-example-submodules.