What is the usual way to use a modified C++ header-only library in my own open source project?

286 Views Asked by At

I want to use a modified C++ header library in my own open source project, but not sure what is the usual way to do it.

For example, to use the original header library "CUB" in my project, I only need to:

  1. download CUB
  2. include the "umbrella" header file in my source file
  3. specify the path to the location of cub in my computer in compilation file

However, I modified some source files (fewer than five files) in cub and want to use the modified CUB in my project. Of course I can simply change the path in the compilation file to the location of the modified library on my local computer. But I don't know how to show this change on GitHub as an open-source project.

The only way I can think about is asking other users to download both of my project and the modified header library, but I feel like this is an ugly way, especially when other users have already downloaded the original library in their computers for other uses.

I am new to C++, so any explanation relates to C++ header library and template library will be appreciated.

1

There are 1 best solutions below

0
Jan Schultke On

Your seem to be under the impression that you should keep the library separate from your project, but you should not.

If you are going to modify CUB and use this modified version in your project, you should make it part of your project. For example, you could put it into a 3rd-party folder inside of your project directory. In order to make your own changes visible, you could also create a submodule inside your repository:

mkdir '3rd-party'
cd '3rd-party'
git submodule add cub-forked
cd cub-forked
// copy CUB files into cub-forked
git submodule set-url "URL_of_your_cub-forked_on_GitHub

This way, when people visit your main repository, they can navigate to your modified cub-forked repository on GitHub too.

You can add 3rd-party/cub-forked to your include path for easy including of its header files.