Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version
  1. Add the submodule to the main module's repository:

    • If the submodule is not already added, use git submodule add to add the submodule to the main module's repository.
    • If the submodule is already added as a directory in the repository, remove it with git rm --cached <submodule_dir> and then add it as a submodule with git submodule add.
  2. Configure the CMakeLists.txt file:

    • Add the following lines to include the submodule's headers in the main module's build: include_directories(<submodule_dir>/include)
    • Add the following lines to link the submodule's shared or static library with the main module's executable: add_subdirectory(<submodule_dir>) target_link_libraries(<main_module_executable> <submodule_library>)
  3. Build the project:

    • Run cmake to generate the build files for the main module, including the submodule.
    • Build the project with make or the appropriate build tool for your platform.

Note: The submodule must have its own CMakeLists.txt file with instructions on how to build the shared or static library.