diff --git a/flat_git.md b/flat_git.md new file mode 100644 index 0000000..7311218 --- /dev/null +++ b/flat_git.md @@ -0,0 +1,38 @@ +# Introduction + +# Usage + +## Example +In this example let's say you have one CMake project per git repository, for a total of 3 projects. top_project is the main one, and it depends on libraries sub_1, sub_2. Project sub_1 also depend on sub_2. + +CMakeLists.txt - everything is just the same as usual, except that you use `add_shared_git_project` instead of the regular `add_subdirectory`. +```cmake + cmake_minimum_required(VERSION 3.3 FATAL_ERROR) + project(top_project CXX) + include(shared_git_project) + add_executable(top_project main.cpp) + add_shared_git_project(lib/sub_1) + add_shared_git_project(lib/sub_2) +``` + +lib/sub_1/CMakeLists.txt +```cmake + project(sub_1) + include(shared_git_project) + add_library(sub_1 lib1.cpp) + add_shared_git_pcoject(lib/sub_2) +``` + +lib/sub_2/CMakeLists.txt +```cmake + project(sub_2) + add_library(sub_2 lib2.cpp) +``` + +This will clone the main git repository and the sub_1 and sub_2 directories inside the shared/ directory. After doing this you are good to go! +```bash + git clone https://github.com/dummy/top_project.git + mkdir shared + cd top_project.git + flat_git ../shared +``` \ No newline at end of file