@@ -18,7 +18,7 @@ ZLIB_SUPPORT = -DCPPHTTPLIB_ZLIB_SUPPORT -lz
1818BROTLI_DIR = $(PREFIX ) /opt/brotli
1919BROTLI_SUPPORT = -DCPPHTTPLIB_BROTLI_SUPPORT -I$(BROTLI_DIR ) /include -L$(BROTLI_DIR ) /lib -lbrotlicommon -lbrotlienc -lbrotlidec
2020
21- TEST_ARGS = gtest/src/gtest -all.cc gtest/src/gtest_main.cc -Igtest -Igtest/include $(OPENSSL_SUPPORT ) $(ZLIB_SUPPORT ) $(BROTLI_SUPPORT ) -pthread -lcurl
21+ TEST_ARGS = gtest_main.o gtest-all.o -Igtest -Igtest/include $(OPENSSL_SUPPORT ) $(ZLIB_SUPPORT ) $(BROTLI_SUPPORT ) -pthread -lcurl
2222
2323# By default, use standalone_fuzz_target_runner.
2424# This runner does no fuzzing, but simply executes the inputs
@@ -33,19 +33,30 @@ REALPATH = $(shell which grealpath 2>/dev/null || which realpath 2>/dev/null)
3333STYLE_CHECK_FILES = $(filter-out httplib.h httplib.cc, \
3434 $(wildcard example/* .h example/* .cc fuzzing/* .h fuzzing/* .cc * .h * .cc ../httplib.h) )
3535
36- all : test test_split
36+ all : test test_no_exit_time_dtors test_split
3737 ./test
38+ GTEST_FILTER=" ExitTimeDtorsTest.*" ./test_no_exit_time_dtors
3839
3940proxy : test_proxy
4041 ./test_proxy
4142
42- test : test.cc include_httplib.cc ../httplib.h Makefile cert.pem
43+ gtest-all.o : gtest/src/gtest-all.cc
44+ $(CXX ) -c -o $@ $(CXXFLAGS ) -Igtest -Igtest/include $<
45+
46+ gtest_main.o : gtest/src/gtest_main.cc
47+ $(CXX ) -c -o $@ $(CXXFLAGS ) -Igtest -Igtest/include $<
48+
49+ test : gtest_main.o gtest-all.o test.cc include_httplib.cc ../httplib.h Makefile cert.pem
4350 $(CXX ) -o $@ -I.. $(CXXFLAGS ) test.cc include_httplib.cc $(TEST_ARGS )
4451 @file $@
4552
53+ test_no_exit_time_dtors : gtest_main.o gtest-all.o test.cc ../httplib.h Makefile cert.pem
54+ $(CXX ) -o $@ -I.. $(CXXFLAGS ) -DCPPHTTPLIB_NO_EXIT_TIME_DESTRUCTORS \
55+ $(if $(findstring clang,$(CXX ) ) ,-Wexit-time-destructors -Werror=exit-time-destructors) test.cc $(TEST_ARGS )
56+
4657# Note: The intention of test_split is to verify that it works to compile and
4758# link the split httplib.h, so there is normally no need to execute it.
48- test_split : test.cc ../httplib.h httplib.cc Makefile cert.pem
59+ test_split : gtest_main.o gtest-all.o test.cc ../httplib.h httplib.cc Makefile cert.pem
4960 $(CXX ) -o $@ $(CXXFLAGS ) test.cc httplib.cc $(TEST_ARGS )
5061
5162check_abi :
@@ -73,7 +84,7 @@ style_check: $(STYLE_CHECK_FILES)
7384 echo " All files are properly formatted." ; \
7485 fi
7586
76- test_proxy : test_proxy.cc ../httplib.h Makefile cert.pem
87+ test_proxy : gtest_main.o gtest-all.o test_proxy.cc ../httplib.h Makefile cert.pem
7788 $(CXX ) -o $@ -I.. $(CXXFLAGS ) test_proxy.cc $(TEST_ARGS )
7889
7990# Runs server_fuzzer.cc based on value of $(LIB_FUZZING_ENGINE).
@@ -98,5 +109,5 @@ cert.pem:
98109 ./gen-certs.sh
99110
100111clean :
101- rm -rf test test_split test_proxy server_fuzzer * .pem * .0 * .o * .1 * .srl httplib.h httplib.cc _build* * .dSYM
112+ rm -rf test test_no_exit_time_dtors test_split test_proxy server_fuzzer * .pem * .0 * .o * .1 * .srl httplib.h httplib.cc _build* * .dSYM
102113
0 commit comments