Use a single GitLab CI pipeline to build multiple Git C++ dependent REPOs using CMake on Centos8

91 Views Asked by At

I just started learning about CMake and GitLab CI pipeline. I have limited experience with git command lines. We are using another Team's GitLab C++ project. There are 4 Git REPOs which have this local folder structure:

**Project Folder** (not a .git folder). In it are 4 .git REPO folders:
|- **LIB1**: builds many .so files installed to /root/app/
|- **LIB2**: dependent upon LIB1; builds many .so files installed to /root/app
|- **LIB3**: dependent upon LIB1 and LIB2; builds many .so files installed to /root/app
|- **App**: dependent on the 3 LIBs.

Building Locally:
We built a single docker-base dev-container that is used for building the 4 .git REPOs.

The REPOs all use the same branch name. The make install copies the LIB's .so files to a common area, ${CMAKE_INSTALL_PREFIX}, for access by the other LIBs/App. The CMake files access the needed header and protobuf files using relative pathing. So, LIB2 will have lines like ../../LIB2/src/inc, ../../LIB2/proto. We do not create RPMs when building locally.

Building on GitLab Pipeline:
The existing CMake files for each LIB can produce an RPM that has only the .so files, but no header files or protobuf files. Here is the CMakeLists code that enables the make package command:

set(CPACK_GENERATOR "RPM")  
set(CPACK_PACKAGE_NAME ${PROJECT_NAME})  
set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) 

where CMAKE_INSTALL_PREFIX is the location where the .so files are copied with the make install.

The LIB git REPO folders at top-level have CMakeLists.txt and .gitlab-ci.yml, and a dockerfile that we stripped down to use our docker-base dev-container. We already have LIB1 pipeline passing and its RPM pushed to a registry. But now we cannot build in the pipeline LIB2 since the RPM is missing header and protobuf files.

Instead of using RPM files to connect the REPO dependencies, I was wondering whether we could have a single .gitlab-ci.yml file, that would create in the pipeline the same file structure as shown in the Project Folder. And then just build in the pipeline the 4 REPOs just as we do not when "Building Locally".

If it is possible to create this project structure in the pipeline, I think one complicating factor is that as we move into each LIB and App folder, the git files on GITLAB are in different REPOs, whereas, when building locally, all the files are in our drive. Another concern is how to handle each dockerfile in the REPOs that we strip down to use our docker-base dev-container.

If you could advise me on how to create the structure and build each LIB and APP using the existing CMake files that use relative pathing, that would be very helpful. Thank you in advance for your consideration.

What we tried so far:
We just created a LIB1 pipeline that generated an LIB1 RPM and pushed it to a registry. After we retrieved the RPM from the registry, we discovered that it does not have the header files for the .so libraries and is also missing the protobuf files that are auto-generated during the LIB1 build.

We are ready to do the painstaking task of adding the missing files that have to placed in the proper folder tree locations since the existing CMake files for LIB2, LIB3, and the App REPOs use relative pathing to access sibling local REPOs.

Locally, I use a make_all.sh script that came with the project to build everything. If we can mimic this local approach in the GitLab pipeline, that would be much appreciated.

I saw in a GitLab forum an idea of cloning all the REPOs. This confuses me since the LIB1 REPO in the pipeline did not require cloning.

0

There are 0 best solutions below