Better way to work by modules with CMake and GTest or any library.

The structure is as follows:

+-- 3rdparty/
|   +-- LibA  // contains fetching  gtest and json to read config files
|   +-- LibB/ // contains fetching  gtest
|   +-- LibC/ // contains fetching  gtest
+-- ProjectA
|   +-- include/
|   |   +-- header files 
|   +--src
|   |   +-- source files
|   +-- test
|   |   +-- test source files
|   |   +-- CMakeLists.txt // It was containing ExternalProject_Add for get  GTest to build the test binaries.
|   +-- CMakeLists.txt // Building projectA
+-- CMakeLists.txt // main CMake where I do add_subdirectory(ProjectA); add_subdirectory(LibA)

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. Changing the external project module to use the FetchingContent did the trick. All this is was coming from a previous configuration where ExternalProject_Add was being used.

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.