I have a C++ project which contains a testing application based on googletest library. It is built with help of cmake, which uses FetchContent to grab googletest from git.
Everything works quite good with one drawback: during the install step the content of gtest/gmock is partially copied to the installation location. These files aren't needed for the application, so I'm wondering how to disable/suppress this mess?
CMakeLists.txt:
cmake_minimum_required(VERSION 3.20)
project(test)
include(FetchContent)
FetchContent_Declare(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.12.1
)
FetchContent_MakeAvailable(googletest)
add_executable(test main.cpp)
target_link_libraries(test gtest_main)
install(TARGETS test)
main.cpp:
#include <gtest/gtest.h>
int add(int a, int b) {
return a + b;
}
TEST(testCase, testAdd) {
EXPECT_EQ(add(2, 3), 5);
}
The commands to execute:
mkdir build
cd build
cmake ..
cmake --build . --config Release
cmake --install . --prefix ../install
The created ../install directory will get (I'm building on Windows):
bin\test.exe, which is expected (OK)include\gmock\...andinclude\gtest\...(with a lot of headers, which my app doesn't need)lib\gmock.lib,lib\gmock_main.lib, etc. (which the app doesn't need either)
I guess, this behavior is provided by FetchContent_MakeAvailable, and I couldn't find a way to tune it.
Probably it is specific to googletest only?