aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/unit++/unitpp.m4
blob: b9c5a07ea983866de141d036dcf8c8289759ed18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
dnl AM_PATH_UNITPP([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
dnl note to self - reference vars with $1, $2 etc

AC_DEFUN(AM_PATH_UNITPP,
[
	AC_LANG_PUSH(C++)

	AC_ARG_ENABLE(unitpp,
	    AC_HELP_STRING([--enable-unitpp-test],
	        [enable unit tests (default is YES if you have libunit++, else NO)]),
		, 
		[enable_unitpp="yes"] ) 

	AC_ARG_WITH(unitpp-prefix,
		AC_HELP_STRING([--with-unitpp-prefix=DIR],
			[specify the location of unit++ for unit tests]) )
	
	if test "x$with_unitpp_prefix"="x"; then
		UNITPP_CXXFLAGS="-I$with_unitpp_prefix/include"
		UNITPP_LIBS="-L$with_unitpp_prefix/lib -lunit++"
	else
#		UNITPP_CXXFLAGS="-I/usr/local/include"
		UNITPP_LIBS="-lunit++"
	fi
	CXXFLAGS="$CXXFLAGS $UNITPP_CXXFLAGS"
	LIBS="$LIBS $UNITPP_LIBS"
	
	if test $enable_unitpp="yes"; then
		AC_CHECK_HEADER(unit++/unit++.h,
				[ac_check_unitpp="yes"],
				[ac_check_unitpp="no"] )
		
		if test $ac_check_unitpp="yes"; then
			AC_MSG_CHECKING(if unit++ test program compiles)
			AC_TRY_LINK(
				[ #include<unit++/unit++.h> ],
				[ unitpp::test* test_test = new unitpp::suite("Test Suite"); ],
				[ac_check_unitpp="yes"
				AC_MSG_RESULT(yes) ],
				[ac_check_unitpp="no"
				AC_MSG_RESULT(no) ] )
		fi
	else
		ac_check_unitpp="yes"
	fi

	if test $ac_check_unitpp="yes"; then
		ifelse([$1], , :, [$1])
	else
		UNITPP_CXXFLAGS=""
		UNITPP_LIBS=""
		ifelse([$2], , :, [$2])
	fi
	
	AC_LANG_POP(C++)
	
	AC_SUBST(UNITPP_CXXFLAGS)
	AC_SUBST(UNITPP_LIBS)
])