Closed yurivict closed 1 year ago
@yurivict thanks for the report. But I have been using FetchContent for 2 years now, and I don't see any problem on my machine and GitHub Actions CI. Also I still prefer FetchContent to find_package, since I don't have to install gtest in advance into my machine, and I can download the exact version of gtest in the project folder. Thanks for your understanding!
@yhirose Tests fail to link. See the errors above.
The tests fail to link in 1.8.5:
[100% 1/1] : && /usr/local/libexec/ccache/c++ -O2 -pipe -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -isystem /usr/local/include -Wall -Wextra -O2 -pipe -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -isystem /usr/local/include -DNDEBUG -fstack-protector-strong -L/usr/local/lib test/CMakeFiles/peglib-test-main.dir/test1.cc.o test/CMakeFiles/peglib-test-main.dir/test2.cc.o test/CMakeFiles/peglib-test-main.dir/test3.cc.o -o test/peglib-test-main -lgtest_main && cd /usr/ports/textproc/cpp-peglib/work/.build/test && /usr/local/bin/cmake -D TEST_TARGET=peglib-test-main -D TEST_EXECUTABLE=/usr/ports/textproc/cpp-peglib/work/.build/test/peglib-test-main -D TEST_EXECUTOR= -D TEST_WORKING_DIR=/usr/ports/textproc/cpp-peglib/work/.build/test -D TEST_EXTRA_ARGS= -D TEST_PROPERTIES= -D TEST_PREFIX= -D TEST_SUFFIX= -D TEST_FILTER= -D NO_PRETTY_TYPES=FALSE -D NO_PRETTY_VALUES=FALSE -D TEST_LIST=peglib-test-main_TESTS -D CTEST_FILE=/usr/ports/textproc/cpp-peglib/work/.build/test/peglib-test-main[1]_tests.cmake -D TEST_DISCOVERY_TIMEOUT=5 -D TEST_XML_OUTPUT_DIR= -P /usr/local/share/cmake/Modules/GoogleTestAddTests.cmake
FAILED: test/peglib-test-main test/peglib-test-main[1]_tests.cmake /usr/ports/textproc/cpp-peglib/work/.build/test/peglib-test-main[1]_tests.cmake
: && /usr/local/libexec/ccache/c++ -O2 -pipe -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -isystem /usr/local/include -Wall -Wextra -O2 -pipe -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -isystem /usr/local/include -DNDEBUG -fstack-protector-strong -L/usr/local/lib test/CMakeFiles/peglib-test-main.dir/test1.cc.o test/CMakeFiles/peglib-test-main.dir/test2.cc.o test/CMakeFiles/peglib-test-main.dir/test3.cc.o -o test/peglib-test-main -lgtest_main && cd /usr/ports/textproc/cpp-peglib/work/.build/test && /usr/local/bin/cmake -D TEST_TARGET=peglib-test-main -D TEST_EXECUTABLE=/usr/ports/textproc/cpp-peglib/work/.build/test/peglib-test-main -D TEST_EXECUTOR= -D TEST_WORKING_DIR=/usr/ports/textproc/cpp-peglib/work/.build/test -D TEST_EXTRA_ARGS= -D TEST_PROPERTIES= -D TEST_PREFIX= -D TEST_SUFFIX= -D TEST_FILTER= -D NO_PRETTY_TYPES=FALSE -D NO_PRETTY_VALUES=FALSE -D TEST_LIST=peglib-test-main_TESTS -D CTEST_FILE=/usr/ports/textproc/cpp-peglib/work/.build/test/peglib-test-main[1]_tests.cmake -D TEST_DISCOVERY_TIMEOUT=5 -D TEST_XML_OUTPUT_DIR= -P /usr/local/share/cmake/Modules/GoogleTestAddTests.cmake
/usr/local/bin/x86_64-unknown-freebsd14.0-ld: test/CMakeFiles/peglib-test-main.dir/test1.cc.o: undefined reference to symbol '_ZN7testing4Test5SetUpEv'
/usr/local/bin/x86_64-unknown-freebsd14.0-ld: /usr/local/lib/libgtest.so.1.14.0: error adding symbols: DSO missing from command line
Why use FetchContent? You should find externally installed googletest using
find_package(GTest)
.