![]() The parent repository tracks all the commits.Ī submodule update checks out the revision of all the commits that the parent repository has gone through after a pull.This is useful when you want to roll back to the current commit of the parent repository. ![]() There is always an option to use the best commit. So the above example shows adding a project submodule in my project in a folder named assign. Remote: Total 3025 (delta 0), reused 0 (delta 0), pack-reused 5257 Password for into '/home/rishivant/main/project'. ![]() git submodule add assignĬloning into '/home/rishivant/Documents/ut it assignment/assign'. This example will show you in a better way. The command to commit it is :- $ git commit -m "Added the submodule to the project." So as a consequence you will need to commit it. While adding your submodule you will find that it will be staged. To add a submodule use ‘git submodule add’ and specify the url of the repository you want to add as a submodule. 2-How to create repository with submodules ?Ģ.1 To add a submodule in a git repository. gitmodules file which contains the path of all submodules and the link to clone them. You can find the submodule anywhere inside the parents repository working directory.We can configure the submodule via. Now this helps in tracking the changes in all the repositories from a central repository. In simple words git allows you to include other repositories into a single repository called parent repository. Sub modules provide the feature of embedding one repository into another as a sub folder. So FetchContent fixes the issue, and as well I even removed it from there because there is no need anymore to fetch as its coming from one of the libraries I built.Reading Time: 3 minutes 1 – What is a Git Submodule?Īctually git provides the feature of git submodule to help projects with this. All this is was coming from a previous configuration where ExternalProject_Add was being used. Changing the external project module to use the FetchingContent did the trick. The error I was getting it was related to using the external project module of CMake that was realizing that the GoogleTest was already fetched at the project level. +- CMakeLists.txt // main CMake where I do add_subdirectory(ProjectA) add_subdirectory(LibA) | | +- CMakeLists.txt // It was containing ExternalProject_Add for get GTest to build the test binaries. | +- LibA // contains fetching gtest and json to read config files The structure is as follows: +- 3rdparty/ If this works I will post the final CMakeLists.txt. ![]() Should I use FetchContent_Populate instead of FetchContent_MakeAvailable?Įdit: As I mentioned in the post, the submodules are being added with git submodule, not with the FetchContent module.Įdit2: I guess the correct way of doing if gtest was populated already is with FetchContent_Populate. I don’t see how I can tell CMake to build GTest in another module. Target_link_libraries(PlaceHolderUnitTest gtest_main) include(CTest)Īdd_executable(PlaceHolderUnitTest PlaceHolderUnitTest.cpp) This is the CMake file for testing in my main project. GoogleTest is being detected in build-debug/_deps/googletest-src already when CMake runs the fetching from the submodule. The problem comes when I am adding the submodule to my main project where I use Google Test for testing as well. Target_link_libraries(xUnitTest gtest_main MOTOR nlohmann_json::nlohmann_json) Set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)Īdd_executable(XUnitTes X1UnitTest.cpp X2UnitTest.cpp X3UnitTesting.cpp) Set(JSON_BuildTests OFF CACHE INTERNAL "") My submodule CMake its as follows: message(STATUS "Fetching googletest") ![]() I am not having an issue with how the module FetchContent works. I could install GTest in the system but my manager, for some reason, does not want that approach. How can I avoid this? The issue is that each library is using it. The issue I having is that Google Test is being already detected when fetching it in the main project. I am also fetching Google Test for testing purposes in the main project, mainly integration of each library with the rest of the components or with other specific features of the product. I am using git submodules in the main project to include my libraries, and I am adding them with +- CMakeLists.txt // where I created the lib and enable testing adding the test subdirectoryĪnd that structure is followed for the rest of the libraries I have, which are around 5, for different devices like cameras, sensors, and stuff. | +- CMakeLists.txt // where I fetch GoogleTest and a JSON library for testing purposes The different structure of the libraries is the following: I am integrating this into the main project. I am finding myself stuck to integrate some libraries of my own that are using CMake into a product. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |