How to clone and integrate external (from git) cmake project into local one How to clone and integrate external (from git) cmake project into local one git git

How to clone and integrate external (from git) cmake project into local one


I would go with the first approach. You don't need to specify a build command because cmake is used by default. This could look like:

cmake_minimum_required(VERSION 3.0)project(GTestProject)include(ExternalProject)set(EXTERNAL_INSTALL_LOCATION ${CMAKE_BINARY_DIR}/external)ExternalProject_Add(googletest    GIT_REPOSITORY https://github.com/google/googletest    CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LOCATION})include_directories(${EXTERNAL_INSTALL_LOCATION}/include)link_directories(${EXTERNAL_INSTALL_LOCATION}/lib)add_executable(FirstTest main.cpp)add_dependencies(FirstTest googletest)target_link_libraries(FirstTest gtest gtest_main pthread)

I don't know if this is the correct/preferred way if there even is one. If you wanted to implement your second approach you would have to download the code with execute_process first.