configure.prf 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. equals(QMAKE_HOST.os, Windows) {
  2. SETENV_PFX = "set "
  3. SETENV_SFX = "&"
  4. } else {
  5. SETENV_PFX =
  6. SETENV_SFX =
  7. }
  8. QMAKE_MAKE = $$(MAKE)
  9. !isEmpty(QMAKE_MAKE) {
  10. # We were called recursively. Use the same make.
  11. } else:if(equals(MAKEFILE_GENERATOR, UNIX)|equals(MAKEFILE_GENERATOR, MINGW)) {
  12. !equals(QMAKE_HOST.os, Windows): \
  13. QMAKE_MAKE = make
  14. else: \
  15. QMAKE_MAKE = mingw32-make
  16. } else:if(equals(MAKEFILE_GENERATOR, MSVC.NET)|equals(MAKEFILE_GENERATOR, MSBUILD)) {
  17. QMAKE_MAKE = nmake
  18. } else {
  19. error("Configure tests are not supported with the $$MAKEFILE_GENERATOR Makefile generator.")
  20. }
  21. # Make sure we don't inherit MAKEFLAGS - -i in particular is fatal.
  22. QMAKE_MAKE = "$${SETENV_PFX}MAKEFLAGS=$$SETENV_SFX $$QMAKE_MAKE"
  23. # Ensure that a cache is present. If none was found on startup, this will create
  24. # one in the build directory of the project which loads this feature.
  25. cache()
  26. QMAKE_CONFIG_LOG = $$dirname(_QMAKE_CACHE_)/config.log
  27. QMAKE_CONFIG_TESTS_DIR = $$_PRO_FILE_PWD_/config.tests
  28. defineTest(qtRunLoggedCommand) {
  29. msg = "+ $$1"
  30. write_file($$QMAKE_CONFIG_LOG, msg, append)
  31. system("$$1 >> \"$$QMAKE_CONFIG_LOG\" 2>&1")|return(false)
  32. return(true)
  33. }
  34. # Try to build the test project in $$QMAKE_CONFIG_TESTS_DIR/$$1
  35. # ($$_PRO_FILE_PWD_/config.tests/$$1 by default).
  36. #
  37. # If the test passes, config_$$1 will be added to CONFIG.
  38. # The result is automatically cached. Use of cached results
  39. # can be suppressed by passing CONFIG+=recheck to qmake.
  40. #
  41. # Returns: true iff the test passes
  42. defineTest(qtCompileTest) {
  43. positive = config_$$1
  44. done = done_config_$$1
  45. $$done:!recheck {
  46. $$positive:return(true)
  47. return(false)
  48. }
  49. log("Checking for $${1}... ")
  50. msg = "executing config test $$1"
  51. write_file($$QMAKE_CONFIG_LOG, msg, append)
  52. test_dir = $$QMAKE_CONFIG_TESTS_DIR/$$1
  53. test_out_dir = $$shadowed($$test_dir)
  54. test_cmd_base = "cd $$system_quote($$system_path($$test_out_dir)) &&"
  55. # Disable qmake features which are typically counterproductive for tests
  56. qmake_configs = "\"CONFIG -= qt debug_and_release app_bundle lib_bundle\""
  57. # On WinRT we need to change the entry point as we cannot create windows
  58. # applications
  59. winrt {
  60. qmake_configs += " \"QMAKE_LFLAGS+=/ENTRY:main\""
  61. }
  62. # Clean up after previous run
  63. exists($$test_out_dir/Makefile):qtRunLoggedCommand("$$test_cmd_base $$QMAKE_MAKE $$(QMAKE_MAKE_ARGS) distclean")
  64. mkpath($$test_out_dir)|error("Aborting.")
  65. !isEmpty (QMAKE_QTCONF): qtconfarg = -qtconf $$QMAKE_QTCONF
  66. qtRunLoggedCommand("$$test_cmd_base $$system_quote($$system_path($$QMAKE_QMAKE)) $$qtconfarg -spec $$QMAKESPEC $$qmake_configs $$shell_quote($$test_dir)") {
  67. qtRunLoggedCommand("$$test_cmd_base $$QMAKE_MAKE $$(QMAKE_MAKE_ARGS)") {
  68. log("yes$$escape_expand(\\n)")
  69. msg = "test $$1 succeeded"
  70. write_file($$QMAKE_CONFIG_LOG, msg, append)
  71. !$$positive {
  72. CONFIG += $$positive
  73. cache(CONFIG, add, positive)
  74. }
  75. !$$done {
  76. CONFIG += $$done
  77. cache(CONFIG, add, done)
  78. }
  79. export(CONFIG)
  80. return(true)
  81. }
  82. }
  83. log("no$$escape_expand(\\n)")
  84. msg = "test $$1 FAILED"
  85. write_file($$QMAKE_CONFIG_LOG, msg, append)
  86. $$positive {
  87. CONFIG -= $$positive
  88. cache(CONFIG, sub, positive)
  89. }
  90. !$$done {
  91. CONFIG += $$done
  92. cache(CONFIG, add, done)
  93. }
  94. export(CONFIG)
  95. return(false)
  96. }