3

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.

Jan Schultke
  • 17,446
  • 6
  • 47
  • 96
Jason7525
  • 31
  • 1
  • As a note: In case your open source project is a library, and cub is included in your public header files, then you need to make sure that your modified headers of cub are included and not the one the person using your library might have included. – t.niese Aug 24 '20 at 08:26

1 Answers1

0

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.

Jan Schultke
  • 17,446
  • 6
  • 47
  • 96