From 626ce00befee975637c7d7795d8d1fce60cea77d Mon Sep 17 00:00:00 2001 From: Gautham B A Date: Sat, 5 Dec 2020 16:11:09 +0530 Subject: Fix typo --- googletest/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'googletest/README.md') diff --git a/googletest/README.md b/googletest/README.md index 9e747ce0..8488aaef 100644 --- a/googletest/README.md +++ b/googletest/README.md @@ -60,7 +60,7 @@ If you want to use GoogleTest in a project which already uses CMake, the easiest way is to get installed libraries and headers. * Import GoogleTest by using `find_package` (or `pkg_check_modules`). For - example, if `find_package(GTest CONFIG REQUIRED)` is succeed, you can use + example, if `find_package(GTest CONFIG REQUIRED)` succeeds, you can use the libraries as `GTest::gtest`, `GTest::gmock`. And a more robust and flexible approach is to build GoogleTest as part of that -- cgit v1.2.3 From 5065389aabfa1d70a49d57eb355b9db4500801be Mon Sep 17 00:00:00 2001 From: Vollstrecker Date: Sat, 13 Mar 2021 16:58:42 +0100 Subject: Use Fetchcontent instead of ExternalProject Hi, instead of ExternalProject and a new file that is spawned in a new process, it's easier to just use FetchContent. cmake 3.14 should be old enough to be spread. --- googletest/README.md | 62 +++++++++------------------------------------------- 1 file changed, 10 insertions(+), 52 deletions(-) (limited to 'googletest/README.md') diff --git a/googletest/README.md b/googletest/README.md index 717c8867..33604bd8 100644 --- a/googletest/README.md +++ b/googletest/README.md @@ -85,58 +85,18 @@ main build can be done a few different ways: is just a little more complex, but doesn't have the limitations of the other methods. -The last of the above methods is implemented with a small piece of CMake code in -a separate file (e.g. `CMakeLists.txt.in`) which is copied to the build area and -then invoked as a sub-build _during the CMake stage_. That directory is then -pulled into the main build with `add_subdirectory()`. For example: +The last of the above methods is implemented with a small piece of CMake code so +the code is pulled into the main build. -New file `CMakeLists.txt.in`: +Just add to your `CMakeLists.txt`: ```cmake -cmake_minimum_required(VERSION 2.8.12) - -project(googletest-download NONE) - -include(ExternalProject) -ExternalProject_Add(googletest - GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG master - SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-src" - BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-build" - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - TEST_COMMAND "" +include (FetchContent) +FetchContent_Declare( + googletest + GIT_REPOSITORY https://github.com/google/googletest.git ) -``` - -Existing build's `CMakeLists.txt`: - -```cmake -# Download and unpack googletest at configure time -configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt) -execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . - RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download ) -if(result) - message(FATAL_ERROR "CMake step for googletest failed: ${result}") -endif() -execute_process(COMMAND ${CMAKE_COMMAND} --build . - RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download ) -if(result) - message(FATAL_ERROR "Build step for googletest failed: ${result}") -endif() - -# Prevent overriding the parent project's compiler/linker -# settings on Windows -set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) - -# Add googletest directly to our build. This defines -# the gtest and gtest_main targets. -add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src - ${CMAKE_CURRENT_BINARY_DIR}/googletest-build - EXCLUDE_FROM_ALL) +FetchContent_MakeAvailable(googletest) # Now simply link against gtest or gtest_main as needed. Eg add_executable(example example.cpp) @@ -144,10 +104,8 @@ target_link_libraries(example gtest_main) add_test(NAME example_test COMMAND example) ``` -Note that this approach requires CMake 2.8.2 or later due to its use of the -`ExternalProject_Add()` command. The above technique is discussed in more detail -in [this separate article](http://crascit.com/2015/07/25/cmake-gtest/) which -also contains a link to a fully generalized implementation of the technique. +Note that this approach requires CMake 3.14 or later due to its use of the +`FetchContent_MakeAvailable()` command. ##### Visual Studio Dynamic vs Static Runtimes -- cgit v1.2.3 From 38c316fc5cc1dfee51d2c2cf4b23f036d92221ac Mon Sep 17 00:00:00 2001 From: Vollstrecker Date: Wed, 14 Apr 2021 14:58:03 +0200 Subject: Changes like Requested. --- googletest/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'googletest/README.md') diff --git a/googletest/README.md b/googletest/README.md index 33604bd8..991a3170 100644 --- a/googletest/README.md +++ b/googletest/README.md @@ -85,8 +85,8 @@ main build can be done a few different ways: is just a little more complex, but doesn't have the limitations of the other methods. -The last of the above methods is implemented with a small piece of CMake code so -the code is pulled into the main build. +The last of the above methods is implemented with a small piece of CMake so the +code is pulled into the main build. Just add to your `CMakeLists.txt`: -- cgit v1.2.3 From c79eb87c11f6a69ff4f3183bb03eb89c6c9cd674 Mon Sep 17 00:00:00 2001 From: Vollstrecker Date: Wed, 14 Apr 2021 23:13:01 +0200 Subject: Mention to explicitely set the option to it's default. --- googletest/README.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'googletest/README.md') diff --git a/googletest/README.md b/googletest/README.md index 991a3170..0c10b148 100644 --- a/googletest/README.md +++ b/googletest/README.md @@ -96,6 +96,8 @@ FetchContent_Declare( googletest GIT_REPOSITORY https://github.com/google/googletest.git ) +# For Windows: Prevent overriding the parent project's compiler/linker settings +set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) FetchContent_MakeAvailable(googletest) # Now simply link against gtest or gtest_main as needed. Eg -- cgit v1.2.3 From 8043818e1b9417a04f16bba4553a8c05eba391c6 Mon Sep 17 00:00:00 2001 From: Vollstrecker Date: Tue, 20 Apr 2021 10:09:33 +0200 Subject: Use URL instead of git-repo --- googletest/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'googletest/README.md') diff --git a/googletest/README.md b/googletest/README.md index 0c10b148..2454cd61 100644 --- a/googletest/README.md +++ b/googletest/README.md @@ -94,7 +94,8 @@ Just add to your `CMakeLists.txt`: include (FetchContent) FetchContent_Declare( googletest - GIT_REPOSITORY https://github.com/google/googletest.git + # Specify the commit you depend on and update it regularly. + URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip ) # For Windows: Prevent overriding the parent project's compiler/linker settings set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) -- cgit v1.2.3