2014-06-16 14:50:13 +00:00
|
|
|
QMAKE_MAKE = $$(MAKE)
|
|
|
|
!isEmpty(QMAKE_MAKE) {
|
|
|
|
# We were called recursively. Use the right make, as MAKEFLAGS may be set as well.
|
2016-05-17 12:07:06 +00:00
|
|
|
} else:if(equals(MAKEFILE_GENERATOR, UNIX)|equals(MAKEFILE_GENERATOR, MINGW)) {
|
2012-12-19 22:44:05 +00:00
|
|
|
!equals(QMAKE_HOST.os, Windows): \
|
|
|
|
QMAKE_MAKE = make
|
|
|
|
else: \
|
|
|
|
QMAKE_MAKE = mingw32-make
|
|
|
|
} else:if(equals(MAKEFILE_GENERATOR, MSVC.NET)|equals(MAKEFILE_GENERATOR, MSBUILD)) {
|
2012-04-05 14:47:35 +00:00
|
|
|
QMAKE_MAKE = nmake
|
2012-12-19 22:44:05 +00:00
|
|
|
} else {
|
2012-04-05 14:47:35 +00:00
|
|
|
error("Configure tests are not supported with the $$MAKEFILE_GENERATOR Makefile generator.")
|
2012-12-19 22:44:05 +00:00
|
|
|
}
|
2012-04-05 14:47:35 +00:00
|
|
|
|
|
|
|
# Ensure that a cache is present. If none was found on startup, this will create
|
|
|
|
# one in the build directory of the project which loads this feature.
|
|
|
|
cache()
|
|
|
|
|
|
|
|
QMAKE_CONFIG_LOG = $$dirname(_QMAKE_CACHE_)/config.log
|
|
|
|
QMAKE_CONFIG_TESTS_DIR = $$_PRO_FILE_PWD_/config.tests
|
|
|
|
|
|
|
|
defineTest(qtRunLoggedCommand) {
|
|
|
|
msg = "+ $$1"
|
|
|
|
write_file($$QMAKE_CONFIG_LOG, msg, append)
|
|
|
|
system("$$1 >> \"$$QMAKE_CONFIG_LOG\" 2>&1")|return(false)
|
|
|
|
return(true)
|
|
|
|
}
|
|
|
|
|
|
|
|
# Try to build the test project in $$QMAKE_CONFIG_TESTS_DIR/$$1
|
|
|
|
# ($$_PRO_FILE_PWD_/config.tests/$$1 by default).
|
|
|
|
#
|
|
|
|
# If the test passes, config_$$1 will be added to CONFIG.
|
|
|
|
# The result is automatically cached. Use of cached results
|
|
|
|
# can be suppressed by passing CONFIG+=recheck to qmake.
|
|
|
|
#
|
|
|
|
# Returns: true iff the test passes
|
|
|
|
defineTest(qtCompileTest) {
|
|
|
|
positive = config_$$1
|
|
|
|
done = done_config_$$1
|
|
|
|
|
|
|
|
$$done:!recheck {
|
|
|
|
$$positive:return(true)
|
|
|
|
return(false)
|
|
|
|
}
|
|
|
|
|
|
|
|
log("Checking for $${1}... ")
|
|
|
|
msg = "executing config test $$1"
|
|
|
|
write_file($$QMAKE_CONFIG_LOG, msg, append)
|
|
|
|
|
|
|
|
test_dir = $$QMAKE_CONFIG_TESTS_DIR/$$1
|
|
|
|
test_out_dir = $$shadowed($$test_dir)
|
2012-07-25 08:51:44 +00:00
|
|
|
test_cmd_base = "cd $$system_quote($$system_path($$test_out_dir)) &&"
|
2012-04-05 14:47:35 +00:00
|
|
|
|
|
|
|
# Disable qmake features which are typically counterproductive for tests
|
|
|
|
qmake_configs = "\"CONFIG -= qt debug_and_release app_bundle lib_bundle\""
|
|
|
|
|
2013-11-05 19:36:01 +00:00
|
|
|
# On WinRT we need to change the entry point as we cannot create windows
|
|
|
|
# applications
|
|
|
|
winrt {
|
|
|
|
qmake_configs += " \"QMAKE_LFLAGS+=/ENTRY:main\""
|
|
|
|
}
|
|
|
|
|
2012-04-05 14:47:35 +00:00
|
|
|
# Clean up after previous run
|
|
|
|
exists($$test_out_dir/Makefile):qtRunLoggedCommand("$$test_cmd_base $$QMAKE_MAKE distclean")
|
|
|
|
|
|
|
|
mkpath($$test_out_dir)|error("Aborting.")
|
|
|
|
|
2014-09-24 12:43:04 +00:00
|
|
|
qtRunLoggedCommand("$$test_cmd_base $$system_quote($$system_path($$QMAKE_QMAKE)) -spec $$QMAKESPEC $$qmake_configs $$shell_quote($$test_dir)") {
|
2012-04-05 14:47:35 +00:00
|
|
|
qtRunLoggedCommand("$$test_cmd_base $$QMAKE_MAKE") {
|
|
|
|
log("yes$$escape_expand(\\n)")
|
|
|
|
msg = "test $$1 succeeded"
|
|
|
|
write_file($$QMAKE_CONFIG_LOG, msg, append)
|
|
|
|
|
|
|
|
!$$positive {
|
|
|
|
CONFIG += $$positive
|
|
|
|
cache(CONFIG, add, positive)
|
|
|
|
}
|
|
|
|
!$$done {
|
|
|
|
CONFIG += $$done
|
|
|
|
cache(CONFIG, add, done)
|
|
|
|
}
|
|
|
|
export(CONFIG)
|
|
|
|
return(true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
log("no$$escape_expand(\\n)")
|
|
|
|
msg = "test $$1 FAILED"
|
|
|
|
write_file($$QMAKE_CONFIG_LOG, msg, append)
|
|
|
|
|
|
|
|
$$positive {
|
|
|
|
CONFIG -= $$positive
|
|
|
|
cache(CONFIG, sub, positive)
|
|
|
|
}
|
|
|
|
!$$done {
|
|
|
|
CONFIG += $$done
|
|
|
|
cache(CONFIG, add, done)
|
|
|
|
}
|
|
|
|
export(CONFIG)
|
|
|
|
return(false)
|
|
|
|
}
|