xref: /trunk/main/solenv/gbuild/GoogleTest.mk (revision 390c74e1)
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
30DISABLE_SAL_DBGBOX := 1
31export DISABLE_SAL_DBGBOX
32
33# defined by platform
34#  gb_CppunitTest_TARGETTYPE
35#  gb_CppunitTest_get_filename
36gb_GoogleTest__get_linktargetname = GoogleTest/$(call gb_GoogleTest_get_filename,$(1))
37
38.PHONY : $(call gb_GoogleTest_get_clean_target,%)
39$(call gb_GoogleTest_get_clean_target,%) :
40	$(call gb_Helper_abbreviate_dirs,\
41		rm -f $(call gb_GoogleTest_get_target,$*) $(call gb_GoogleTest_get_target,$*).xml)
42
43.PHONY : $(call gb_GoogleTest_get_target,%)
44$(call gb_GoogleTest_get_target,%) :
45	$(call gb_Output_announce,$*,$(true),CUT,2)
46	$(subst gb_GoogleTest_GTESTPRECOMMAND,$(gb_GoogleTest_GTESTPRECOMMAND),\
47		$(call gb_Helper_abbreviate_dirs_native,\
48			mkdir -p $(dir $@) && \
49			gb_GoogleTest_GTESTPRECOMMAND $(call gb_LinkTarget_get_target,GoogleTest/$(call gb_GoogleTest_get_filename,$*)) \
50				--gtest_output="xml:$(call gb_GoogleTest_get_target,$*).xml"))
51
52define gb_GoogleTest_GoogleTest
53$(call gb_GoogleTest__GoogleTest_impl,$(1),$(call gb_GoogleTest__get_linktargetname,$(1)))
54
55endef
56
57define gb_GoogleTest__GoogleTest_impl
58$(call gb_LinkTarget_LinkTarget,$(2))
59$(call gb_LinkTarget_set_targettype,$(2),GoogleTest)
60$(call gb_LinkTarget_add_defs,$(2),\
61	$(gb_GoogleTest_DEFS) \
62)
63$(call gb_LinkTarget_add_linked_libs,$(2),gtest)
64$(call gb_GoogleTest_get_target,$(1)) : $(call gb_LinkTarget_get_target,$(2))
65$(call gb_GoogleTest_get_clean_target,$(1)) : $(call gb_LinkTarget_get_clean_target,$(2))
66$(call gb_GoogleTest_GoogleTest_platform,$(1),$(2),$(call gb_LinkTarget_get_target,GoogleTest/$(call gb_GoogleTest_get_filename,$(1))))
67$$(eval $$(call gb_Module_register_target,$(call gb_GoogleTest_get_target,$(1)),$(call gb_GoogleTest_get_clean_target,$(1))))
68
69endef
70
71define gb_GoogleTest__forward_to_Linktarget
72gb_GoogleTest_$(1) = $$(call gb_LinkTarget_$(1),$$(call gb_GoogleTest__get_linktargetname,$$(1)),$$(2),$$(3),$$(4))
73
74endef
75
76$(eval $(foreach method,\
77	add_cobject \
78	add_cobjects \
79	add_cxxobject \
80	add_cxxobjects \
81	add_objcxxobject \
82	add_objcxxobjects \
83	add_exception_objects \
84	add_noexception_objects \
85	set_yaccflags \
86	add_cflags \
87	set_cflags \
88	add_cxxflags \
89	set_cxxflags \
90	add_objcxxflags \
91	set_objcxxflags \
92	add_defs \
93	set_defs \
94	set_include \
95	add_ldflags \
96	set_ldflags \
97	add_libs \
98	set_library_path_flags \
99	add_api \
100	set_private_api \
101	add_linked_libs \
102	add_linked_static_libs \
103	use_external \
104	use_externals \
105	add_package_headers \
106	add_sdi_headers \
107	add_precompiled_header \
108,\
109	$(call gb_GoogleTest__forward_to_Linktarget,$(method))\
110))
111
112# vim: set noet sw=4 ts=4:
113