configure: Fix location of code coverage disablement
diff --git a/configure.ac b/configure.ac
index 83cb4d8..8dac6f5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -11,6 +11,7 @@
 # Make sure the default CFLAGS of `-O2 -g` don't override CODE_COVERAGE_CFLAGS
 # It is important that this comes before AC_PROG_C{C,XX}, as we are attempting
 # to stop them from populating default CFLAGS and CXXFLAGS.
+AS_IF([test "x$enable_tests" = "xno"], [enable_code_coverage=no])
 AS_IF([test "x$enable_code_coverage" != "xno"], [
     AS_IF([test "x${CXXFLAGS+set}" != "xset"], [
         AC_SUBST(CXXFLAGS, [""])
@@ -140,7 +141,6 @@
 	[AM_EXTRA_RECURSIVE_TARGETS([check-valgrind-]vgtool)])
 
 # Code coverage
-AS_IF([test "x$enable_tests" = "xno"], [enable_code_coverage=no])
 AX_CODE_COVERAGE
 AM_EXTRA_RECURSIVE_TARGETS([check-code-coverage])