googletest submodule
@henryiii is there any desire to shift googletest from being a submodule to a separately download. I know on most of our other projects we have moved away from having googletest as a submodule since it wasn't required for all or even most builds and that made it an extra download that was unnecessary.
Instead it uses fetch_content or a GitUtils include on older cmake to do the same thing.
If this was of interest I could make a PR for this in the next couple weeks.
How about conanfile.txt inside tests directory?
CMakeLists.txt
if(CLI11_TESTING_INTERNAL)
enable_testing()
add_subdirectory(tests)
endif()
tests/CMakeLists.txt
# Conan bootstrap
if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
message(
STATUS
"Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
file(DOWNLOAD "https://github.com/conan-io/cmake-conan/raw/v0.13/conan.cmake"
"${CMAKE_BINARY_DIR}/conan.cmake")
endif()
include(${CMAKE_BINARY_DIR}/conan.cmake)
conan_check(REQUIRED)
conan_cmake_run(
CONANFILE conanfile.txt
BASIC_SETUP CMAKE_TARGETS
BUILD missing)
include(GoogleTest) # Bundled
tests/conanfile.txt
[requires]
gtest/1.10.0
[generators]
cmake
[options]
# Possible gtest options are:
# - shared
# - build_gmock
# - fPIC
# - no_main
# - debug_postfix
# - hide_symbols
gtest:shared=False
gtest:no_main=True
Then you'll able to use something like this:
target_link_libraries(
myTestExecutable
PRIVATE CONAN_PKG::GTest)
Using this approach you don't need git submodule as well as calling fetch_content.
I'm a fan of git submodules because a) dependencies are not duplicated for each build directory (I usually have several, up to a dozen or so), and b) you can get everything before building, so it's easy to continue to work even on a plane.
However, if there's enough of a reason to avoid submodules, I would consider alternatives, since we really only use it to get gtest. I wish it was easier to be selectively recursive.
(And I haven't really played with Conan other than to support it, looks rather slick in that example...)
I suppose that is a distinction that might be different for libraries are built and header only. In the case of CLI11 it might make more sense to have as a submodule. Some of our other libraries get built a lot but the testing is more rare and off by default so making everyone download Google test if they weren't testing it was overkill.
I've shifted the other submodules away (just needed for one example or special procedures), just GTest is left. That will save lots of time/space (Json was huge if recursive checkouts were on)
I think the calculus for GTEST is different for CLI11 than the other libraries I work with. In several of the others they are used as submodules themselves so having google test as a submodule often results in a bunch of copies of google test being downloaded with no purpose. But CLI11 is probably still used most commonly as a header only library so having an extra gtest as a submodule is not that big of deal.
That may change is CL11 shifts towards a compiled library option, where having subsubmodules becomes a somewhat bigger issue. But for now I think the changes are good, and we can reevaluate later as the library evolves.