xref: /aoo42x/main/solenv/gbuild/GoogleTest.mk (revision e75d772d)
1#**************************************************************
2#
3#  Licensed to the Apache Software Foundation (ASF) under one
4#  or more contributor license agreements.  See the NOTICE file
5#  distributed with this work for additional information
6#  regarding copyright ownership.  The ASF licenses this file
7#  to you under the Apache License, Version 2.0 (the
8#  "License"); you may not use this file except in compliance
9#  with the License.  You may obtain a copy of the License at
10#
11#    http://www.apache.org/licenses/LICENSE-2.0
12#
13#  Unless required by applicable law or agreed to in writing,
14#  software distributed under the License is distributed on an
15#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16#  KIND, either express or implied.  See the License for the
17#  specific language governing permissions and limitations
18#  under the License.
19#
20#**************************************************************
21
22
23
24
25# GoogleTest class
26
27# in non-product builds, ensure that tools-based assertions do not pop up as message box, but are routed to the shell
28DBGSV_ERROR_OUT := shell
29export DBGSV_ERROR_OUT
30
31# defined by platform
32#  gb_CppunitTest_TARGETTYPE
33#  gb_CppunitTest_get_filename
34gb_GoogleTest__get_linktargetname = GoogleTest/$(call gb_GoogleTest_get_filename,$(1))
35
36.PHONY : $(call gb_GoogleTest_get_clean_target,%)
37$(call gb_GoogleTest_get_clean_target,%) :
38	$(call gb_Helper_abbreviate_dirs,\
39		rm -f $(call gb_GoogleTest_get_target,$*) $(call gb_GoogleTest_get_target,$*).xml)
40
41.PHONY : $(call gb_GoogleTest_get_target,%)
42$(call gb_GoogleTest_get_target,%) :
43	$(call gb_Output_announce,$*,$(true),CUT,2)
44	$(subst gb_GoogleTest_GTESTPRECOMMAND,$(gb_GoogleTest_GTESTPRECOMMAND),\
45		$(call gb_Helper_abbreviate_dirs_native,\
46			mkdir -p $(dir $@) && \
47			gb_GoogleTest_GTESTPRECOMMAND $(call gb_LinkTarget_get_target,GoogleTest/$(call gb_GoogleTest_get_filename,$*)) \
48				--gtest_output="xml:$(call gb_GoogleTest_get_target,$*).xml"))
49
50define gb_GoogleTest_GoogleTest
51$(call gb_GoogleTest__GoogleTest_impl,$(1),$(call gb_GoogleTest__get_linktargetname,$(1)))
52
53endef
54
55define gb_GoogleTest__GoogleTest_impl
56$(call gb_LinkTarget_LinkTarget,$(2))
57$(call gb_LinkTarget_set_targettype,$(2),GoogleTest)
58$(call gb_LinkTarget_add_linked_libs,$(2),gtest)
59$(call gb_GoogleTest_get_target,$(1)) : $(call gb_LinkTarget_get_target,$(2))
60$(call gb_GoogleTest_get_clean_target,$(1)) : $(call gb_LinkTarget_get_clean_target,$(2))
61$(call gb_GoogleTest_GoogleTest_platform,$(1),$(2),$(call gb_LinkTarget_get_target,GoogleTest/$(call gb_GoogleTest_get_filename,$(1))))
62$$(eval $$(call gb_Module_register_target,$(call gb_GoogleTest_get_target,$(1)),$(call gb_GoogleTest_get_clean_target,$(1))))
63
64endef
65
66define gb_GoogleTest__forward_to_Linktarget
67gb_GoogleTest_$(1) = $$(call gb_LinkTarget_$(1),$$(call gb_GoogleTest__get_linktargetname,$$(1)),$$(2),$$(3))
68
69endef
70
71$(eval $(foreach method,\
72	add_cobject \
73	add_cobjects \
74	add_cxxobject \
75	add_cxxobjects \
76	add_objcxxobject \
77	add_objcxxobjects \
78	add_exception_objects \
79	add_noexception_objects \
80	set_cflags \
81	set_cxxflags \
82	set_objcxxflags \
83	set_defs \
84	set_include \
85	set_ldflags \
86	set_library_path_flags \
87	add_linked_libs \
88	add_linked_static_libs \
89	add_package_headers \
90	add_sdi_headers \
91	add_precompiled_header \
92,\
93	$(call gb_GoogleTest__forward_to_Linktarget,$(method))\
94))
95
96# vim: set noet sw=4 ts=4:
97