CMakeLists.txt 110 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813
  1. # a macro for tests that have a simple format where the name matches the
  2. # directory and project
  3. macro(ADD_TEST_MACRO NAME COMMAND)
  4. string(REPLACE "." "/" dir "${NAME}")
  5. string(REGEX REPLACE "[^.]*\\." "" proj "${NAME}")
  6. add_test(${NAME} ${CMAKE_CTEST_COMMAND}
  7. --build-and-test
  8. "${CMake_SOURCE_DIR}/Tests/${dir}"
  9. "${CMake_BINARY_DIR}/Tests/${dir}"
  10. --build-two-config
  11. ${build_generator_args}
  12. --build-project ${proj}
  13. ${${NAME}_CTEST_OPTIONS}
  14. --build-options ${build_options}
  15. ${${NAME}_BUILD_OPTIONS}
  16. --test-command ${COMMAND} ${ARGN})
  17. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${dir}")
  18. endmacro()
  19. include(${CMAKE_CURRENT_SOURCE_DIR}/RegexEscapeString.cmake)
  20. include(${CMAKE_CURRENT_SOURCE_DIR}/CheckFortran.cmake)
  21. # Fake a user home directory to avoid polluting the real one.
  22. if(DEFINED ENV{HOME} AND NOT CTEST_NO_TEST_HOME)
  23. set(TEST_HOME "${CMake_BINARY_DIR}/Tests/CMakeFiles/TestHome")
  24. file(MAKE_DIRECTORY "${TEST_HOME}")
  25. file(WRITE "${TEST_HOME}/.cvspass" ":pserver:[email protected]:/cvsroot/KWSys A\n")
  26. set(TEST_HOME_ENV_CODE "# Fake a user home directory to avoid polluting the real one.
  27. # But provide original ENV{HOME} value in ENV{CTEST_REAL_HOME} for tests that
  28. # need access to the real HOME directory.
  29. set(ENV{CTEST_REAL_HOME} \"\$ENV{HOME}\")
  30. set(ENV{HOME} \"${TEST_HOME}\")
  31. ")
  32. endif()
  33. # Choose a default configuration for CTest tests.
  34. set(CTestTest_CONFIG Debug)
  35. if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE)
  36. set(CTestTest_CONFIG ${CMAKE_BUILD_TYPE})
  37. endif()
  38. configure_file(${CMake_SOURCE_DIR}/Tests/EnforceConfig.cmake.in
  39. ${CMake_BINARY_DIR}/Tests/EnforceConfig.cmake @ONLY)
  40. # Testing
  41. if(BUILD_TESTING)
  42. set(CMake_TEST_DEVENV "")
  43. if(CMAKE_GENERATOR MATCHES "Visual Studio [7-9] " AND
  44. NOT CMAKE_MAKE_PROGRAM MATCHES "[mM][sS][bB][uU][iI][lL][dD]\\.[eE][xX][eE]")
  45. set(CMake_TEST_DEVENV "${CMAKE_MAKE_PROGRAM}")
  46. endif()
  47. if(CMAKE_GENERATOR MATCHES "Visual Studio")
  48. set(CMake_TEST_EXPLICIT_MAKE_PROGRAM "")
  49. else()
  50. set(CMake_TEST_EXPLICIT_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM}")
  51. endif()
  52. if(NOT CMake_TEST_EXTERNAL_CMAKE)
  53. if("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles" OR ("${CMAKE_GENERATOR}" MATCHES Ninja AND NOT WIN32))
  54. set(TEST_CompileCommandOutput 1)
  55. endif()
  56. endif()
  57. set(MAKE_IS_GNU )
  58. if(CMAKE_MAKE_PROGRAM MATCHES make)
  59. execute_process(COMMAND ${CMAKE_MAKE_PROGRAM} no_such_target --version
  60. RESULT_VARIABLE res OUTPUT_VARIABLE out ERROR_VARIABLE out)
  61. if("${res}" STREQUAL "0")
  62. if("${out}" MATCHES "GNU")
  63. set(MAKE_IS_GNU 1)
  64. endif()
  65. endif()
  66. endif()
  67. # some old versions of make simply cannot handle spaces in paths
  68. if (MAKE_IS_GNU OR
  69. CMAKE_MAKE_PROGRAM MATCHES "nmake|gmake|wmake" OR
  70. CMAKE_GENERATOR MATCHES "Visual Studio|XCode|Borland")
  71. set(MAKE_SUPPORTS_SPACES 1)
  72. else()
  73. set(MAKE_SUPPORTS_SPACES 0)
  74. endif()
  75. set(build_generator_args
  76. --build-generator ${CMAKE_GENERATOR}
  77. )
  78. if(CMAKE_GENERATOR_TOOLSET)
  79. list(APPEND build_generator_args
  80. --build-generator-toolset ${CMAKE_GENERATOR_TOOLSET}
  81. )
  82. endif()
  83. set(build_options)
  84. if(CMake_TEST_EXPLICIT_MAKE_PROGRAM)
  85. list(APPEND build_options -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM})
  86. endif()
  87. if(NOT CMake_TEST_EXTERNAL_CMAKE)
  88. add_subdirectory(CMakeLib)
  89. endif()
  90. add_subdirectory(CMakeOnly)
  91. add_subdirectory(RunCMake)
  92. add_subdirectory(FindPackageModeMakefileTest)
  93. if(NOT CMake_TEST_EXTERNAL_CMAKE)
  94. add_subdirectory(CTestTestMemcheck)
  95. endif()
  96. # Collect a list of all test build directories.
  97. set(TEST_BUILD_DIRS)
  98. # Should the long tests be run?
  99. option(CMAKE_RUN_LONG_TESTS
  100. "Should the long tests be run (such as Bootstrap)." ON)
  101. mark_as_advanced(CMAKE_RUN_LONG_TESTS)
  102. if (CMAKE_RUN_LONG_TESTS)
  103. option(CTEST_TEST_CTEST
  104. "Should the tests that run a full sub ctest process be run?"
  105. OFF)
  106. mark_as_advanced(CTEST_TEST_CTEST)
  107. endif ()
  108. # Should tests that use CVS be run?
  109. #
  110. set(do_cvs_tests 0)
  111. if(EXISTS ${CMAKE_ROOT}/Modules/FindCVS.cmake)
  112. find_package(CVS QUIET)
  113. else()
  114. find_program(CVS_EXECUTABLE NAMES cvs)
  115. endif()
  116. if(CVS_EXECUTABLE)
  117. set(do_cvs_tests 1)
  118. endif()
  119. if(do_cvs_tests AND NOT UNIX)
  120. if("${CVS_EXECUTABLE}" MATCHES "cygwin")
  121. set(do_cvs_tests 0)
  122. endif()
  123. endif()
  124. # Should CPack tests be run? By default, yes, but...
  125. #
  126. # Disable packaging test on Apple 10.3 and below. PackageMaker starts
  127. # DiskManagementTool as root and disowns it
  128. # (http://lists.apple.com/archives/installer-dev/2005/Jul/msg00005.html).
  129. # It is left holding open pipe handles and preventing ProcessUNIX from
  130. # detecting end-of-data even after its immediate child exits. Then
  131. # the test hangs until it times out and is killed. This is a
  132. # well-known bug in kwsys process execution that I would love to get
  133. # time to fix.
  134. #
  135. option(CTEST_TEST_CPACK
  136. "Should the tests that use '--build-target package' be run?"
  137. ON)
  138. mark_as_advanced(CTEST_TEST_CPACK)
  139. set(CTEST_TEST_OSX_ARCH 0)
  140. if(APPLE)
  141. execute_process(
  142. COMMAND sw_vers -productVersion
  143. OUTPUT_VARIABLE OSX_VERSION
  144. OUTPUT_STRIP_TRAILING_WHITESPACE
  145. )
  146. if(OSX_VERSION MATCHES "^10\\.[0123]" OR OSX_VERSION MATCHES "ProductVersion:\t10\\.[0123]")
  147. message(STATUS "Forcing CTEST_TEST_CPACK=OFF on OSX < 10.4")
  148. message(STATUS "OSX_VERSION='${OSX_VERSION}'")
  149. set(CTEST_TEST_CPACK OFF)
  150. else()
  151. set(CTEST_TEST_OSX_ARCH 1)
  152. endif()
  153. endif()
  154. # Use 1500 or CTEST_TEST_TIMEOUT for long test timeout value,
  155. # whichever is greater.
  156. set(CMAKE_LONG_TEST_TIMEOUT 1500)
  157. if(CTEST_TEST_TIMEOUT)
  158. set(CMAKE_LONG_TEST_TIMEOUT ${CTEST_TEST_TIMEOUT})
  159. endif()
  160. if(CMAKE_LONG_TEST_TIMEOUT LESS 1500)
  161. set(CMAKE_LONG_TEST_TIMEOUT 1500)
  162. endif()
  163. add_test(NAME CMake.Copyright
  164. COMMAND cmake -P ${CMAKE_CURRENT_SOURCE_DIR}/CMakeCopyright.cmake)
  165. # add a bunch of standard build-and-test style tests
  166. ADD_TEST_MACRO(CommandLineTest CommandLineTest)
  167. ADD_TEST_MACRO(FindPackageTest FindPackageTest)
  168. ADD_TEST_MACRO(FindModulesExecuteAll FindModulesExecuteAll)
  169. ADD_TEST_MACRO(StringFileTest StringFileTest)
  170. ADD_TEST_MACRO(TryCompile TryCompile)
  171. ADD_TEST_MACRO(TarTest TarTest)
  172. ADD_TEST_MACRO(SystemInformation SystemInformation)
  173. ADD_TEST_MACRO(MathTest MathTest)
  174. ADD_TEST_MACRO(CompileFeatures CompileFeatures)
  175. ADD_TEST_MACRO(CMakeCommands.target_compile_features target_compile_features)
  176. # assume no resources building to test
  177. set(TEST_RESOURCES FALSE)
  178. # for windows and cygwin assume we have resources
  179. if(WIN32 OR CYGWIN)
  180. set(TEST_RESOURCES TRUE)
  181. endif()
  182. # for borland and watcom there is no resource support
  183. if("${CMAKE_GENERATOR}" MATCHES "WMake" OR
  184. "${CMAKE_GENERATOR}" MATCHES "Borland")
  185. set(TEST_RESOURCES FALSE)
  186. endif()
  187. if(TEST_RESOURCES)
  188. ADD_TEST_MACRO(VSResource VSResource)
  189. endif()
  190. ADD_TEST_MACRO(Simple Simple)
  191. ADD_TEST_MACRO(PreOrder PreOrder)
  192. ADD_TEST_MACRO(MissingSourceFile MissingSourceFile)
  193. set_tests_properties(MissingSourceFile PROPERTIES
  194. PASS_REGULAR_EXPRESSION "CMake Error at CMakeLists.txt:3 \\(add_executable\\):[ \r\n]*Cannot find source file:[ \r\n]*DoesNotExist/MissingSourceFile.c")
  195. if(CMAKE_Fortran_COMPILER)
  196. ADD_TEST_MACRO(FortranOnly FortranOnly)
  197. endif()
  198. # test Visual Studio GNU Fortran mixing with cmake_add_fortran_subdirectory
  199. # run this project if we have a working fortran compiler or
  200. # the test is enabled with CMAKE_TEST_CMAKE_ADD_FORTRAN cache variable.
  201. # If you enable the test, CMake should find the MinGW fortran install,
  202. # or in some cases you might need to set the PATH so that cmake can find
  203. # the gfortran from mingw.
  204. if(CMAKE_Fortran_COMPILER OR CMAKE_TEST_CMAKE_ADD_FORTRAN)
  205. set(CMAKE_SKIP_VSGNUFortran FALSE)
  206. # disable test for apple builds using ifort if they are building
  207. # more than one architecture, as ifort does not support that.
  208. if(APPLE AND (CMAKE_Fortran_COMPILER MATCHES ifort))
  209. list(LENGTH CMAKE_OSX_ARCHITECTURES len)
  210. if("${len}" GREATER 1)
  211. message(STATUS "Skip VSGNUFortran for ifort dual cpu mac build")
  212. set(CMAKE_SKIP_VSGNUFortran TRUE)
  213. endif()
  214. endif()
  215. if((CMAKE_C_COMPILER MATCHES lsb)
  216. AND (CMAKE_Fortran_COMPILER MATCHES ifort))
  217. message(STATUS "Skip VSGNUFortran for ifort and lsb compilers")
  218. set(CMAKE_SKIP_VSGNUFortran TRUE)
  219. endif()
  220. if(NOT CMAKE_SKIP_VSGNUFortran)
  221. ADD_TEST_MACRO(VSGNUFortran ${CMAKE_COMMAND} -P runtest.cmake)
  222. endif()
  223. endif()
  224. ADD_TEST_MACRO(COnly COnly)
  225. ADD_TEST_MACRO(CxxOnly CxxOnly)
  226. ADD_TEST_MACRO(IPO COnly/COnly)
  227. ADD_TEST_MACRO(OutDir runtime/OutDir)
  228. ADD_TEST_MACRO(ObjectLibrary UseCshared)
  229. ADD_TEST_MACRO(NewlineArgs NewlineArgs)
  230. ADD_TEST_MACRO(SetLang SetLang)
  231. ADD_TEST_MACRO(EmptyProperty EmptyProperty)
  232. ADD_TEST_MACRO(ExternalOBJ ExternalOBJ)
  233. if(NOT CMake_TEST_EXTERNAL_CMAKE)
  234. ADD_TEST_MACRO(LoadCommand LoadedCommand)
  235. endif()
  236. ADD_TEST_MACRO(LinkDirectory bin/LinkDirectory)
  237. ADD_TEST_MACRO(LinkLanguage LinkLanguage)
  238. ADD_TEST_MACRO(LinkLine LinkLine)
  239. ADD_TEST_MACRO(MacroTest miniMacroTest)
  240. ADD_TEST_MACRO(FunctionTest miniFunctionTest)
  241. ADD_TEST_MACRO(ReturnTest ReturnTest)
  242. ADD_TEST_MACRO(Properties Properties)
  243. ADD_TEST_MACRO(Assembler HelloAsm)
  244. ADD_TEST_MACRO(SourceGroups SourceGroups)
  245. ADD_TEST_MACRO(Preprocess Preprocess)
  246. set(ExportImport_BUILD_OPTIONS -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM})
  247. ADD_TEST_MACRO(ExportImport ExportImport)
  248. ADD_TEST_MACRO(Unset Unset)
  249. ADD_TEST_MACRO(PolicyScope PolicyScope)
  250. ADD_TEST_MACRO(EmptyLibrary EmptyLibrary)
  251. ADD_TEST_MACRO(CompileDefinitions CompileDefinitions)
  252. ADD_TEST_MACRO(CompileOptions CompileOptions)
  253. ADD_TEST_MACRO(CompatibleInterface CompatibleInterface)
  254. ADD_TEST_MACRO(AliasTarget AliasTarget)
  255. ADD_TEST_MACRO(StagingPrefix StagingPrefix)
  256. ADD_TEST_MACRO(InterfaceLibrary InterfaceLibrary)
  257. if (CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]")
  258. set(ConfigSources_BUILD_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
  259. ADD_TEST_MACRO(ConfigSources ConfigSources)
  260. endif()
  261. ADD_TEST_MACRO(SourcesProperty SourcesProperty)
  262. if(CMAKE_CXX_COMPILER_ID STREQUAL GNU
  263. AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.6)
  264. set(runCxxDialectTest 1)
  265. endif()
  266. if(CMAKE_CXX_COMPILER_ID STREQUAL Clang
  267. AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 2.9)
  268. if(NOT APPLE OR POLICY CMP0025)
  269. set(runCxxDialectTest 1)
  270. endif()
  271. endif()
  272. if(runCxxDialectTest)
  273. ADD_TEST_MACRO(CxxDialect CxxDialect)
  274. endif()
  275. set_tests_properties(EmptyLibrary PROPERTIES
  276. PASS_REGULAR_EXPRESSION "CMake Error: CMake can not determine linker language for target: test")
  277. ADD_TEST_MACRO(CrossCompile CrossCompile)
  278. set_tests_properties(CrossCompile PROPERTIES
  279. PASS_REGULAR_EXPRESSION "TRY_RUN.. invoked in cross-compiling mode")
  280. if("${CMAKE_GENERATOR}" MATCHES "Make")
  281. ADD_TEST_MACRO(Policy0002 Policy0002)
  282. endif()
  283. if(CTEST_TEST_OSX_ARCH)
  284. ADD_TEST_MACRO(Architecture Architecture)
  285. set_tests_properties(Architecture PROPERTIES
  286. PASS_REGULAR_EXPRESSION "(file is not of required architecture|does not match cputype|not the architecture being linked)")
  287. endif()
  288. list(APPEND TEST_BUILD_DIRS ${CMake_TEST_INSTALL_PREFIX})
  289. if(NOT QT4_FOUND)
  290. find_package(Qt4 QUIET)
  291. endif()
  292. if(QT4_FOUND)
  293. # test whether the Qt4 which has been found works, on some machines
  294. # which run nightly builds there were errors like "wrong file format"
  295. # for libQtCore.so. So first check it works, and only if it does add
  296. # the automoc test.
  297. include(CheckCXXSourceCompiles)
  298. set(_save_CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES}")
  299. set(_save_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
  300. set(CMAKE_REQUIRED_INCLUDES ${QT_INCLUDES})
  301. set(CMAKE_REQUIRED_LIBRARIES ${QT_QTCORE_LIBRARIES})
  302. CHECK_CXX_SOURCE_COMPILES("#include <QCoreApplication>\n int main() {return (qApp == 0 ? 0 : 1); }\n"
  303. QT4_WORKS)
  304. set(CMAKE_REQUIRED_INCLUDES "${_save_CMAKE_REQUIRED_INCLUDES}")
  305. set(CMAKE_REQUIRED_LIBRARIES "${_save_CMAKE_REQUIRED_LIBRARIES}")
  306. endif()
  307. # run test for BundleUtilities on supported platforms/compilers
  308. if(MSVC OR
  309. MINGW OR
  310. CMAKE_SYSTEM_NAME MATCHES "Linux" OR
  311. CMAKE_SYSTEM_NAME MATCHES "Darwin")
  312. if(NOT "${CMAKE_GENERATOR}" STREQUAL "Watcom WMake")
  313. add_test(BundleUtilities ${CMAKE_CTEST_COMMAND}
  314. --build-and-test
  315. "${CMake_SOURCE_DIR}/Tests/BundleUtilities"
  316. "${CMake_BINARY_DIR}/Tests/BundleUtilities"
  317. ${build_generator_args}
  318. --build-project BundleUtilities
  319. --build-options ${build_options}
  320. )
  321. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BundleUtilities")
  322. # run test for DeployQt4 on supported platforms/compilers (which depends on BundleUtilities)
  323. # this test also depends on the existence of the standard qtiff plugin
  324. if(QT4_WORKS AND QT_QTSQL_FOUND)
  325. add_test(Qt4Deploy ${CMAKE_CTEST_COMMAND}
  326. --build-and-test
  327. "${CMake_SOURCE_DIR}/Tests/Qt4Deploy"
  328. "${CMake_BINARY_DIR}/Tests/Qt4Deploy"
  329. ${build_generator_args}
  330. --build-project Qt4Deploy
  331. --build-options ${build_options}
  332. -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
  333. -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}
  334. )
  335. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4Deploy")
  336. endif()
  337. endif()
  338. endif()
  339. set(CMAKE_BUILD_TEST_SOURCE_DIR "${CMake_SOURCE_DIR}/Tests/COnly")
  340. set(CMAKE_BUILD_TEST_BINARY_DIR "${CMake_BINARY_DIR}/Tests/CMakeBuildCOnly")
  341. set(CMAKE_BUILD_TEST_EXE COnly)
  342. configure_file("${CMake_SOURCE_DIR}/Tests/CMakeBuildTest.cmake.in"
  343. "${CMake_BINARY_DIR}/Tests/CMakeBuildTest.cmake" @ONLY)
  344. add_test(CMakeBuildTest ${CMAKE_CMAKE_COMMAND} -P
  345. "${CMake_BINARY_DIR}/Tests/CMakeBuildTest.cmake")
  346. list(APPEND TEST_BUILD_DIRS ${CMAKE_BUILD_TEST_BINARY_DIR})
  347. # now do it again for a project that has two project commands
  348. set(CMAKE_BUILD_TEST_SOURCE_DIR "${CMake_SOURCE_DIR}/Tests/DoubleProject")
  349. set(CMAKE_BUILD_TEST_BINARY_DIR "${CMake_BINARY_DIR}/Tests/DoubleProject")
  350. set(CMAKE_BUILD_TEST_EXE just_silly)
  351. configure_file("${CMake_SOURCE_DIR}/Tests/CMakeBuildTest.cmake.in"
  352. "${CMake_BINARY_DIR}/Tests/CMakeBuildDoubleProjectTest.cmake" @ONLY)
  353. add_test(CMakeDoubleProject ${CMAKE_CMAKE_COMMAND} -P
  354. "${CMake_BINARY_DIR}/Tests/CMakeBuildDoubleProjectTest.cmake")
  355. list(APPEND TEST_BUILD_DIRS ${CMAKE_BUILD_TEST_BINARY_DIR})
  356. ADD_TEST_MACRO(Module.CheckTypeSize CheckTypeSize)
  357. add_test(Module.ExternalData ${CMAKE_CTEST_COMMAND}
  358. --build-and-test
  359. "${CMake_SOURCE_DIR}/Tests/Module/ExternalData"
  360. "${CMake_BINARY_DIR}/Tests/Module/ExternalData"
  361. ${build_generator_args}
  362. --build-project ExternalDataTest
  363. --build-noclean
  364. --force-new-ctest-process
  365. --build-options ${build_options}
  366. -DMAKE_SUPPORTS_SPACES=${MAKE_SUPPORTS_SPACES}
  367. --test-command ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE} -V
  368. )
  369. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Module/ExternalData")
  370. ADD_TEST_MACRO(Module.GenerateExportHeader GenerateExportHeader)
  371. ADD_TEST_MACRO(Module.FindDependency FindDependency)
  372. if (APPLE OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
  373. include(CheckCXXCompilerFlag)
  374. check_cxx_compiler_flag(-fPIE run_pic_test)
  375. else()
  376. if (CMAKE_CXX_COMPILER_ID MATCHES "PGI"
  377. OR CMAKE_CXX_COMPILER_ID MATCHES "PathScale"
  378. OR CMAKE_SYSTEM_NAME MATCHES "IRIX64"
  379. OR CMAKE_CXX_COMPILER_ID MATCHES "Intel")
  380. set(run_pic_test 0)
  381. else()
  382. set(run_pic_test 1)
  383. endif()
  384. endif()
  385. if (run_pic_test)
  386. ADD_TEST_MACRO(PositionIndependentTargets PositionIndependentTargets)
  387. endif()
  388. if((CMAKE_CXX_COMPILER_ID MATCHES "GNU") AND
  389. (NOT "${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 4.2) AND
  390. (CMAKE_SYSTEM_NAME MATCHES "Linux"))
  391. include(CheckCXXCompilerFlag)
  392. check_cxx_compiler_flag(
  393. -fvisibility-inlines-hidden run_inlines_hidden_test)
  394. endif()
  395. if(run_inlines_hidden_test)
  396. add_test(VisibilityInlinesHidden ${CMAKE_CTEST_COMMAND}
  397. --build-and-test
  398. "${CMake_SOURCE_DIR}/Tests/VisibilityInlinesHidden"
  399. "${CMake_BINARY_DIR}/Tests/VisibilityInlinesHidden"
  400. ${build_generator_args}
  401. --build-project VisibilityInlinesHidden
  402. --build-options ${build_options}
  403. )
  404. list(APPEND TEST_BUILD_DIRS
  405. "${CMake_BINARY_DIR}/Tests/VisibilityInlinesHidden"
  406. )
  407. endif()
  408. add_test(LinkFlags-prepare
  409. ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE}
  410. --build-and-test
  411. "${CMake_SOURCE_DIR}/Tests/LinkFlags"
  412. "${CMake_BINARY_DIR}/Tests/LinkFlags"
  413. ${build_generator_args}
  414. --build-project LinkFlags
  415. --build-target LinkFlags
  416. --build-options ${build_options}
  417. -DTEST_CONFIG=\${CTEST_CONFIGURATION_TYPE}
  418. )
  419. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LinkFlags")
  420. macro(ADD_LINK_FLAGS_TEST name depends)
  421. add_test(LinkFlags-${name}
  422. ${CMAKE_CMAKE_COMMAND} --build "${CMake_BINARY_DIR}/Tests/LinkFlags"
  423. --target LinkFlags_${name} --config \${CTEST_CONFIGURATION_TYPE}
  424. )
  425. set_tests_properties(LinkFlags-${name} PROPERTIES
  426. PASS_REGULAR_EXPRESSION "BADFLAG" DEPENDS LinkFlags-${depends})
  427. endmacro()
  428. ADD_LINK_FLAGS_TEST(lib prepare)
  429. ADD_LINK_FLAGS_TEST(dll lib)
  430. ADD_LINK_FLAGS_TEST(mod dll)
  431. ADD_LINK_FLAGS_TEST(exe mod)
  432. ADD_LINK_FLAGS_TEST(lib_config exe)
  433. ADD_LINK_FLAGS_TEST(dll_config lib_config)
  434. ADD_LINK_FLAGS_TEST(mod_config dll_config)
  435. ADD_LINK_FLAGS_TEST(exe_config mod_config)
  436. ADD_LINK_FLAGS_TEST(lib_flags exe_config)
  437. ADD_LINK_FLAGS_TEST(dll_flags lib_flags)
  438. ADD_LINK_FLAGS_TEST(mod_flags dll_flags)
  439. ADD_LINK_FLAGS_TEST(exe_flags mod_flags)
  440. ADD_LINK_FLAGS_TEST(lib_flags_config exe_flags)
  441. ADD_LINK_FLAGS_TEST(dll_flags_config lib_flags_config)
  442. ADD_LINK_FLAGS_TEST(mod_flags_config dll_flags_config)
  443. ADD_LINK_FLAGS_TEST(exe_flags_config mod_flags_config)
  444. # If we are running right now with a UnixMakefiles based generator,
  445. # build the "Simple" test with the ExtraGenerators, if available
  446. # This doesn't test whether the generated project files work (unfortunately),
  447. # mainly it tests that cmake doesn't crash when generating these project files.
  448. if(${CMAKE_GENERATOR} MATCHES "Unix Makefiles" OR ${CMAKE_GENERATOR} MATCHES "KDevelop")
  449. # check which generators we have
  450. execute_process(COMMAND ${CMAKE_CMAKE_COMMAND} --help
  451. OUTPUT_VARIABLE cmakeOutput ERROR_VARIABLE cmakeOutput)
  452. # check for the Eclipse generator
  453. if ("${cmakeOutput}" MATCHES Eclipse)
  454. add_test(Simple_EclipseGenerator ${CMAKE_CTEST_COMMAND}
  455. --build-and-test
  456. "${CMake_SOURCE_DIR}/Tests/Simple"
  457. "${CMake_BINARY_DIR}/Tests/Simple_EclipseGenerator"
  458. --build-two-config
  459. --build-generator "Eclipse CDT4 - Unix Makefiles"
  460. --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
  461. --build-project Simple
  462. --build-options ${build_options}
  463. --test-command Simple)
  464. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Simple_EclipseGenerator")
  465. endif ()
  466. # check for the CodeBlocks generator
  467. if ("${cmakeOutput}" MATCHES CodeBlocks)
  468. add_test(Simple_CodeBlocksGenerator ${CMAKE_CTEST_COMMAND}
  469. --build-and-test
  470. "${CMake_SOURCE_DIR}/Tests/Simple"
  471. "${CMake_BINARY_DIR}/Tests/Simple_CodeBlocksGenerator"
  472. --build-two-config
  473. --build-generator "CodeBlocks - Unix Makefiles"
  474. --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
  475. --build-project Simple
  476. --build-options ${build_options}
  477. --test-command Simple)
  478. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Simple_CodeBlocksGenerator")
  479. endif ()
  480. # check for the KDevelop3 generator
  481. if ("${cmakeOutput}" MATCHES KDevelop3)
  482. add_test(Simple_KDevelop3Generator ${CMAKE_CTEST_COMMAND}
  483. --build-and-test
  484. "${CMake_SOURCE_DIR}/Tests/Simple"
  485. "${CMake_BINARY_DIR}/Tests/Simple_KDevelop3Generator"
  486. --build-two-config
  487. --build-generator "KDevelop3 - Unix Makefiles"
  488. --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
  489. --build-project Simple
  490. --build-options ${build_options}
  491. --test-command Simple)
  492. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Simple_KDevelop3Generator")
  493. endif ()
  494. endif()
  495. # test for correct sub-project generation
  496. # not implemented in VS 6, VS 7.0, Xcode, or Ninja
  497. if(NOT CMAKE_GENERATOR MATCHES "Visual Studio [67]$|Xcode|Ninja")
  498. # run cmake and configure all of SubProject
  499. # but only build the independent executable car
  500. add_test(SubProject ${CMAKE_CTEST_COMMAND}
  501. --build-and-test
  502. "${CMake_SOURCE_DIR}/Tests/SubProject"
  503. "${CMake_BINARY_DIR}/Tests/SubProject"
  504. --build-project SubProject
  505. ${build_generator_args}
  506. --build-target car
  507. --build-options ${build_options}
  508. --test-command car
  509. )
  510. # For stage 2, do not run cmake again.
  511. # Then build the foo sub project which should build
  512. # the bar library which should be referenced because
  513. # foo links to the static library bar, but bar is not
  514. # directly in the foo sub project
  515. if(CMake_TEST_EXPLICIT_MAKE_PROGRAM)
  516. set(SubProject-Stage2_BUILD_MAKEPROGRAM
  517. --build-makeprogram ${CMake_TEST_EXPLICIT_MAKE_PROGRAM}
  518. )
  519. endif()
  520. add_test(SubProject-Stage2 ${CMAKE_CTEST_COMMAND}
  521. --build-and-test
  522. "${CMake_SOURCE_DIR}/Tests/SubProject/foo"
  523. "${CMake_BINARY_DIR}/Tests/SubProject/foo"
  524. --build-generator ${CMAKE_GENERATOR}
  525. --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
  526. ${SubProject-Stage2_BUILD_MAKEPROGRAM}
  527. --build-nocmake
  528. --build-project foo
  529. --build-target foo
  530. --build-exe-dir "${CMake_BINARY_DIR}/Tests/SubProject/foo"
  531. --build-options ${build_options}
  532. --test-command foo
  533. )
  534. set_tests_properties ( SubProject-Stage2 PROPERTIES DEPENDS SubProject)
  535. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SubProject")
  536. endif()
  537. # macro to add a test that will build a nightly release
  538. # of CMake for given platform using the release scripts
  539. macro(ADD_NIGHTLY_BUILD_TEST name script)
  540. set(_TEST_DIR "${CMake_BINARY_DIR}/Tests/${name}")
  541. file(MAKE_DIRECTORY "${_TEST_DIR}")
  542. file(WRITE "${_TEST_DIR}/nightly-cmake.sh"
  543. "cd ${_TEST_DIR}
  544. ${CMake_BINARY_DIR}/bin/cmake -DCMAKE_CREATE_VERSION=nightly -P ${CMake_SOURCE_DIR}/Utilities/Release/${script}
  545. ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release/upload_release.cmake
  546. ")
  547. add_test(${name} /bin/sh ${_TEST_DIR}/nightly-cmake.sh)
  548. if(COMMAND SET_TESTS_PROPERTIES AND COMMAND GET_TEST_PROPERTY)
  549. set_tests_properties (${name} PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT})
  550. endif()
  551. endmacro()
  552. if(CMAKE_BUILD_NIGHTLY_RELEASES)
  553. ADD_NIGHTLY_BUILD_TEST(CMakeNightlyWindows
  554. dash2win64_release.cmake)
  555. ADD_NIGHTLY_BUILD_TEST(CMakeNightlyMac
  556. dashmacmini2_release.cmake)
  557. ADD_NIGHTLY_BUILD_TEST(CMakeNightlyMac64
  558. dashmacmini5_release.cmake)
  559. ADD_NIGHTLY_BUILD_TEST(CMakeNightlyLinux
  560. magrathea_release.cmake)
  561. endif()
  562. # add tests with more complex invocations
  563. add_test(Framework ${CMAKE_CTEST_COMMAND}
  564. --build-and-test
  565. "${CMake_SOURCE_DIR}/Tests/Framework"
  566. "${CMake_BINARY_DIR}/Tests/Framework"
  567. --build-two-config
  568. ${build_generator_args}
  569. --build-project Framework
  570. --build-options ${build_options}
  571. "-DCMAKE_INSTALL_PREFIX:PATH=${CMake_BINARY_DIR}/Tests/Framework/Install"
  572. --test-command bar)
  573. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Framework")
  574. add_test(TargetName ${CMAKE_CTEST_COMMAND}
  575. --build-and-test
  576. "${CMake_SOURCE_DIR}/Tests/TargetName"
  577. "${CMake_BINARY_DIR}/Tests/TargetName"
  578. --build-two-config
  579. ${build_generator_args}
  580. --build-project TargetName
  581. --build-options ${build_options}
  582. --test-command ${CMAKE_CMAKE_COMMAND} -E compare_files
  583. ${CMake_SOURCE_DIR}/Tests/TargetName/scripts/hello_world
  584. ${CMake_BINARY_DIR}/Tests/TargetName/scripts/hello_world)
  585. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/TargetName")
  586. add_test(LibName ${CMAKE_CTEST_COMMAND}
  587. --build-and-test
  588. "${CMake_SOURCE_DIR}/Tests/LibName"
  589. "${CMake_BINARY_DIR}/Tests/LibName"
  590. --build-two-config
  591. ${build_generator_args}
  592. --build-project LibName
  593. --build-exe-dir "${CMake_BINARY_DIR}/Tests/LibName/lib"
  594. --build-options ${build_options}
  595. --test-command foobar
  596. )
  597. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LibName")
  598. add_test(CustComDepend ${CMAKE_CTEST_COMMAND}
  599. --build-and-test
  600. "${CMake_SOURCE_DIR}/Tests/CustComDepend"
  601. "${CMake_BINARY_DIR}/Tests/CustComDepend"
  602. --build-two-config
  603. ${build_generator_args}
  604. --build-project CustComDepend
  605. --build-exe-dir "${CMake_BINARY_DIR}/Tests/CustComDepend/bin"
  606. --build-options ${build_options}
  607. --test-command foo bar.c
  608. )
  609. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CustComDepend")
  610. add_test(ArgumentExpansion ${CMAKE_CTEST_COMMAND}
  611. --build-and-test
  612. "${CMake_SOURCE_DIR}/Tests/ArgumentExpansion"
  613. "${CMake_BINARY_DIR}/Tests/ArgumentExpansion"
  614. ${build_generator_args}
  615. --build-project ArgumentExpansion
  616. --build-exe-dir "${CMake_BINARY_DIR}/Tests/ArgumentExpansion/bin"
  617. --build-options ${build_options}
  618. )
  619. set_tests_properties(ArgumentExpansion PROPERTIES
  620. FAIL_REGULAR_EXPRESSION "Unexpected: ")
  621. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ArgumentExpansion")
  622. add_test(GeneratorExpression ${CMAKE_CTEST_COMMAND}
  623. --build-and-test
  624. "${CMake_SOURCE_DIR}/Tests/GeneratorExpression"
  625. "${CMake_BINARY_DIR}/Tests/GeneratorExpression"
  626. ${build_generator_args}
  627. --build-project GeneratorExpression
  628. --build-options ${build_options}
  629. -DCMAKE_BUILD_TYPE=\${CTEST_CONFIGURATION_TYPE}
  630. --test-command ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE} -V
  631. )
  632. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/GeneratorExpression")
  633. add_test(CustomCommand ${CMAKE_CTEST_COMMAND}
  634. --build-and-test
  635. "${CMake_SOURCE_DIR}/Tests/CustomCommand"
  636. "${CMake_BINARY_DIR}/Tests/CustomCommand"
  637. --build-two-config
  638. ${build_generator_args}
  639. --build-project CustomCommand
  640. --build-exe-dir "${CMake_BINARY_DIR}/Tests/CustomCommand/bin"
  641. --build-options ${build_options}
  642. --test-command CustomCommand
  643. )
  644. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CustomCommand")
  645. ADD_TEST_MACRO(EmptyDepends ${CMAKE_CTEST_COMMAND})
  646. add_test(CustomCommandWorkingDirectory ${CMAKE_CTEST_COMMAND}
  647. --build-and-test
  648. "${CMake_SOURCE_DIR}/Tests/CustomCommandWorkingDirectory"
  649. "${CMake_BINARY_DIR}/Tests/CustomCommandWorkingDirectory"
  650. --build-two-config
  651. ${build_generator_args}
  652. --build-project TestWorkingDir
  653. --build-options ${build_options}
  654. --test-command working
  655. )
  656. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CustomCommandWorkingDirectory")
  657. #add_test(SimpleExclude ${CMAKE_CTEST_COMMAND}
  658. # --build-and-test
  659. # "${CMake_SOURCE_DIR}/Tests/SimpleExclude"
  660. # "${CMake_BINARY_DIR}/Tests/SimpleExclude"
  661. # ${build_generator_args}
  662. # --build-project SimpleExclude
  663. # --build-two-config
  664. # --build-options ${build_options}
  665. # --test-command t4
  666. #--test-command "${CMAKE_COMMAND}"
  667. #"-DCONFIGURATION=\${CTEST_CONFIGURATION_TYPE}"
  668. #-P "${CMake_BINARY_DIR}/Tests/SimpleExclude/run.cmake"
  669. #)
  670. # add_test(SameName ${CMAKE_CTEST_COMMAND}
  671. # --build-and-test
  672. # "${CMake_SOURCE_DIR}/Tests/SameName"
  673. # "${CMake_BINARY_DIR}/Tests/SameName"
  674. # ${build_generator_args}
  675. # --build-project SameName
  676. # --build-two-config
  677. # --build-options ${build_options}
  678. # --test-command
  679. # "${CMake_BINARY_DIR}/Tests/SameName/Exe1/mytest2")
  680. add_test(OutOfSource ${CMAKE_CTEST_COMMAND}
  681. --build-and-test
  682. "${CMake_SOURCE_DIR}/Tests/OutOfSource"
  683. "${CMake_BINARY_DIR}/Tests/OutOfSource"
  684. ${build_generator_args}
  685. --build-project OutOfSource
  686. --build-two-config
  687. --build-options ${build_options}
  688. --test-command
  689. "${CMake_BINARY_DIR}/Tests/OutOfSource/SubDir/OutOfSourceSubdir/simple")
  690. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/OutOfSource")
  691. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/OutOfSourceDeep")
  692. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/OutOfBinary")
  693. add_test(BuildDepends ${CMAKE_CTEST_COMMAND}
  694. --build-and-test
  695. "${CMake_SOURCE_DIR}/Tests/BuildDepends"
  696. "${CMake_BINARY_DIR}/Tests/BuildDepends"
  697. ${build_generator_args}
  698. --build-project BuildDepends
  699. --build-options ${build_options}
  700. )
  701. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BuildDepends")
  702. set(SimpleInstallInstallDir
  703. "${CMake_BINARY_DIR}/Tests/SimpleInstall/InstallDirectory")
  704. add_test(SimpleInstall ${CMAKE_CTEST_COMMAND}
  705. --build-and-test
  706. "${CMake_SOURCE_DIR}/Tests/SimpleInstall"
  707. "${CMake_BINARY_DIR}/Tests/SimpleInstall"
  708. ${build_generator_args}
  709. --build-project TestSimpleInstall
  710. --build-two-config
  711. --build-options ${build_options}
  712. "-DCMAKE_INSTALL_PREFIX:PATH=${SimpleInstallInstallDir}"
  713. "-DCTEST_TEST_CPACK:BOOL=${CTEST_TEST_CPACK}"
  714. --test-command ${SimpleInstallInstallDir}/MyTest/bin/SimpleInstExe)
  715. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SimpleInstall")
  716. add_test(SimpleInstall-Stage2 ${CMAKE_CTEST_COMMAND}
  717. --build-and-test
  718. "${CMake_SOURCE_DIR}/Tests/SimpleInstallS2"
  719. "${CMake_BINARY_DIR}/Tests/SimpleInstallS2"
  720. ${build_generator_args}
  721. --build-project TestSimpleInstall
  722. --build-two-config
  723. --build-options ${build_options}
  724. "-DCMAKE_INSTALL_PREFIX:PATH=${SimpleInstallInstallDir}"
  725. "-DSTAGE2:BOOL=1"
  726. --test-command ${SimpleInstallInstallDir}/MyTest/bin/SimpleInstExeS2)
  727. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SimpleInstallS2")
  728. set(MissingInstallInstallDir
  729. "${CMake_BINARY_DIR}/Tests/MissingInstall/InstallDirectory")
  730. add_test(MissingInstall ${CMAKE_CTEST_COMMAND}
  731. --build-and-test
  732. "${CMake_SOURCE_DIR}/Tests/MissingInstall"
  733. "${CMake_BINARY_DIR}/Tests/MissingInstall"
  734. ${build_generator_args}
  735. --build-project TestMissingInstall
  736. --build-two-config
  737. --build-options ${build_options}
  738. "-DCMAKE_INSTALL_PREFIX:PATH=${MissingInstallInstallDir}")
  739. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/MissingInstall")
  740. # By default, run the CPackComponents test if the CTEST_TEST_CPACK
  741. # option is ON:
  742. #
  743. set(CTEST_RUN_CPackComponents ${CTEST_TEST_CPACK})
  744. set(CTEST_package_X11_TEST ${CTEST_TEST_CPACK})
  745. set(CTEST_RUN_CPackComponentsForAll ${CTEST_TEST_CPACK})
  746. if (CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT CMAKE_CURRENT_BINARY_DIR MATCHES " ")
  747. find_program(RPMBUILD NAMES rpmbuild)
  748. endif()
  749. # Do not try to build RPM
  750. if (NOT RPMBUILD)
  751. set(CPACK_BINARY_RPM OFF)
  752. endif()
  753. find_program(NSIS_MAKENSIS_EXECUTABLE NAMES makensis
  754. PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS]
  755. DOC "makensis program location"
  756. )
  757. # But on Windows, only run the CPackComponents test if the NSIS
  758. # installer builder is available:
  759. #
  760. if(WIN32)
  761. if(NSIS_MAKENSIS_EXECUTABLE)
  762. set(CTEST_RUN_CPackComponents ON)
  763. else()
  764. set(CTEST_RUN_CPackComponents OFF)
  765. set(CTEST_package_X11_TEST OFF)
  766. endif()
  767. endif()
  768. # On Windows run the CPackWiXGenerator test
  769. # if the WiX Toolset seems to be available
  770. if(WIN32)
  771. file(TO_CMAKE_PATH "$ENV{WIX}" WIX_ROOT)
  772. find_program(WIX_LIGHT_EXECUTABLE light
  773. PATHS "${WIX_ROOT}/bin"
  774. DOC "WiX Toolset light.exe location")
  775. if(WIX_LIGHT_EXECUTABLE)
  776. add_test(CPackWiXGenerator ${CMAKE_CTEST_COMMAND}
  777. -C \${CTEST_CONFIGURATION_TYPE}
  778. --build-and-test
  779. "${CMake_SOURCE_DIR}/Tests/CPackWiXGenerator"
  780. "${CMake_BINARY_DIR}/Tests/CPackWiXGenerator"
  781. ${build_generator_args}
  782. --build-project CPackWiXGenerator
  783. --build-options ${build_options}
  784. --test-command ${CMAKE_CMAKE_COMMAND}
  785. "-DCPackWiXGenerator_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/CPackWiXGenerator"
  786. "-Dconfig=\${CTEST_CONFIGURATION_TYPE}"
  787. -P "${CMake_SOURCE_DIR}/Tests/CPackWiXGenerator/RunCPackVerifyResult.cmake")
  788. endif()
  789. endif()
  790. if(CTEST_RUN_CPackComponents)
  791. set(CPackComponents_BUILD_OPTIONS)
  792. if(APPLE)
  793. set(CPackComponents_BUILD_OPTIONS -DCPACK_BINARY_DRAGNDROP:BOOL=ON)
  794. endif()
  795. if(NSIS_MAKENSIS_EXECUTABLE)
  796. set(CPackComponents_BUILD_OPTIONS ${CPackComponents_BUILD_OPTIONS}
  797. -DCPACK_BINARY_NSIS:BOOL=ON)
  798. endif()
  799. add_test(CPackComponents ${CMAKE_CTEST_COMMAND}
  800. --build-and-test
  801. "${CMake_SOURCE_DIR}/Tests/CPackComponents"
  802. "${CMake_BINARY_DIR}/Tests/CPackComponents"
  803. ${build_generator_args}
  804. --build-project CPackComponents
  805. --build-two-config
  806. --build-target package
  807. --build-options ${build_options}
  808. -DCPACK_BINARY_DEB:BOOL=${CPACK_BINARY_DEB}
  809. -DCPACK_BINARY_RPM:BOOL=${CPACK_BINARY_RPM}
  810. ${CPackComponents_BUILD_OPTIONS}
  811. --graphviz=CPackComponents.dot
  812. --test-command ${CMAKE_CMAKE_COMMAND}
  813. "-DCPackComponents_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/CPackComponents"
  814. -P "${CMake_SOURCE_DIR}/Tests/CPackComponents/VerifyResult.cmake")
  815. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CPackComponents")
  816. endif()
  817. if(CTEST_RUN_CPackComponentsForAll)
  818. # Check whether if rpmbuild command is found
  819. # before adding RPM tests
  820. find_program(RPMBUILD_EXECUTABLE NAMES rpmbuild)
  821. if(RPMBUILD_EXECUTABLE)
  822. list(APPEND ACTIVE_CPACK_GENERATORS RPM)
  823. endif()
  824. # Check whether if dpkg command is found
  825. # before adding DEB tests
  826. find_program(DPKG_EXECUTABLE NAMES dpkg)
  827. if(DPKG_EXECUTABLE)
  828. list(APPEND ACTIVE_CPACK_GENERATORS DEB)
  829. endif()
  830. # ACTIVE_CPACK_GENERATORS variable
  831. # now contains the list of 'active generators'
  832. set(CPackComponentsForAll_BUILD_OPTIONS)
  833. # set up list of CPack generators
  834. list(APPEND GENLST "ZIP")
  835. if(APPLE)
  836. list(APPEND GENLST "DragNDrop")
  837. endif()
  838. if (NOT CMAKE_CURRENT_BINARY_DIR MATCHES " ")
  839. list(FIND ACTIVE_CPACK_GENERATORS "RPM" RPM_ACTIVE)
  840. if (NOT ${RPM_ACTIVE} EQUAL -1)
  841. list(APPEND GENLST "RPM")
  842. endif()
  843. endif()
  844. list(FIND ACTIVE_CPACK_GENERATORS "DEB" DEB_ACTIVE)
  845. if (NOT ${DEB_ACTIVE} EQUAL -1)
  846. list(APPEND GENLST "DEB")
  847. endif()
  848. # set up list of component packaging ways
  849. list(APPEND CWAYLST "default")
  850. list(APPEND CWAYLST "OnePackPerGroup")
  851. list(APPEND CWAYLST "IgnoreGroup")
  852. list(APPEND CWAYLST "AllInOne")
  853. foreach(CPackGen ${GENLST})
  854. set(CPackRun_CPackGen "-DCPackGen=${CPackGen}")
  855. foreach(CPackComponentWay ${CWAYLST})
  856. set(CPackRun_CPackComponentWay "-DCPackComponentWay=${CPackComponentWay}")
  857. add_test(CPackComponentsForAll-${CPackGen}-${CPackComponentWay} ${CMAKE_CTEST_COMMAND}
  858. --build-and-test
  859. "${CMake_SOURCE_DIR}/Tests/CPackComponentsForAll"
  860. "${CMake_BINARY_DIR}/Tests/CPackComponentsForAll/build${CPackGen}-${CPackComponentWay}"
  861. ${build_generator_args}
  862. --build-project CPackComponentsForAll
  863. --build-options ${build_options}
  864. -DCPACK_BINARY_${CPackGen}:BOOL=ON
  865. ${CPackRun_CPackComponentWay}
  866. ${CPackComponentsForAll_BUILD_OPTIONS}
  867. --graphviz=CPackComponentsForAll.dot
  868. --test-command ${CMAKE_CMAKE_COMMAND}
  869. "-DCPackComponentsForAll_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/CPackComponentsForAll/build${CPackGen}-${CPackComponentWay}"
  870. "${CPackRun_CPackGen}"
  871. "${CPackRun_CPackComponentWay}"
  872. -P "${CMake_SOURCE_DIR}/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake")
  873. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CPackComponentsForAll/build${CPackGen}-${CPackComponentWay}")
  874. endforeach()
  875. endforeach()
  876. endif()
  877. # By default, turn this test off (because it takes a long time...)
  878. #
  879. if(NOT DEFINED CTEST_RUN_CPackTestAllGenerators)
  880. set(CTEST_RUN_CPackTestAllGenerators OFF)
  881. # ...but: if it appears to be a coverage dashboard, or long tests are
  882. # on, then set it to the generic CTEST_TEST_CPACK setting.
  883. #
  884. if(CMAKE_CXX_FLAGS MATCHES "-ftest-coverage" OR
  885. NOT "$ENV{COVFILE}" STREQUAL "" OR
  886. CMAKE_RUN_LONG_TESTS)
  887. set(CTEST_RUN_CPackTestAllGenerators ${CTEST_TEST_CPACK})
  888. endif()
  889. endif()
  890. if(CTEST_RUN_CPackTestAllGenerators)
  891. add_test(CPackTestAllGenerators ${CMAKE_CTEST_COMMAND}
  892. --build-and-test
  893. "${CMake_SOURCE_DIR}/Tests/CPackTestAllGenerators"
  894. "${CMake_BINARY_DIR}/Tests/CPackTestAllGenerators"
  895. ${build_generator_args}
  896. --build-project CPackTestAllGenerators
  897. --build-options ${build_options}
  898. --test-command
  899. ${CMAKE_CMAKE_COMMAND}
  900. -D dir=${CMake_BINARY_DIR}/Tests/CPackTestAllGenerators
  901. -P ${CMake_SOURCE_DIR}/Tests/CPackTestAllGenerators/RunCPack.cmake
  902. )
  903. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CPackTestAllGenerators")
  904. endif()
  905. if(CTEST_package_X11_TEST)
  906. set(X11_build_target_arg --build-target package)
  907. else()
  908. set(X11_build_target_arg)
  909. endif()
  910. add_test(X11 ${CMAKE_CTEST_COMMAND}
  911. --build-and-test
  912. "${CMake_SOURCE_DIR}/Tests/X11"
  913. "${CMake_BINARY_DIR}/Tests/X11"
  914. ${build_generator_args}
  915. --build-project UseX11
  916. --build-two-config
  917. ${X11_build_target_arg}
  918. --build-options ${build_options}
  919. --test-command UseX11)
  920. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/X11")
  921. if(NOT DEFINED CTEST_RUN_CMakeTestAllGenerators)
  922. set(CTEST_RUN_CMakeTestAllGenerators ON)
  923. endif()
  924. if(CTEST_RUN_CMakeTestAllGenerators)
  925. add_test(CMakeTestAllGenerators ${CMAKE_CMAKE_COMMAND}
  926. -D dir=${CMake_BINARY_DIR}/Tests/CMakeTestAllGenerators
  927. -D CMake_SOURCE_DIR=${CMake_SOURCE_DIR}
  928. -P ${CMake_SOURCE_DIR}/Tests/CMakeTestAllGenerators/RunCMake.cmake
  929. )
  930. list(APPEND TEST_BUILD_DIRS
  931. "${CMake_BINARY_DIR}/Tests/CMakeTestAllGenerators")
  932. endif()
  933. if(NOT DEFINED CTEST_RUN_CMakeTestBadCommandLines)
  934. set(CTEST_RUN_CMakeTestBadCommandLines ON)
  935. endif()
  936. if(CTEST_RUN_CMakeTestBadCommandLines)
  937. add_test(CMakeTestBadCommandLines ${CMAKE_CMAKE_COMMAND}
  938. -D dir=${CMake_BINARY_DIR}/Tests/CMakeTestBadCommandLines
  939. -D gen=${CMAKE_GENERATOR}
  940. -D CMake_SOURCE_DIR=${CMake_SOURCE_DIR}
  941. -P ${CMake_SOURCE_DIR}/Tests/CMakeTestBadCommandLines/RunCMake.cmake
  942. )
  943. list(APPEND TEST_BUILD_DIRS
  944. "${CMake_BINARY_DIR}/Tests/CMakeTestBadCommandLines")
  945. endif()
  946. if(NOT DEFINED CTEST_RUN_CMakeTestMultipleConfigures)
  947. set(CTEST_RUN_CMakeTestMultipleConfigures ON)
  948. endif()
  949. if(CTEST_RUN_CMakeTestMultipleConfigures)
  950. add_test(CMakeTestMultipleConfigures ${CMAKE_CMAKE_COMMAND}
  951. -D dir=${CMake_BINARY_DIR}/Tests/CMakeTestMultipleConfigures
  952. -D gen=${CMAKE_GENERATOR}
  953. -D CMake_SOURCE_DIR=${CMake_SOURCE_DIR}
  954. -P ${CMake_SOURCE_DIR}/Tests/CMakeTestMultipleConfigures/RunCMake.cmake
  955. )
  956. list(APPEND TEST_BUILD_DIRS
  957. "${CMake_BINARY_DIR}/Tests/CMakeTestMultipleConfigures")
  958. endif()
  959. if(NOT CMake_TEST_EXTERNAL_CMAKE)
  960. add_test(LoadedCommandOneConfig ${CMAKE_CTEST_COMMAND}
  961. --build-and-test
  962. "${CMake_SOURCE_DIR}/Tests/LoadCommandOneConfig"
  963. "${CMake_BINARY_DIR}/Tests/LoadCommandOneConfig"
  964. ${build_generator_args}
  965. --build-project LoadCommand
  966. --build-options ${build_options}
  967. --test-command LoadedCommand
  968. )
  969. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LoadCommandOneConfig")
  970. endif()
  971. add_test(complex ${CMAKE_CTEST_COMMAND}
  972. --build-and-test
  973. "${CMake_SOURCE_DIR}/Tests/Complex"
  974. "${CMake_BINARY_DIR}/Tests/Complex"
  975. --build-two-config
  976. --build-config-sample "${CMAKE_CTEST_COMMAND}"
  977. ${build_generator_args}
  978. --build-project Complex
  979. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Complex/bin"
  980. --build-options ${build_options}
  981. -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
  982. --test-command complex
  983. )
  984. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Complex")
  985. add_test(complexOneConfig ${CMAKE_CTEST_COMMAND}
  986. --build-and-test
  987. "${CMake_SOURCE_DIR}/Tests/ComplexOneConfig"
  988. "${CMake_BINARY_DIR}/Tests/ComplexOneConfig"
  989. ${build_generator_args}
  990. --build-project Complex
  991. --build-exe-dir "${CMake_BINARY_DIR}/Tests/ComplexOneConfig/bin"
  992. --build-options ${build_options}
  993. -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
  994. --test-command complex)
  995. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ComplexOneConfig")
  996. # because of the registry write these tests depend on each other
  997. set_tests_properties ( complex PROPERTIES DEPENDS complexOneConfig)
  998. add_test(Environment ${CMAKE_CTEST_COMMAND}
  999. --build-and-test
  1000. "${CMake_SOURCE_DIR}/Tests/Environment"
  1001. "${CMake_BINARY_DIR}/Tests/Environment"
  1002. ${build_generator_args}
  1003. --build-project EnvironmentProj
  1004. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Environment"
  1005. --force-new-ctest-process
  1006. --build-options ${build_options}
  1007. --test-command ${CMAKE_CTEST_COMMAND} -V
  1008. )
  1009. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Environment")
  1010. add_test(QtAutomocNoQt ${CMAKE_CTEST_COMMAND}
  1011. --build-and-test
  1012. "${CMake_SOURCE_DIR}/Tests/QtAutomocNoQt"
  1013. "${CMake_BINARY_DIR}/Tests/QtAutomocNoQt"
  1014. ${build_generator_args}
  1015. --build-project QtAutomocNoQt
  1016. --build-options ${build_options}
  1017. -DCMAKE_BUILD_TYPE=\${CTEST_CONFIGURATION_TYPE}
  1018. )
  1019. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/QtAutomocNoQt")
  1020. # On Windows there is no RPATH, so while Qt might be available for building,
  1021. # the required dlls may not be in the PATH, so we can't run the executables
  1022. # on that platform.
  1023. if(WIN32)
  1024. set(run_autogen_test ${CMAKE_CTEST_COMMAND} -V)
  1025. set(run_autouic_test ${CMAKE_CTEST_COMMAND} -V)
  1026. else()
  1027. set(run_autogen_test QtAutogen)
  1028. set(run_autouic_test QtAutoUicInterface)
  1029. endif()
  1030. find_package(Qt5Widgets QUIET NO_MODULE)
  1031. if(Qt5Widgets_FOUND)
  1032. add_test(Qt5Autogen ${CMAKE_CTEST_COMMAND}
  1033. --build-and-test
  1034. "${CMake_SOURCE_DIR}/Tests/QtAutogen"
  1035. "${CMake_BINARY_DIR}/Tests/Qt5Autogen"
  1036. ${build_generator_args}
  1037. --build-project QtAutogen
  1038. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt5Autogen"
  1039. --force-new-ctest-process
  1040. --build-options ${build_options}
  1041. -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DQT_TEST_VERSION=5
  1042. --test-command ${run_autogen_test}
  1043. )
  1044. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt5Autogen")
  1045. add_test(Qt5AutoUicInterface ${CMAKE_CTEST_COMMAND}
  1046. --build-and-test
  1047. "${CMake_SOURCE_DIR}/Tests/QtAutoUicInterface"
  1048. "${CMake_BINARY_DIR}/Tests/Qt5AutoUicInterface"
  1049. ${build_generator_args}
  1050. --build-project QtAutoUicInterface
  1051. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt5AutoUicInterface"
  1052. --force-new-ctest-process
  1053. --build-options ${build_options}
  1054. -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DQT_TEST_VERSION=5
  1055. --test-command ${run_autouic_test}
  1056. )
  1057. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt5AutoUicInterface")
  1058. endif()
  1059. if(QT4_WORKS AND QT_QTGUI_FOUND)
  1060. add_test(Qt4Autogen ${CMAKE_CTEST_COMMAND}
  1061. --build-and-test
  1062. "${CMake_SOURCE_DIR}/Tests/QtAutogen"
  1063. "${CMake_BINARY_DIR}/Tests/Qt4Autogen"
  1064. ${build_generator_args}
  1065. --build-project QtAutogen
  1066. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4Autogen"
  1067. --force-new-ctest-process
  1068. --build-options ${build_options}
  1069. -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DQT_TEST_VERSION=4
  1070. --test-command ${run_autogen_test}
  1071. )
  1072. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4Autogen")
  1073. add_test(Qt4AutoUicInterface ${CMAKE_CTEST_COMMAND}
  1074. --build-and-test
  1075. "${CMake_SOURCE_DIR}/Tests/QtAutoUicInterface"
  1076. "${CMake_BINARY_DIR}/Tests/Qt4AutoUicInterface"
  1077. ${build_generator_args}
  1078. --build-project QtAutoUicInterface
  1079. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4AutoUicInterface"
  1080. --force-new-ctest-process
  1081. --build-options ${build_options}
  1082. -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DQT_TEST_VERSION=4
  1083. --test-command ${run_autouic_test}
  1084. )
  1085. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4AutoUicInterface")
  1086. add_test(Qt4Targets ${CMAKE_CTEST_COMMAND}
  1087. --build-and-test
  1088. "${CMake_SOURCE_DIR}/Tests/Qt4Targets"
  1089. "${CMake_BINARY_DIR}/Tests/Qt4Targets"
  1090. ${build_generator_args}
  1091. --build-project Qt4Targets
  1092. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4Targets"
  1093. --force-new-ctest-process
  1094. --build-options ${build_options}
  1095. -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}
  1096. --test-command ${CMAKE_CTEST_COMMAND} -V
  1097. )
  1098. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4Targets")
  1099. if(Qt5Widgets_FOUND AND NOT Qt5Widgets_VERSION VERSION_LESS 5.1.0)
  1100. add_test(Qt4And5Automoc ${CMAKE_CTEST_COMMAND}
  1101. --build-and-test
  1102. "${CMake_SOURCE_DIR}/Tests/Qt4And5Automoc"
  1103. "${CMake_BINARY_DIR}/Tests/Qt4And5Automoc"
  1104. ${build_generator_args}
  1105. --build-project Qt4And5Automoc
  1106. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4And5Automoc"
  1107. --force-new-ctest-process
  1108. --build-options ${build_options}
  1109. --test-command ${CMAKE_CTEST_COMMAND} -V
  1110. )
  1111. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4And5Automoc")
  1112. add_test(Qt4And5AutomocReverse ${CMAKE_CTEST_COMMAND}
  1113. --build-and-test
  1114. "${CMake_SOURCE_DIR}/Tests/Qt4And5Automoc"
  1115. "${CMake_BINARY_DIR}/Tests/Qt4And5AutomocReverse"
  1116. ${build_generator_args}
  1117. --build-project Qt4And5Automoc
  1118. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4And5AutomocReverse"
  1119. --force-new-ctest-process
  1120. --build-options ${build_options} -DQT_REVERSE_FIND_ORDER=1
  1121. --test-command ${CMAKE_CTEST_COMMAND} -V
  1122. )
  1123. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4And5AutomocReverse")
  1124. endif()
  1125. endif()
  1126. find_package(GTK2 QUIET)
  1127. if(GTK2_FOUND)
  1128. add_subdirectory(FindGTK2)
  1129. endif()
  1130. add_test(ExternalProject ${CMAKE_CTEST_COMMAND}
  1131. --build-and-test
  1132. "${CMake_SOURCE_DIR}/Tests/ExternalProject"
  1133. "${CMake_BINARY_DIR}/Tests/ExternalProject"
  1134. ${build_generator_args}
  1135. --build-project ExternalProjectTest
  1136. --build-exe-dir "${CMake_BINARY_DIR}/Tests/ExternalProject"
  1137. --force-new-ctest-process
  1138. --build-options ${build_options}
  1139. --test-command ${CMAKE_CTEST_COMMAND} -V
  1140. )
  1141. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProject")
  1142. set_tests_properties(ExternalProject PROPERTIES
  1143. TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT})
  1144. add_test(ExternalProjectUpdateSetup ${CMAKE_CTEST_COMMAND}
  1145. --build-and-test
  1146. "${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate"
  1147. "${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate"
  1148. ${build_generator_args}
  1149. --build-project ExternalProjectUpdateTest
  1150. --build-exe-dir "${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate"
  1151. --force-new-ctest-process
  1152. --build-options ${build_options}
  1153. --test-command ${CMAKE_CTEST_COMMAND} -V
  1154. )
  1155. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate")
  1156. set_tests_properties(ExternalProjectUpdateSetup PROPERTIES
  1157. TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT})
  1158. add_test(NAME ExternalProjectUpdate
  1159. COMMAND ${CMAKE_CMAKE_COMMAND}
  1160. -DExternalProjectUpdate_SOURCE_DIR:PATH=${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate
  1161. -DExternalProjectUpdate_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate
  1162. -DCMAKE_GENERATOR=${CMAKE_GENERATOR}
  1163. -DCMAKE_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET}
  1164. -DCMAKE_CTEST_COMMAND=${CMAKE_CTEST_COMMAND}
  1165. -P ${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake
  1166. )
  1167. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate")
  1168. set_tests_properties(ExternalProjectUpdate PROPERTIES
  1169. TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}
  1170. WORKING_DIRECTORY ${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate
  1171. DEPENDS ExternalProjectUpdateSetup )
  1172. # do each of the tutorial steps
  1173. foreach(STP RANGE 1 7)
  1174. add_test(TutorialStep${STP} ${CMAKE_CTEST_COMMAND}
  1175. --build-and-test
  1176. "${CMake_SOURCE_DIR}/Tests/Tutorial/Step${STP}"
  1177. "${CMake_BINARY_DIR}/Tests/Tutorial/Step${STP}"
  1178. --build-two-config
  1179. ${build_generator_args}
  1180. --build-project Tutorial
  1181. --build-options ${build_options}
  1182. --test-command Tutorial 25.0)
  1183. endforeach()
  1184. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Tutorial")
  1185. add_test(testing ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE}
  1186. --build-and-test
  1187. "${CMake_SOURCE_DIR}/Tests/Testing"
  1188. "${CMake_BINARY_DIR}/Tests/Testing"
  1189. ${build_generator_args}
  1190. --build-project Testing
  1191. --build-options ${build_options}
  1192. --test-command ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE}
  1193. )
  1194. set_tests_properties(testing PROPERTIES PASS_REGULAR_EXPRESSION "Passed")
  1195. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Testing")
  1196. add_test(wrapping ${CMAKE_CTEST_COMMAND}
  1197. --build-and-test
  1198. "${CMake_SOURCE_DIR}/Tests/Wrapping"
  1199. "${CMake_BINARY_DIR}/Tests/Wrapping"
  1200. ${build_generator_args}
  1201. --build-project Wrapping
  1202. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin"
  1203. --build-options ${build_options}
  1204. --test-command wrapping
  1205. )
  1206. add_test(qtwrapping ${CMAKE_CTEST_COMMAND}
  1207. --build-and-test
  1208. "${CMake_SOURCE_DIR}/Tests/Wrapping"
  1209. "${CMake_BINARY_DIR}/Tests/Wrapping"
  1210. ${build_generator_args}
  1211. --build-project Wrapping
  1212. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin"
  1213. --build-options ${build_options}
  1214. --test-command qtwrapping
  1215. )
  1216. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Wrapping")
  1217. add_test(testdriver1 ${CMAKE_CTEST_COMMAND}
  1218. --build-and-test
  1219. "${CMake_SOURCE_DIR}/Tests/TestDriver"
  1220. "${CMake_BINARY_DIR}/Tests/TestDriver"
  1221. ${build_generator_args}
  1222. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin"
  1223. --build-project TestDriverTest
  1224. --build-options ${build_options}
  1225. --test-command TestDriverTest test1
  1226. )
  1227. add_test(testdriver2 ${CMAKE_CTEST_COMMAND}
  1228. --build-and-test
  1229. "${CMake_SOURCE_DIR}/Tests/TestDriver"
  1230. "${CMake_BINARY_DIR}/Tests/TestDriver"
  1231. ${build_generator_args}
  1232. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin"
  1233. --build-project TestDriverTest
  1234. --build-options ${build_options}
  1235. --test-command TestDriverTest test2
  1236. )
  1237. add_test(testdriver3 ${CMAKE_CTEST_COMMAND}
  1238. --build-and-test
  1239. "${CMake_SOURCE_DIR}/Tests/TestDriver"
  1240. "${CMake_BINARY_DIR}/Tests/TestDriver"
  1241. ${build_generator_args}
  1242. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin"
  1243. --build-project TestDriverTest
  1244. --build-options ${build_options}
  1245. --test-command TestDriverTest subdir/test3
  1246. )
  1247. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/TestDriver")
  1248. add_test(Dependency ${CMAKE_CTEST_COMMAND}
  1249. --build-and-test
  1250. "${CMake_SOURCE_DIR}/Tests/Dependency"
  1251. "${CMake_BINARY_DIR}/Tests/Dependency"
  1252. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Dependency/Exec"
  1253. ${build_generator_args}
  1254. --build-project Dependency
  1255. --build-options ${build_options}
  1256. --test-command exec
  1257. )
  1258. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Dependency")
  1259. if("${CMAKE_SYSTEM_NAME}" MATCHES syllable)
  1260. # RPATH isn't supported under Syllable, so the tests don't
  1261. # find their libraries. In order to fix that LIBRARY_OUTPUT_DIR
  1262. # in the tests would have to be adjusted to ${EXECUTABLE_OUTPUT_DIR}/lib .
  1263. # For now we just require on Syllable that the user adjusts the DLL_PATH
  1264. # environment variable, so except the two tests below all other tests will succeed.
  1265. set(_DLL_PATH "$ENV{DLL_PATH}")
  1266. if(NOT "${_DLL_PATH}" MATCHES "^(.*:)?\\@bindir\\@/\\.(:.*)?$")
  1267. message(FATAL_ERROR "In order to successfully run the CMake test suite on Syllable you need to add \"\\@bindir\\@/.\" to the DLL_PATH environment variable")
  1268. endif()
  1269. if(NOT "${_DLL_PATH}" MATCHES "^(.*:)?\\@bindir\\@/\\.\\./lib(:.*)?$")
  1270. message(FATAL_ERROR "In order to successfully run the CMake test suite on Syllable you need to add \"\\@bindir\\@/../lib\" to the DLL_PATH environment variable")
  1271. endif()
  1272. else()
  1273. add_test(JumpWithLibOut ${CMAKE_CTEST_COMMAND}
  1274. --build-and-test
  1275. "${CMake_SOURCE_DIR}/Tests/Jump"
  1276. "${CMake_BINARY_DIR}/Tests/Jump/WithLibOut"
  1277. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Jump/WithLibOut/Executable"
  1278. --build-project Jump
  1279. ${build_generator_args}
  1280. --build-options ${build_options}
  1281. -DLIBRARY_OUTPUT_PATH:PATH=${CMake_BINARY_DIR}/Tests/Jump/WithLibOut/Lib
  1282. --test-command jumpExecutable
  1283. )
  1284. add_test(JumpNoLibOut ${CMAKE_CTEST_COMMAND}
  1285. --build-and-test
  1286. "${CMake_SOURCE_DIR}/Tests/Jump"
  1287. "${CMake_BINARY_DIR}/Tests/Jump/NoLibOut"
  1288. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Jump/NoLibOut/Executable"
  1289. --build-run-dir "${CMake_BINARY_DIR}/Tests/Jump/NoLibOut/Executable"
  1290. --build-project Jump
  1291. ${build_generator_args}
  1292. --build-options ${build_options}
  1293. --test-command jumpExecutable
  1294. )
  1295. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Jump")
  1296. add_test(Plugin ${CMAKE_CTEST_COMMAND}
  1297. --build-and-test
  1298. "${CMake_SOURCE_DIR}/Tests/Plugin"
  1299. "${CMake_BINARY_DIR}/Tests/Plugin"
  1300. ${build_generator_args}
  1301. --build-project Plugin
  1302. --build-two-config
  1303. --build-options ${build_options}
  1304. --test-command bin/example)
  1305. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Plugin")
  1306. if(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG)
  1307. ADD_TEST_MACRO(RuntimePath RuntimePath)
  1308. endif()
  1309. endif()
  1310. if(APPLE AND "${DARWIN_MAJOR_VERSION}" GREATER 9)
  1311. add_test(MacRuntimePath ${CMAKE_CTEST_COMMAND}
  1312. --build-and-test
  1313. "${CMake_SOURCE_DIR}/Tests/MacRuntimePath"
  1314. "${CMake_BINARY_DIR}/Tests/MacRuntimePath"
  1315. ${build_generator_args}
  1316. --build-project MacRuntimePath
  1317. --build-options ${build_options}
  1318. -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM}
  1319. )
  1320. endif()
  1321. add_test(linkorder1 ${CMAKE_CTEST_COMMAND}
  1322. --build-and-test
  1323. "${CMake_SOURCE_DIR}/Tests/LinkLineOrder"
  1324. "${CMake_BINARY_DIR}/Tests/LinkLineOrder"
  1325. ${build_generator_args}
  1326. --build-project LinkLineOrder
  1327. --build-options ${build_options}
  1328. --test-command Exec1
  1329. )
  1330. add_test(linkorder2 ${CMAKE_CTEST_COMMAND}
  1331. --build-and-test
  1332. "${CMake_SOURCE_DIR}/Tests/LinkLineOrder"
  1333. "${CMake_BINARY_DIR}/Tests/LinkLineOrder"
  1334. ${build_generator_args}
  1335. --build-project LinkLineOrder
  1336. --build-options ${build_options}
  1337. --test-command Exec2
  1338. )
  1339. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LinkLineOrder")
  1340. set_tests_properties ( qtwrapping PROPERTIES DEPENDS wrapping)
  1341. set_tests_properties ( testdriver1 PROPERTIES DEPENDS qtwrapping)
  1342. set_tests_properties ( testdriver2 PROPERTIES DEPENDS testdriver1)
  1343. set_tests_properties ( testdriver3 PROPERTIES DEPENDS testdriver2)
  1344. set_tests_properties ( linkorder2 PROPERTIES DEPENDS linkorder1)
  1345. set_tests_properties ( SimpleInstall-Stage2 PROPERTIES DEPENDS SimpleInstall)
  1346. # Test static linking on toolchains known to support it.
  1347. if("${CMAKE_C_COMPILER_ID}" MATCHES "^(GNU)$"
  1348. AND NOT APPLE AND NOT WIN32 AND NOT CYGWIN
  1349. AND EXISTS "/usr/lib/libm.a")
  1350. add_test(LinkStatic ${CMAKE_CTEST_COMMAND}
  1351. --build-and-test
  1352. "${CMake_SOURCE_DIR}/Tests/LinkStatic"
  1353. "${CMake_BINARY_DIR}/Tests/LinkStatic"
  1354. ${build_generator_args}
  1355. --build-project LinkStatic
  1356. --build-options ${build_options}
  1357. -DMATH_LIBRARY:FILEPATH=/usr/lib/libm.a
  1358. --test-command LinkStatic
  1359. )
  1360. endif()
  1361. if(MAKE_SUPPORTS_SPACES)
  1362. add_test(SubDirSpaces ${CMAKE_CTEST_COMMAND}
  1363. --build-and-test
  1364. "${CMake_SOURCE_DIR}/Tests/SubDirSpaces"
  1365. "${CMake_BINARY_DIR}/Tests/SubDirSpaces"
  1366. --build-exe-dir
  1367. "${CMake_BINARY_DIR}/Tests/SubDirSpaces/Executable Sources"
  1368. ${build_generator_args}
  1369. --build-project SUBDIR
  1370. --build-options ${build_options}
  1371. --test-command test
  1372. "${CMake_BINARY_DIR}/Tests/SubDirSpaces/ShouldBeHere"
  1373. "${CMake_BINARY_DIR}/Tests/SubDirSpaces/testfromsubdir.obj"
  1374. )
  1375. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SubDirSpaces")
  1376. endif ()
  1377. if (WIN32)
  1378. add_test(SubDir ${CMAKE_CTEST_COMMAND}
  1379. --build-and-test
  1380. "${CMake_SOURCE_DIR}/Tests/SubDir"
  1381. "${CMake_BINARY_DIR}/Tests/SubDir"
  1382. --build-exe-dir "${CMake_BINARY_DIR}/Tests/SubDir/Executable"
  1383. ${build_generator_args}
  1384. --build-project SUBDIR
  1385. --build-options ${build_options}
  1386. --test-command test
  1387. "${CMake_BINARY_DIR}/Tests/SubDir/ShouldBeHere"
  1388. "${CMake_BINARY_DIR}/Tests/SubDir/testfromsubdir.obj"
  1389. )
  1390. else ()
  1391. add_test(SubDir ${CMAKE_CTEST_COMMAND}
  1392. --build-and-test
  1393. "${CMake_SOURCE_DIR}/Tests/SubDir"
  1394. "${CMake_BINARY_DIR}/Tests/SubDir"
  1395. --build-exe-dir "${CMake_BINARY_DIR}/Tests/SubDir/Executable"
  1396. ${build_generator_args}
  1397. --build-project SUBDIR
  1398. --build-options ${build_options}
  1399. --test-command test
  1400. "${CMake_BINARY_DIR}/Tests/SubDir/ShouldBeHere"
  1401. "${CMake_BINARY_DIR}/Tests/SubDir/testfromsubdir.o"
  1402. )
  1403. endif ()
  1404. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SubDir")
  1405. if(MSVC)
  1406. ADD_TEST_MACRO(ForceInclude foo)
  1407. ADD_TEST_MACRO(PDBDirectoryAndName myexe)
  1408. ADD_TEST_MACRO(PrecompiledHeader foo)
  1409. endif()
  1410. if(MSVC OR
  1411. "${CMAKE_GENERATOR}" MATCHES "(MSYS|MinGW) Makefiles")
  1412. ADD_TEST_MACRO(ModuleDefinition example_exe)
  1413. endif()
  1414. ADD_TEST_MACRO(CheckCompilerRelatedVariables CheckCompilerRelatedVariables)
  1415. if("${CMAKE_GENERATOR}" MATCHES "Makefile")
  1416. add_test(MakeClean ${CMAKE_CTEST_COMMAND}
  1417. --build-and-test
  1418. "${CMake_SOURCE_DIR}/Tests/MakeClean"
  1419. "${CMake_BINARY_DIR}/Tests/MakeClean"
  1420. ${build_generator_args}
  1421. --build-project MakeClean
  1422. --build-exe-dir "${CMake_BINARY_DIR}/MakeClean"
  1423. --build-options ${build_options}
  1424. --test-command check_clean
  1425. )
  1426. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/MakeClean")
  1427. endif()
  1428. if(NOT DEFINED CTEST_RUN_MFC)
  1429. set(CTEST_RUN_MFC OFF)
  1430. if(MSVC)
  1431. set(CTEST_RUN_MFC ON)
  1432. # Look for evidence that this is a VCExpress build. If so, avoid
  1433. # the MFC test by default.
  1434. string(TOLOWER "${CMAKE_MAKE_PROGRAM}" mkprog)
  1435. if(mkprog MATCHES "vcexpress")
  1436. message(STATUS
  1437. "CMAKE_MAKE_PROGRAM indicates vcexpress, avoiding MFC test")
  1438. set(CTEST_RUN_MFC OFF)
  1439. endif()
  1440. # Since MSBuild might also be the "makeprogram" for a VCExpress
  1441. # build tree, use one more heuristic, too. The string representing
  1442. # the .vcproj file type contains "VCExpress" on machines where an
  1443. # express edition of VS was installed last:
  1444. if(CTEST_RUN_MFC)
  1445. execute_process(COMMAND cmd /c assoc .vcproj
  1446. OUTPUT_STRIP_TRAILING_WHITESPACE
  1447. OUTPUT_VARIABLE ov)
  1448. if(ov MATCHES "VCExpress")
  1449. message(STATUS
  1450. ".vcproj file association indicates VCExpress, avoiding MFC test")
  1451. set(CTEST_RUN_MFC OFF)
  1452. endif()
  1453. endif()
  1454. # For the Watcom WMake generator, avoid the MFC test by default.
  1455. if(CTEST_RUN_MFC)
  1456. if("${CMAKE_GENERATOR}" MATCHES "WMake")
  1457. message(STATUS
  1458. "using the Watcom WMake generator, avoiding MFC test")
  1459. set(CTEST_RUN_MFC OFF)
  1460. endif()
  1461. endif()
  1462. # Last resort, after quick checks are done. Do a try_compile, and avoid
  1463. # the MFC test if the simplest possible MFC app cannot be compiled.
  1464. if(CTEST_RUN_MFC AND NOT DEFINED HAVE_MFC)
  1465. configure_file(
  1466. ${CMAKE_CURRENT_SOURCE_DIR}/MFC/try_compile/CMakeLists.txt
  1467. ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile/CMakeLists.txt
  1468. COPYONLY
  1469. )
  1470. configure_file(
  1471. ${CMAKE_CURRENT_SOURCE_DIR}/MFC/mfc1/stdafx.cpp
  1472. ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile/stdafx.cpp
  1473. COPYONLY
  1474. )
  1475. configure_file(
  1476. ${CMAKE_CURRENT_SOURCE_DIR}/MFC/mfc1/stdafx.h
  1477. ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile/stdafx.h
  1478. COPYONLY
  1479. )
  1480. message(STATUS "Looking for MFC")
  1481. try_compile(HAVE_MFC
  1482. ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile/build
  1483. ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile
  1484. try_compile_mfc
  1485. OUTPUT_VARIABLE HAVE_MFC_OUTPUT)
  1486. if(HAVE_MFC)
  1487. message(STATUS "Looking for MFC - found")
  1488. set(HAVE_MFC 1 CACHE INTERNAL "Have MFC")
  1489. file(APPEND
  1490. ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
  1491. "Determining if MFC exists passed with the following output:\n"
  1492. "${HAVE_MFC_OUTPUT}\n\n")
  1493. else()
  1494. message(STATUS "Looking for MFC - not found")
  1495. set(HAVE_MFC "" CACHE INTERNAL "Have MFC")
  1496. file(APPEND
  1497. ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
  1498. "Determining if MFC exists failed with the following output:\n"
  1499. "${HAVE_MFC_OUTPUT}\n\n")
  1500. endif()
  1501. endif()
  1502. if(CTEST_RUN_MFC AND NOT HAVE_MFC)
  1503. message(STATUS
  1504. "cannot compile simplest ever MFC app, avoiding MFC test")
  1505. set(CTEST_RUN_MFC OFF)
  1506. endif()
  1507. endif()
  1508. endif()
  1509. if(CTEST_RUN_MFC)
  1510. add_test(MFC ${CMAKE_CTEST_COMMAND}
  1511. --build-and-test
  1512. "${CMake_SOURCE_DIR}/Tests/MFC"
  1513. "${CMake_BINARY_DIR}/Tests/MFC"
  1514. --build-two-config
  1515. ${build_generator_args}
  1516. --build-project mfc_driver
  1517. --build-options ${build_options}
  1518. --test-command ${CMAKE_CTEST_COMMAND}
  1519. -C \${CTEST_CONFIGURATION_TYPE} -VV)
  1520. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/MFC")
  1521. endif()
  1522. if(${CMAKE_GENERATOR} MATCHES "Visual Studio")
  1523. if(NOT MSVC60)
  1524. ADD_TEST_MACRO(SBCS SBCS)
  1525. endif()
  1526. if(NOT "${CMAKE_GENERATOR}" MATCHES "Visual Studio [6789]( |$)"
  1527. AND NOT CMAKE_GENERATOR_TOOLSET)
  1528. ADD_TEST_MACRO(VSWindowsFormsResx VSWindowsFormsResx)
  1529. endif()
  1530. add_test(VSExternalInclude ${CMAKE_CTEST_COMMAND}
  1531. --build-and-test
  1532. "${CMake_SOURCE_DIR}/Tests/VSExternalInclude"
  1533. "${CMake_BINARY_DIR}/Tests/VSExternalInclude"
  1534. --build-two-config
  1535. ${build_generator_args}
  1536. --build-project VSExternalInclude
  1537. --build-options ${build_options}
  1538. --test-command VSExternalInclude)
  1539. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSExternalInclude")
  1540. add_test(VSMidl ${CMAKE_CTEST_COMMAND}
  1541. --build-and-test
  1542. "${CMake_SOURCE_DIR}/Tests/VSMidl"
  1543. "${CMake_BINARY_DIR}/Tests/VSMidl"
  1544. --build-two-config
  1545. ${build_generator_args}
  1546. --build-project VSMidl
  1547. --build-options ${build_options}
  1548. --test-command VSMidl)
  1549. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSMidl")
  1550. if(CMake_TEST_DEVENV)
  1551. # The test (and tested property) works with .sln files, so it's skipped when:
  1552. # * Using VS6, which doesn't use .sln files
  1553. # * cmake --build is set up to use MSBuild, since the MSBuild invocation does not use the .sln file
  1554. set(_last_test "")
  1555. foreach(config ${CMAKE_CONFIGURATION_TYPES})
  1556. add_test(NAME VSExcludeFromDefaultBuild-${config} COMMAND ${CMAKE_CTEST_COMMAND}
  1557. --build-and-test
  1558. "${CMake_SOURCE_DIR}/Tests/VSExcludeFromDefaultBuild"
  1559. "${CMake_BINARY_DIR}/Tests/VSExcludeFromDefaultBuild"
  1560. --build-config ${config}
  1561. --build-two-config
  1562. --build-generator ${CMAKE_GENERATOR}
  1563. --build-makeprogram ${CMake_TEST_DEVENV}
  1564. --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
  1565. --build-project VSExcludeFromDefaultBuild
  1566. --test-command ${CMAKE_COMMAND}
  1567. -D "activeConfig=${config}"
  1568. -D "allConfigs=${CMAKE_CONFIGURATION_TYPES}"
  1569. -D "dir=${CMake_BINARY_DIR}/Tests/VSExcludeFromDefaultBuild"
  1570. -P "${CMake_SOURCE_DIR}/Tests/VSExcludeFromDefaultBuild/ResultTest.cmake")
  1571. if(_last_test)
  1572. set_property(TEST VSExcludeFromDefaultBuild-${config} PROPERTY DEPENDS ${_last_test})
  1573. endif()
  1574. set(_last_test "VSExcludeFromDefaultBuild-${config}")
  1575. endforeach()
  1576. unset(_last_test)
  1577. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSExcludeFromDefaultBuild")
  1578. endif()
  1579. if(CMAKE_GENERATOR MATCHES "Visual Studio ([0-5]|[6-9][0-9])")
  1580. # This is Visual Studio 10 or above, so the default build tool is MSBuild.
  1581. add_test(NAME VSProjectInSubdir COMMAND ${CMAKE_CTEST_COMMAND}
  1582. --build-and-test
  1583. "${CMake_SOURCE_DIR}/Tests/VSProjectInSubdir"
  1584. "${CMake_BINARY_DIR}/Tests/VSProjectInSubdir"
  1585. --build-two-config
  1586. --build-generator ${CMAKE_GENERATOR}
  1587. --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
  1588. --build-project VSProjectInSubdir
  1589. --build-target test)
  1590. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSProjectInSubdir")
  1591. endif()
  1592. endif()
  1593. if (APPLE)
  1594. if (CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
  1595. set(BundleTestInstallDir
  1596. "${CMake_BINARY_DIR}/Tests/BundleTest/InstallDirectory")
  1597. add_test(BundleTest ${CMAKE_CTEST_COMMAND}
  1598. --build-and-test
  1599. "${CMake_SOURCE_DIR}/Tests/BundleTest"
  1600. "${CMake_BINARY_DIR}/Tests/BundleTest"
  1601. --build-two-config
  1602. ${build_generator_args}
  1603. --build-project BundleTest
  1604. --build-target install
  1605. # --build-target package
  1606. --build-options ${build_options}
  1607. "-DCMAKE_INSTALL_PREFIX:PATH=${BundleTestInstallDir}"
  1608. "-DCMake_SOURCE_DIR:PATH=${CMake_SOURCE_DIR}"
  1609. --test-command
  1610. ${BundleTestInstallDir}/Applications/SecondBundleExe.app/Contents/MacOS/SecondBundleExe)
  1611. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BundleTest")
  1612. add_test(CFBundleTest ${CMAKE_CTEST_COMMAND}
  1613. --build-and-test
  1614. "${CMake_SOURCE_DIR}/Tests/CFBundleTest"
  1615. "${CMake_BINARY_DIR}/Tests/CFBundleTest"
  1616. --build-two-config
  1617. ${build_generator_args}
  1618. --build-project CFBundleTest
  1619. --build-options ${build_options}
  1620. --test-command
  1621. ${CMAKE_CMAKE_COMMAND} -DCTEST_CONFIGURATION_TYPE=\${CTEST_CONFIGURATION_TYPE}
  1622. -Ddir=${CMake_BINARY_DIR}/Tests/CFBundleTest
  1623. -Dgen=${CMAKE_GENERATOR}
  1624. -P ${CMake_SOURCE_DIR}/Tests/CFBundleTest/VerifyResult.cmake)
  1625. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CFBundleTest")
  1626. ADD_TEST_MACRO(ObjC++ ObjC++)
  1627. endif ()
  1628. endif ()
  1629. if(APPLE AND CTEST_TEST_CPACK)
  1630. add_test(BundleGeneratorTest ${CMAKE_CTEST_COMMAND}
  1631. --build-and-test
  1632. "${CMake_SOURCE_DIR}/Tests/BundleGeneratorTest"
  1633. "${CMake_BINARY_DIR}/Tests/BundleGeneratorTest"
  1634. --build-two-config
  1635. ${build_generator_args}
  1636. --build-project BundleGeneratorTest
  1637. --build-target package
  1638. --build-options ${build_options}
  1639. "-DCMAKE_INSTALL_PREFIX:PATH=${CMake_BINARY_DIR}/Tests/BundleGeneratorTest/InstallDirectory"
  1640. )
  1641. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BundleGeneratorTest")
  1642. endif()
  1643. add_test(WarnUnusedUnusedViaSet ${CMAKE_CTEST_COMMAND}
  1644. --build-and-test
  1645. "${CMake_SOURCE_DIR}/Tests/VariableUnusedViaSet"
  1646. "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaSet"
  1647. ${build_generator_args}
  1648. --build-noclean
  1649. --build-project WarnUnusedUnusedViaSet
  1650. --build-options ${build_options}
  1651. "--warn-unused-vars")
  1652. set_tests_properties(WarnUnusedUnusedViaSet PROPERTIES
  1653. PASS_REGULAR_EXPRESSION "unused variable \\(changing definition\\) 'UNUSED_VARIABLE'")
  1654. set_tests_properties(WarnUnusedUnusedViaSet PROPERTIES
  1655. FAIL_REGULAR_EXPRESSION "unused variable \\(unsetting\\) 'UNUSED_VARIABLE'")
  1656. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaSet")
  1657. add_test(WarnUnusedUnusedViaUnset ${CMAKE_CTEST_COMMAND}
  1658. --build-and-test
  1659. "${CMake_SOURCE_DIR}/Tests/VariableUnusedViaUnset"
  1660. "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaUnset"
  1661. ${build_generator_args}
  1662. --build-noclean
  1663. --build-project WarnUnusedUnusedViaUnset
  1664. --build-options ${build_options}
  1665. "--warn-unused-vars")
  1666. set_tests_properties(WarnUnusedUnusedViaUnset PROPERTIES
  1667. PASS_REGULAR_EXPRESSION "CMake Warning .*VariableUnusedViaUnset.CMakeLists.txt:7 \\(set\\):")
  1668. set_tests_properties(WarnUnusedUnusedViaUnset PROPERTIES
  1669. FAIL_REGULAR_EXPRESSION "CMake Warning .*VariableUnusedViaUnset.CMakeLists.txt:5 \\(set\\):")
  1670. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaUnset")
  1671. if("${CMAKE_GENERATOR}" MATCHES "Makefile" AND NOT WIN32)
  1672. # Ninja does not support ADDITIONAL_MAKE_CLEAN_FILES and therefore fails
  1673. # this test. (See #13371)
  1674. # Apparently Visual Studio does not support it either. As the MakeClean
  1675. # test above is only run with the Makefiles generator, only run this
  1676. # test with the Makefiles generator also.
  1677. add_test(WarnUnusedCliUnused ${CMAKE_CTEST_COMMAND}
  1678. --build-and-test
  1679. "${CMake_SOURCE_DIR}/Tests/WarnUnusedCliUnused"
  1680. "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused"
  1681. ${build_generator_args}
  1682. --build-project WarnUnusedCliUnused
  1683. --build-options ${build_options}
  1684. "-DUNUSED_CLI_VARIABLE=Unused")
  1685. set_tests_properties(WarnUnusedCliUnused PROPERTIES
  1686. PASS_REGULAR_EXPRESSION "CMake Warning:.*Manually-specified variables were not used by the project:.* UNUSED_CLI_VARIABLE")
  1687. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused")
  1688. endif()
  1689. add_test(WarnUnusedCliUsed ${CMAKE_CTEST_COMMAND}
  1690. --build-and-test
  1691. "${CMake_SOURCE_DIR}/Tests/VariableUsage"
  1692. "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUsed"
  1693. ${build_generator_args}
  1694. --build-noclean
  1695. --build-project WarnUnusedCliUsed
  1696. --build-options ${build_options}
  1697. "-DUSED_VARIABLE=Usage proven")
  1698. set_tests_properties(WarnUnusedCliUsed PROPERTIES
  1699. PASS_REGULAR_EXPRESSION "Usage proven")
  1700. set_tests_properties(WarnUnusedCliUsed PROPERTIES
  1701. FAIL_REGULAR_EXPRESSION "CMake Warning: The variable, 'USED_VARIABLE'")
  1702. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUsed")
  1703. add_test(WarnUninitialized ${CMAKE_CTEST_COMMAND}
  1704. --build-and-test
  1705. "${CMake_SOURCE_DIR}/Tests/VariableUsage"
  1706. "${CMake_BINARY_DIR}/Tests/WarnUninitialized"
  1707. ${build_generator_args}
  1708. --build-noclean
  1709. --build-project WarnUninitialized
  1710. --build-options ${build_options}
  1711. "--warn-uninitialized")
  1712. set_tests_properties(WarnUninitialized PROPERTIES
  1713. PASS_REGULAR_EXPRESSION "uninitialized variable 'USED_VARIABLE'")
  1714. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUninitialized")
  1715. add_test(TestsWorkingDirectory ${CMAKE_CTEST_COMMAND}
  1716. --build-and-test
  1717. "${CMake_SOURCE_DIR}/Tests/TestsWorkingDirectory"
  1718. "${CMake_BINARY_DIR}/Tests/TestsWorkingDirectory"
  1719. ${build_generator_args}
  1720. --build-project TestsWorkingDirectoryProj
  1721. --build-exe-dir "${CMake_BINARY_DIR}/Tests/TestsWorkingDirectory"
  1722. --force-new-ctest-process
  1723. --build-options ${build_options}
  1724. --test-command ${CMAKE_CTEST_COMMAND} -V -C \${CTEST_CONFIGURATION_TYPE}
  1725. )
  1726. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/TestsWorkingDirectory")
  1727. # Make sure CTest can handle a test with no newline in output.
  1728. add_test(CTest.NoNewline
  1729. ${CMAKE_CMAKE_COMMAND} -E echo_append "This line has no newline!")
  1730. # A simple test for ctest in script mode
  1731. configure_file("${CMake_SOURCE_DIR}/Tests/CTestScriptMode/CTestTestScriptMode.cmake.in"
  1732. "${CMake_BINARY_DIR}/Tests/CTestScriptMode/CTestTestScriptMode.cmake" @ONLY)
  1733. # add_test(CTest.ScriptMode ${CMAKE_CTEST_COMMAND}
  1734. # -S "${CMake_BINARY_DIR}/Tests/CTestScriptMode/CTestTestScriptMode.cmake"
  1735. # )
  1736. # A test for ctest_build() with targets in subdirectories
  1737. set(ctest_configure_options)
  1738. if(CMAKE_GENERATOR_TOOLSET)
  1739. list(APPEND ctest_configure_options -T ${CMAKE_GENERATOR_TOOLSET})
  1740. endif()
  1741. if(CMake_TEST_EXPLICIT_MAKE_PROGRAM)
  1742. list(APPEND ctest_configure_options -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM})
  1743. endif()
  1744. configure_file("${CMake_SOURCE_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in"
  1745. "${CMake_BINARY_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake" @ONLY)
  1746. unset(ctest_configure_options)
  1747. add_test(CTest.BuildCommand.ProjectInSubdir
  1748. ${CMAKE_CTEST_COMMAND} -S "${CMake_BINARY_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake")
  1749. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CTestBuildCommandProjectInSubdir/Nested")
  1750. set(CTEST_TEST_UPDATE 1)
  1751. if(CTEST_TEST_UPDATE)
  1752. # Test CTest Update with Subversion
  1753. find_package(Subversion QUIET)
  1754. if(Subversion_FOUND)
  1755. get_filename_component(_Subversion_BIN_DIR
  1756. ${Subversion_SVN_EXECUTABLE} PATH)
  1757. find_program(Subversion_SVNADMIN_EXECUTABLE svnadmin
  1758. HINTS ${_Subversion_BIN_DIR}
  1759. )
  1760. mark_as_advanced(Subversion_SVNADMIN_EXECUTABLE)
  1761. if(NOT Subversion_SVNADMIN_EXECUTABLE)
  1762. set(Subversion_FOUND FALSE)
  1763. endif()
  1764. endif()
  1765. if(Subversion_FOUND)
  1766. set(CTestUpdateSVN_DIR "CTest UpdateSVN")
  1767. configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateSVN.cmake.in"
  1768. "${CMake_BINARY_DIR}/Tests/CTestUpdateSVN.cmake" @ONLY)
  1769. add_test(CTest.UpdateSVN ${CMAKE_CMAKE_COMMAND}
  1770. -P "${CMake_BINARY_DIR}/Tests/CTestUpdateSVN.cmake"
  1771. )
  1772. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateSVN_DIR}")
  1773. endif()
  1774. # Test CTest Update with CVS
  1775. if(EXISTS ${CMAKE_ROOT}/Modules/FindCVS.cmake)
  1776. find_package(CVS QUIET)
  1777. else()
  1778. find_program(CVS_EXECUTABLE NAMES cvs)
  1779. set(CVS_FOUND ${CVS_EXECUTABLE})
  1780. endif()
  1781. set(CTEST_TEST_UPDATE_CVS ${CVS_FOUND})
  1782. if(CTEST_TEST_UPDATE_CVS AND NOT UNIX)
  1783. if("${CVS_EXECUTABLE}" MATCHES "cygwin")
  1784. message(STATUS "No CTest.UpdateCVS test with cygwin cvs.exe outside cygwin!")
  1785. set(CTEST_TEST_UPDATE_CVS 0)
  1786. endif()
  1787. endif()
  1788. if(CTEST_TEST_UPDATE_CVS)
  1789. set(CTestUpdateCVS_DIR "CTest UpdateCVS")
  1790. configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateCVS.cmake.in"
  1791. "${CMake_BINARY_DIR}/Tests/CTestUpdateCVS.cmake" @ONLY)
  1792. add_test(CTest.UpdateCVS ${CMAKE_CMAKE_COMMAND}
  1793. -P "${CMake_BINARY_DIR}/Tests/CTestUpdateCVS.cmake"
  1794. )
  1795. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateCVS_DIR}")
  1796. endif()
  1797. # Test CTest Update with BZR
  1798. find_program(BZR_EXECUTABLE NAMES bzr)
  1799. mark_as_advanced(BZR_EXECUTABLE)
  1800. set(CTEST_TEST_UPDATE_BZR 0)
  1801. if(BZR_EXECUTABLE)
  1802. if(NOT "${BZR_EXECUTABLE}" MATCHES "cygwin" OR UNIX)
  1803. set(CTEST_TEST_UPDATE_BZR 1)
  1804. endif()
  1805. endif()
  1806. if(CTEST_TEST_UPDATE_BZR)
  1807. # Check if xmloutput plugin is there
  1808. execute_process(COMMAND ${BZR_EXECUTABLE} xmlplugins RESULT_VARIABLE xmlplugres
  1809. OUTPUT_QUIET ERROR_QUIET)
  1810. if( NOT ${xmlplugres} )
  1811. set(CTestUpdateBZR_DIR "CTest UpdateBZR")
  1812. configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateBZR.cmake.in"
  1813. "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR.cmake" @ONLY)
  1814. add_test(CTest.UpdateBZR ${CMAKE_CMAKE_COMMAND}
  1815. -P "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR.cmake"
  1816. )
  1817. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateBZR_DIR}")
  1818. set(CTestUpdateBZR_DIR "CTest UpdateBZR_CLocale")
  1819. configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateBZR.cmake.in"
  1820. "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR_CLocale.cmake" @ONLY)
  1821. add_test(CTest.UpdateBZR.CLocale ${CMAKE_CMAKE_COMMAND}
  1822. -P "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR_CLocale.cmake"
  1823. )
  1824. set_tests_properties(CTest.UpdateBZR.CLocale PROPERTIES ENVIRONMENT LC_ALL=C)
  1825. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateBZR_DIR}")
  1826. endif()
  1827. endif()
  1828. # Test CTest Update with GIT
  1829. find_program(GIT_EXECUTABLE NAMES git)
  1830. mark_as_advanced(GIT_EXECUTABLE)
  1831. set(CTEST_TEST_UPDATE_GIT 0)
  1832. if(GIT_EXECUTABLE)
  1833. if(NOT "${GIT_EXECUTABLE}" MATCHES "cygwin" OR UNIX)
  1834. set(CTEST_TEST_UPDATE_GIT 1)
  1835. endif()
  1836. endif()
  1837. if(CTEST_TEST_UPDATE_GIT)
  1838. set(CTestUpdateGIT_DIR "CTest UpdateGIT")
  1839. configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateGIT.cmake.in"
  1840. "${CMake_BINARY_DIR}/Tests/CTestUpdateGIT.cmake" @ONLY)
  1841. add_test(CTest.UpdateGIT ${CMAKE_CMAKE_COMMAND}
  1842. -P "${CMake_BINARY_DIR}/Tests/CTestUpdateGIT.cmake"
  1843. )
  1844. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateGIT_DIR}")
  1845. endif()
  1846. # Test CTest Update with HG
  1847. find_program(HG_EXECUTABLE NAMES hg)
  1848. mark_as_advanced(HG_EXECUTABLE)
  1849. set(CTEST_TEST_UPDATE_HG 0)
  1850. if(HG_EXECUTABLE)
  1851. if(NOT "${HG_EXECUTABLE}" MATCHES "cygwin" OR UNIX)
  1852. set(CTEST_TEST_UPDATE_HG 1)
  1853. endif()
  1854. endif()
  1855. if(CTEST_TEST_UPDATE_HG)
  1856. set(CTestUpdateHG_DIR "CTest UpdateHG")
  1857. configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateHG.cmake.in"
  1858. "${CMake_BINARY_DIR}/Tests/CTestUpdateHG.cmake" @ONLY)
  1859. add_test(CTest.UpdateHG ${CMAKE_CMAKE_COMMAND}
  1860. -P "${CMake_BINARY_DIR}/Tests/CTestUpdateHG.cmake"
  1861. )
  1862. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateHG_DIR}")
  1863. endif()
  1864. # Test CTest Update with P4
  1865. find_program(P4_EXECUTABLE NAMES p4)
  1866. find_program(P4D_EXECUTABLE NAMES p4d)
  1867. mark_as_advanced(P4_EXECUTABLE P4D_EXECUTABLE)
  1868. set(CTEST_TEST_UPDATE_P4 0)
  1869. if(P4_EXECUTABLE AND P4D_EXECUTABLE)
  1870. if(NOT "${P4_EXECUTABLE};${P4D_EXECUTABLE}" MATCHES "cygwin" OR UNIX)
  1871. set(CTEST_TEST_UPDATE_P4 1)
  1872. endif()
  1873. endif()
  1874. if(CTEST_TEST_UPDATE_P4)
  1875. set(CTestUpdateP4_DIR "CTest UpdateP4")
  1876. configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateP4.cmake.in"
  1877. "${CMake_BINARY_DIR}/Tests/CTestUpdateP4.cmake" @ONLY)
  1878. add_test(CTest.UpdateP4 ${CMAKE_CMAKE_COMMAND}
  1879. -P "${CMake_BINARY_DIR}/Tests/CTestUpdateP4.cmake"
  1880. )
  1881. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateP4_DIR}")
  1882. endif()
  1883. endif()
  1884. configure_file(
  1885. "${CMake_SOURCE_DIR}/Tests/CTestTestFailure/testNoBuild.cmake.in"
  1886. "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testNoBuild.cmake"
  1887. @ONLY ESCAPE_QUOTES)
  1888. add_test(CTestTestNoBuild ${CMAKE_CTEST_COMMAND}
  1889. -S "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testNoBuild.cmake" -V
  1890. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testOut1.log"
  1891. )
  1892. set_tests_properties(CTestTestNoBuild PROPERTIES
  1893. FAIL_REGULAR_EXPRESSION "Error" WILL_FAIL true)
  1894. configure_file(
  1895. "${CMake_SOURCE_DIR}/Tests/CTestTestFailure/testNoExe.cmake.in"
  1896. "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testNoExe.cmake"
  1897. @ONLY ESCAPE_QUOTES)
  1898. add_test(CTestTestNoExe ${CMAKE_CTEST_COMMAND}
  1899. -S "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testNoExe.cmake" -V
  1900. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testOut2.log"
  1901. )
  1902. set_tests_properties(CTestTestNoExe PROPERTIES DEPENDS CTestTestNoBuild
  1903. PASS_REGULAR_EXPRESSION "Could not find executable"
  1904. FAIL_REGULAR_EXPRESSION "SegFault")
  1905. configure_file(
  1906. "${CMake_SOURCE_DIR}/Tests/CTestTestUpload/test.cmake.in"
  1907. "${CMake_BINARY_DIR}/Tests/CTestTestUpload/test.cmake"
  1908. @ONLY ESCAPE_QUOTES)
  1909. add_test(CTestTestUpload ${CMAKE_CTEST_COMMAND}
  1910. -S "${CMake_BINARY_DIR}/Tests/CTestTestUpload/test.cmake" -V
  1911. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestUpload/testOut.log"
  1912. )
  1913. set_tests_properties(CTestTestUpload PROPERTIES
  1914. PASS_REGULAR_EXPRESSION "Upload\\.xml")
  1915. configure_file(
  1916. "${CMake_SOURCE_DIR}/Tests/CTestTestEmptyBinaryDirectory/test.cmake.in"
  1917. "${CMake_BINARY_DIR}/Tests/CTestTestEmptyBinaryDirectory/test.cmake"
  1918. @ONLY ESCAPE_QUOTES)
  1919. add_test(CTestTestEmptyBinaryDirectory ${CMAKE_CTEST_COMMAND}
  1920. -S "${CMake_BINARY_DIR}/Tests/CTestTestEmptyBinaryDirectory/test.cmake" -V
  1921. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestEmptyBinaryDirectory/testOut.log"
  1922. )
  1923. set_tests_properties(CTestTestEmptyBinaryDirectory PROPERTIES
  1924. PASS_REGULAR_EXPRESSION "TEST_SUCCESS")
  1925. configure_file(
  1926. "${CMake_SOURCE_DIR}/Tests/CTestTestConfigFileInBuildDir/test1.cmake.in"
  1927. "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir1/test1.cmake"
  1928. @ONLY ESCAPE_QUOTES)
  1929. add_test(CTestTestConfigFileInBuildDir1 ${CMAKE_CTEST_COMMAND}
  1930. -S "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir1/test1.cmake" -V
  1931. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir1/testOut1.log"
  1932. )
  1933. REGEX_ESCAPE_STRING(CTEST_TEST_ESCAPED_SOURCE_DIR "${CMake_SOURCE_DIR}")
  1934. set_tests_properties(CTestTestConfigFileInBuildDir1 PROPERTIES DEPENDS CTestTestNoBuild
  1935. PASS_REGULAR_EXPRESSION
  1936. "Reading ctest configuration file: ${CTEST_TEST_ESCAPED_SOURCE_DIR}.Tests.CTestTestConfigFileInBuildDir.CTestConfig.cmake")
  1937. configure_file(
  1938. "${CMake_SOURCE_DIR}/Tests/CTestTestConfigFileInBuildDir/test2.cmake.in"
  1939. "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir2/test2.cmake"
  1940. @ONLY ESCAPE_QUOTES)
  1941. configure_file(
  1942. "${CMake_SOURCE_DIR}/Tests/CTestTestConfigFileInBuildDir/CTestConfig.cmake"
  1943. "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir2/CTestConfig.cmake"
  1944. @ONLY ESCAPE_QUOTES COPYONLY)
  1945. add_test(CTestTestConfigFileInBuildDir2 ${CMAKE_CTEST_COMMAND}
  1946. -S "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir2/test2.cmake" -V
  1947. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir2/testOut2.log"
  1948. )
  1949. REGEX_ESCAPE_STRING(CTEST_TEST_ESCAPED_BINARY_DIR "${CMake_BINARY_DIR}")
  1950. set_tests_properties(CTestTestConfigFileInBuildDir2 PROPERTIES DEPENDS CTestTestNoBuild
  1951. REQUIRED_FILES ${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir2/CTestConfig.cmake
  1952. PASS_REGULAR_EXPRESSION
  1953. "Reading ctest configuration file: ${CTEST_TEST_ESCAPED_BINARY_DIR}.Tests.CTestTestConfigFileInBuildDir2.CTestConfig.cmake")
  1954. # test coverage for mumps
  1955. # create a MumpsCoverage dir in the binary tree under Testing to
  1956. # avoid the .NoDartCoverage files in the cmake testing tree
  1957. configure_file(
  1958. "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/DartConfiguration.tcl.in"
  1959. "${CMake_BINARY_DIR}/Testing/MumpsCoverage/DartConfiguration.tcl")
  1960. configure_file(
  1961. "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/gtm_coverage.mcov.in"
  1962. "${CMake_BINARY_DIR}/Testing/MumpsCoverage/gtm_coverage.mcov")
  1963. file(REMOVE_RECURSE "${CMake_BINARY_DIR}/Testing/MumpsCoverage/VistA-FOIA")
  1964. file(COPY "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/VistA-FOIA"
  1965. DESTINATION "${CMake_BINARY_DIR}/Testing/MumpsCoverage")
  1966. add_test(NAME CTestGTMCoverage
  1967. COMMAND cmake -E chdir
  1968. ${CMake_BINARY_DIR}/Testing/MumpsCoverage
  1969. $<TARGET_FILE:ctest> -T Coverage --debug)
  1970. set_tests_properties(CTestGTMCoverage PROPERTIES
  1971. PASS_REGULAR_EXPRESSION
  1972. "Process file.*ZZCOVTST.m.*Total LOC:.*23.*Percentage Coverage: 82.61*"
  1973. ENVIRONMENT COVFILE=)
  1974. configure_file(
  1975. "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/DartConfiguration.cache.tcl.in"
  1976. "${CMake_BINARY_DIR}/Testing/MumpsCacheCoverage/DartConfiguration.tcl")
  1977. configure_file(
  1978. "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/cache_coverage.cmcov.in"
  1979. "${CMake_BINARY_DIR}/Testing/MumpsCacheCoverage/cache_coverage.cmcov")
  1980. file(REMOVE_RECURSE "${CMake_BINARY_DIR}/Testing/MumpsCacheCoverage/VistA-FOIA")
  1981. file(COPY "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/VistA-FOIA"
  1982. DESTINATION "${CMake_BINARY_DIR}/Testing/MumpsCacheCoverage")
  1983. add_test(NAME CTestCacheCoverage
  1984. COMMAND cmake -E chdir
  1985. ${CMake_BINARY_DIR}/Testing/MumpsCacheCoverage
  1986. $<TARGET_FILE:ctest> -T Coverage --debug)
  1987. set_tests_properties(CTestCacheCoverage PROPERTIES
  1988. PASS_REGULAR_EXPRESSION
  1989. "Process file.*ZZCOVTST.m.*Total LOC:.*22.*Percentage Coverage: 86.36.*"
  1990. ENVIRONMENT COVFILE=)
  1991. # Adding a test case for Python Coverage
  1992. configure_file(
  1993. "${CMake_SOURCE_DIR}/Tests/PythonCoverage/coverage.xml.in"
  1994. "${CMake_BINARY_DIR}/Testing/PythonCoverage/coverage.xml")
  1995. configure_file(
  1996. "${CMake_SOURCE_DIR}/Tests/PythonCoverage/DartConfiguration.tcl.in"
  1997. "${CMake_BINARY_DIR}/Testing/PythonCoverage/DartConfiguration.tcl")
  1998. file(COPY "${CMake_SOURCE_DIR}/Tests/PythonCoverage/coveragetest"
  1999. DESTINATION "${CMake_BINARY_DIR}/Testing/PythonCoverage")
  2000. add_test(NAME CTestPythonCoverage
  2001. COMMAND cmake -E chdir
  2002. ${CMake_BINARY_DIR}/Testing/PythonCoverage
  2003. $<TARGET_FILE:ctest> -T Coverage --debug)
  2004. set_tests_properties(CTestPythonCoverage PROPERTIES
  2005. PASS_REGULAR_EXPRESSION
  2006. "Process file.*foo.py.*Total LOC:.*13.*Percentage Coverage: 84.62.*"
  2007. ENVIRONMENT COVFILE=)
  2008. function(add_config_tests cfg)
  2009. set(base "${CMake_BINARY_DIR}/Tests/CTestConfig")
  2010. # Test -S script with a -C config arg to ctest:
  2011. configure_file(
  2012. "${CMake_SOURCE_DIR}/Tests/CTestConfig/script.cmake.in"
  2013. "${base}/${cfg}-script.cmake"
  2014. @ONLY ESCAPE_QUOTES)
  2015. add_test(CTestConfig.Script.${cfg} ${CMAKE_CTEST_COMMAND}
  2016. -C ${cfg}
  2017. -S "${base}/${cfg}-script.cmake" -VV
  2018. --output-log "${base}/${cfg}-script.log"
  2019. )
  2020. # Test -D dashboard with a -C config arg to ctest.
  2021. # (Actual commands inside a cmake -P script because we need to be able to set
  2022. # the working directory reliably...)
  2023. configure_file(
  2024. "${CMake_SOURCE_DIR}/Tests/CTestConfig/dashboard.cmake.in"
  2025. "${base}/${cfg}-dashboard.cmake"
  2026. @ONLY ESCAPE_QUOTES)
  2027. add_test(CTestConfig.Dashboard.${cfg} ${CMAKE_CMAKE_COMMAND}
  2028. -P "${base}/${cfg}-dashboard.cmake" -VV
  2029. )
  2030. endfunction()
  2031. add_config_tests(Debug)
  2032. add_config_tests(MinSizeRel)
  2033. add_config_tests(Release)
  2034. add_config_tests(RelWithDebInfo)
  2035. # Test -S script with some -D variable definition args to ctest:
  2036. add_test(CTestConfig.ScriptWithArgs ${CMAKE_CTEST_COMMAND}
  2037. -C "Release"
  2038. -D arg1=this
  2039. -D arg2=that
  2040. -D "arg3=the other"
  2041. "-Darg4=this is the fourth"
  2042. -Darg5=the_fifth
  2043. -Darg6:STRING=value-with-type
  2044. -S "${CMake_SOURCE_DIR}/Tests/CTestConfig/ScriptWithArgs.cmake" -VV
  2045. --output-log "${CMake_BINARY_DIR}/Tests/CTestConfig/ScriptWithArgs.log"
  2046. )
  2047. ADD_TEST_MACRO(CMakeCommands.add_compile_options add_compile_options)
  2048. ADD_TEST_MACRO(CMakeCommands.target_link_libraries target_link_libraries)
  2049. ADD_TEST_MACRO(CMakeCommands.target_include_directories target_include_directories)
  2050. ADD_TEST_MACRO(CMakeCommands.target_compile_definitions target_compile_definitions)
  2051. ADD_TEST_MACRO(CMakeCommands.target_compile_options target_compile_options)
  2052. configure_file(
  2053. "${CMake_SOURCE_DIR}/Tests/CTestTestCrash/test.cmake.in"
  2054. "${CMake_BINARY_DIR}/Tests/CTestTestCrash/test.cmake"
  2055. @ONLY ESCAPE_QUOTES)
  2056. add_test(CTestTestCrash ${CMAKE_CTEST_COMMAND}
  2057. -S "${CMake_BINARY_DIR}/Tests/CTestTestCrash/test.cmake" -V
  2058. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestCrash/testOutput.log"
  2059. )
  2060. # with watcom the SEGFAULT is not found, it just fails
  2061. if(CMAKE_GENERATOR MATCHES "Watcom WMake")
  2062. set_tests_properties(CTestTestCrash PROPERTIES
  2063. PASS_REGULAR_EXPRESSION "Failed")
  2064. else()
  2065. set_tests_properties(CTestTestCrash PROPERTIES
  2066. PASS_REGULAR_EXPRESSION "(Illegal|SegFault)")
  2067. endif()
  2068. configure_file(
  2069. "${CMake_SOURCE_DIR}/Tests/CTestTestBadExe/test.cmake.in"
  2070. "${CMake_BINARY_DIR}/Tests/CTestTestBadExe/test.cmake"
  2071. @ONLY ESCAPE_QUOTES)
  2072. add_test(CTestTestBadExe ${CMAKE_CTEST_COMMAND}
  2073. -S "${CMake_BINARY_DIR}/Tests/CTestTestBadExe/test.cmake" -V
  2074. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestBadExe/testOutput.log"
  2075. )
  2076. set(CTestTestBadExe_REGEX "BAD_COMMAND")
  2077. # some cygwin can not be made to produce a BAD_COMMAND error
  2078. # the best we can get from it is a failed test
  2079. if(CYGWIN)
  2080. set(CTestTestBadExe_REGEX "(\\*\\*\\*Failed)|BAD_COMMAND")
  2081. endif()
  2082. set_tests_properties(CTestTestBadExe PROPERTIES
  2083. PASS_REGULAR_EXPRESSION "${CTestTestBadExe_REGEX}")
  2084. configure_file(
  2085. "${CMake_SOURCE_DIR}/Tests/CTestTestParallel/test.cmake.in"
  2086. "${CMake_BINARY_DIR}/Tests/CTestTestParallel/test.cmake"
  2087. @ONLY ESCAPE_QUOTES)
  2088. add_test(CTestTestParallel ${CMAKE_CTEST_COMMAND}
  2089. -S "${CMake_BINARY_DIR}/Tests/CTestTestParallel/test.cmake" -V
  2090. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestParallel/testOutput.log"
  2091. )
  2092. configure_file(
  2093. "${CMake_SOURCE_DIR}/Tests/CTestTestSkipReturnCode/test.cmake.in"
  2094. "${CMake_BINARY_DIR}/Tests/CTestTestSkipReturnCode/test.cmake"
  2095. @ONLY ESCAPE_QUOTES)
  2096. add_test(CTestTestSkipReturnCode ${CMAKE_CTEST_COMMAND}
  2097. -S "${CMake_BINARY_DIR}/Tests/CTestTestSkipReturnCode/test.cmake" -V
  2098. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestSkipReturnCode/testOutput.log"
  2099. -C \${CTEST_CONFIGURATION_TYPE}
  2100. )
  2101. set_tests_properties(CTestTestSkipReturnCode PROPERTIES
  2102. PASS_REGULAR_EXPRESSION "CMakeV1 \\.* +Passed.*CMakeV2 \\.+\\*+Skipped")
  2103. ADD_TEST_MACRO(CTestTestSerialInDepends ${CMAKE_CTEST_COMMAND} -j 4
  2104. --output-on-failure -C "\${CTestTest_CONFIG}")
  2105. ADD_TEST_MACRO(CTestTestMissingDependsExe ${CMAKE_CTEST_COMMAND}
  2106. --output-on-failure -C "\${CTestTest_CONFIG}")
  2107. set_tests_properties(CTestTestMissingDependsExe PROPERTIES
  2108. PASS_REGULAR_EXPRESSION "\\*\\*\\*Not Run"
  2109. )
  2110. ADD_TEST_MACRO(CTestTestSerialOrder ${CMAKE_CTEST_COMMAND}
  2111. --output-on-failure -C "\${CTestTest_CONFIG}")
  2112. if(NOT BORLAND)
  2113. set(CTestLimitDashJ_CTEST_OPTIONS --force-new-ctest-process)
  2114. add_test_macro(CTestLimitDashJ ${CMAKE_CTEST_COMMAND} -j 4
  2115. --output-on-failure -C "\${CTestTest_CONFIG}")
  2116. endif()
  2117. add_test(CTestTestPrintLabels ${CMAKE_CTEST_COMMAND} --print-labels)
  2118. set_tests_properties(CTestTestPrintLabels PROPERTIES LABELS "Label1;Label2")
  2119. set_tests_properties(CTestTestPrintLabels PROPERTIES PASS_REGULAR_EXPRESSION
  2120. "All Labels:.* Label1.* Label2")
  2121. configure_file(
  2122. "${CMake_SOURCE_DIR}/Tests/CTestTestResourceLock/test.cmake.in"
  2123. "${CMake_BINARY_DIR}/Tests/CTestTestResourceLock/test.cmake"
  2124. @ONLY ESCAPE_QUOTES)
  2125. add_test(CTestTestResourceLock ${CMAKE_CTEST_COMMAND}
  2126. -S "${CMake_BINARY_DIR}/Tests/CTestTestResourceLock/test.cmake" -V
  2127. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestResourceLock/output.log"
  2128. )
  2129. configure_file(
  2130. "${CMake_SOURCE_DIR}/Tests/CTestTestScheduler/test.cmake.in"
  2131. "${CMake_BINARY_DIR}/Tests/CTestTestScheduler/test.cmake"
  2132. @ONLY ESCAPE_QUOTES)
  2133. add_test(CTestTestScheduler ${CMAKE_CTEST_COMMAND}
  2134. -S "${CMake_BINARY_DIR}/Tests/CTestTestScheduler/test.cmake" -V
  2135. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestScheduler/testOutput.log"
  2136. )
  2137. set_tests_properties(CTestTestScheduler PROPERTIES
  2138. PASS_REGULAR_EXPRESSION "Start 1.*Start 2.*Start 3.*Start 4.*Start 4.*Start 3.*Start 2.*Start 1"
  2139. RESOURCE_LOCK "CostData")
  2140. configure_file(
  2141. "${CMake_SOURCE_DIR}/Tests/CTestTestCostSerial/test.cmake.in"
  2142. "${CMake_BINARY_DIR}/Tests/CTestTestCostSerial/test.cmake"
  2143. @ONLY ESCAPE_QUOTES)
  2144. add_test(CTestTestCostSerial ${CMAKE_CTEST_COMMAND}
  2145. -S "${CMake_BINARY_DIR}/Tests/CTestTestCostSerial/test.cmake" -V
  2146. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestCostSerial/testOutput.log"
  2147. )
  2148. set_tests_properties(CTestTestCostSerial PROPERTIES
  2149. PASS_REGULAR_EXPRESSION "Start 2.*Start 3.*Start 1.*Start 2.*Start 3.*Start 1"
  2150. RESOURCE_LOCK "CostData")
  2151. configure_file(
  2152. "${CMake_SOURCE_DIR}/Tests/CTestTestStopTime/test.cmake.in"
  2153. "${CMake_BINARY_DIR}/Tests/CTestTestStopTime/test.cmake"
  2154. @ONLY ESCAPE_QUOTES)
  2155. configure_file(
  2156. "${CMake_SOURCE_DIR}/Tests/CTestTestStopTime/GetDate.cmake"
  2157. "${CMake_BINARY_DIR}/Tests/CTestTestStopTime/GetDate.cmake"
  2158. COPYONLY)
  2159. add_test(CTestTestStopTime ${CMAKE_CTEST_COMMAND}
  2160. -S "${CMake_BINARY_DIR}/Tests/CTestTestStopTime/test.cmake" -V
  2161. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestStopTime/testOutput.log"
  2162. )
  2163. set_tests_properties(CTestTestStopTime PROPERTIES
  2164. PASS_REGULAR_EXPRESSION "The stop time has been passed")
  2165. configure_file(
  2166. "${CMake_SOURCE_DIR}/Tests/CTestTestSubdir/test.cmake.in"
  2167. "${CMake_BINARY_DIR}/Tests/CTestTestSubdir/test.cmake"
  2168. @ONLY ESCAPE_QUOTES)
  2169. add_test(CTestTestSubdir ${CMAKE_CTEST_COMMAND}
  2170. -S "${CMake_BINARY_DIR}/Tests/CTestTestSubdir/test.cmake" -V
  2171. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestSubdir/testOutput.log"
  2172. )
  2173. #make sure all 3 subdirs were added
  2174. set_tests_properties(CTestTestSubdir PROPERTIES
  2175. PASS_REGULAR_EXPRESSION "0 tests failed out of 3")
  2176. configure_file(
  2177. "${CMake_SOURCE_DIR}/Tests/CTestTestTimeout/test.cmake.in"
  2178. "${CMake_BINARY_DIR}/Tests/CTestTestTimeout/test.cmake"
  2179. @ONLY ESCAPE_QUOTES)
  2180. add_test(CTestTestTimeout ${CMAKE_CTEST_COMMAND}
  2181. -C "\${CTestTest_CONFIG}"
  2182. -S "${CMake_BINARY_DIR}/Tests/CTestTestTimeout/test.cmake" -V
  2183. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestTimeout/testOutput.log"
  2184. )
  2185. set_tests_properties(CTestTestTimeout PROPERTIES
  2186. PASS_REGULAR_EXPRESSION "TestTimeout *\\.+ *\\*\\*\\*Timeout.*CheckChild *\\.+ *Passed")
  2187. add_test(
  2188. NAME CTestTestRerunFailed
  2189. COMMAND ${CMAKE_CTEST_COMMAND} --rerun-failed)
  2190. set_tests_properties(CTestTestRerunFailed PROPERTIES
  2191. PASS_REGULAR_EXPRESSION "1/1 Test #1: TestTimeout" DEPENDS CTestTestTimeout
  2192. WORKING_DIRECTORY ${CMake_BINARY_DIR}/Tests/CTestTestTimeout)
  2193. configure_file(
  2194. "${CMake_SOURCE_DIR}/Tests/CTestTestZeroTimeout/test.cmake.in"
  2195. "${CMake_BINARY_DIR}/Tests/CTestTestZeroTimeout/test.cmake"
  2196. @ONLY ESCAPE_QUOTES)
  2197. add_test(CTestTestZeroTimeout ${CMAKE_CTEST_COMMAND}
  2198. -S "${CMake_BINARY_DIR}/Tests/CTestTestZeroTimeout/test.cmake" -V
  2199. --output-log
  2200. "${CMake_BINARY_DIR}/Tests/CTestTestZeroTimeout/testOutput.log")
  2201. set_tests_properties(CTestTestZeroTimeout PROPERTIES
  2202. FAIL_REGULAR_EXPRESSION "\\*\\*\\*Timeout")
  2203. configure_file(
  2204. "${CMake_SOURCE_DIR}/Tests/CTestTestDepends/test.cmake.in"
  2205. "${CMake_BINARY_DIR}/Tests/CTestTestDepends/test.cmake"
  2206. @ONLY ESCAPE_QUOTES)
  2207. add_test(CTestTestDepends ${CMAKE_CTEST_COMMAND}
  2208. -C "\${CTestTest_CONFIG}"
  2209. -S "${CMake_BINARY_DIR}/Tests/CTestTestDepends/test.cmake" -V
  2210. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestDepends/testOutput.log"
  2211. )
  2212. configure_file(
  2213. "${CMake_SOURCE_DIR}/Tests/CTestTestCycle/test.cmake.in"
  2214. "${CMake_BINARY_DIR}/Tests/CTestTestCycle/test.cmake"
  2215. @ONLY ESCAPE_QUOTES)
  2216. add_test(CTestTestCycle ${CMAKE_CTEST_COMMAND}
  2217. -C "\${CTestTest_CONFIG}"
  2218. -S "${CMake_BINARY_DIR}/Tests/CTestTestCycle/test.cmake" -V
  2219. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestCycle/testOutput.log"
  2220. )
  2221. set_tests_properties(CTestTestCycle PROPERTIES
  2222. PASS_REGULAR_EXPRESSION "a cycle exists in the test dependency graph")
  2223. configure_file(
  2224. "${CMake_SOURCE_DIR}/Tests/CTestTestRunScript/test.cmake.in"
  2225. "${CMake_BINARY_DIR}/Tests/CTestTestRunScript/test.cmake"
  2226. @ONLY ESCAPE_QUOTES)
  2227. configure_file(
  2228. "${CMake_SOURCE_DIR}/Tests/CTestTestRunScript/hello.cmake.in"
  2229. "${CMake_BINARY_DIR}/Tests/CTestTestRunScript/hello.cmake"
  2230. @ONLY ESCAPE_QUOTES)
  2231. add_test(CTestTestRunScript ${CMAKE_CTEST_COMMAND}
  2232. -S "${CMake_BINARY_DIR}/Tests/CTestTestRunScript/test.cmake" -V
  2233. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestRunScript/testOutput.log"
  2234. )
  2235. add_test(CTestTestShowOnly ${CMAKE_CTEST_COMMAND} -N)
  2236. add_test(CTestBatchTest ${CMAKE_CTEST_COMMAND} -B)
  2237. configure_file(
  2238. "${CMake_SOURCE_DIR}/Tests/CTestTestFdSetSize/test.cmake.in"
  2239. "${CMake_BINARY_DIR}/Tests/CTestTestFdSetSize/test.cmake"
  2240. @ONLY ESCAPE_QUOTES)
  2241. add_test(CTestTestFdSetSize ${CMAKE_CTEST_COMMAND}
  2242. -S "${CMake_BINARY_DIR}/Tests/CTestTestFdSetSize/test.cmake" -j20 -V --timeout 120
  2243. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestFdSetSize/testOutput.log"
  2244. )
  2245. function(add_failed_submit_test name source build in out log regex)
  2246. configure_file("${in}" "${out}" @ONLY)
  2247. add_test(${name} ${CMAKE_CTEST_COMMAND} -S "${out}" -V --output-log "${log}")
  2248. set_tests_properties(${name} PROPERTIES PASS_REGULAR_EXPRESSION "${regex}")
  2249. endfunction()
  2250. set(regex "(Problems when submitting via S*CP")
  2251. set(regex "${regex}|Error message was: ")
  2252. set(regex "${regex}([Cc]ould *n.t resolve host")
  2253. set(regex "${regex}|[Cc]ould *n.t connect to host")
  2254. set(regex "${regex}|Failed connect to")
  2255. set(regex "${regex}|Empty reply from server")
  2256. set(regex "${regex}|The requested URL returned error")
  2257. set(regex "${regex}|libcurl was built with SSL disabled. https: not supported)")
  2258. set(regex "${regex}|Submission method .xmlrpc. not compiled into CTest")
  2259. set(regex "${regex}|Submission problem")
  2260. set(regex "${regex}|Submission successful)")
  2261. set(ctest_coverage_labels_args "")
  2262. foreach(drop_method cp ftp http https scp xmlrpc)
  2263. # Cycle through these values each time through the loop:
  2264. if(ctest_coverage_labels_args STREQUAL "")
  2265. set(ctest_coverage_labels_args "LABELS Everything")
  2266. elseif(ctest_coverage_labels_args STREQUAL "LABELS Everything")
  2267. set(ctest_coverage_labels_args "LABELS 0ArgTest")
  2268. else()
  2269. set(ctest_coverage_labels_args "")
  2270. endif()
  2271. add_failed_submit_test(CTestTestFailedSubmit-${drop_method}
  2272. "${CMake_SOURCE_DIR}/Tests/CTestTest/SmallAndFast"
  2273. "${CMake_BINARY_DIR}/Tests/CTestTestFailedSubmits/${drop_method}"
  2274. "${CMake_SOURCE_DIR}/Tests/CTestTestFailedSubmits/test.cmake.in"
  2275. "${CMake_BINARY_DIR}/Tests/CTestTestFailedSubmits/test-${drop_method}.cmake"
  2276. "${CMake_BINARY_DIR}/Tests/CTestTestFailedSubmits/test-${drop_method}.log"
  2277. "${regex}"
  2278. )
  2279. endforeach()
  2280. if (CMAKE_TESTS_CDASH_SERVER)
  2281. set(regex "^([^:]+)://([^/]+)(/.*)$")
  2282. if ("${CMAKE_TESTS_CDASH_SERVER}" MATCHES "${regex}")
  2283. set(protocol "${CMAKE_MATCH_1}")
  2284. set(server "${CMAKE_MATCH_2}")
  2285. set(path "${CMAKE_MATCH_3}")
  2286. else ()
  2287. set(protocol "http")
  2288. set(server "www.cdash.org")
  2289. set(path "/CDash")
  2290. message("warning: CMAKE_TESTS_CDASH_SERVER does not match expected regex...")
  2291. message(" ...using default url='${protocol}://${server}${path}' for CTestTest[23]")
  2292. endif ()
  2293. endif ()
  2294. if (CTEST_TEST_CTEST AND CMAKE_RUN_LONG_TESTS AND CMAKE_TESTS_CDASH_SERVER)
  2295. configure_file("${CMake_SOURCE_DIR}/Tests/CTestTest/test.cmake.in"
  2296. "${CMake_BINARY_DIR}/Tests/CTestTest/test.cmake" @ONLY ESCAPE_QUOTES)
  2297. add_test(CTestTest ${CMAKE_CTEST_COMMAND}
  2298. -S "${CMake_BINARY_DIR}/Tests/CTestTest/test.cmake" -V
  2299. --output-log "${CMake_BINARY_DIR}/Tests/CTestTest/testOutput.log"
  2300. )
  2301. configure_file("${CMake_SOURCE_DIR}/Tests/CTestTest2/test.cmake.in"
  2302. "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" @ONLY ESCAPE_QUOTES)
  2303. add_test(CTestTest2 ${CMAKE_CTEST_COMMAND}
  2304. -S "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" -V
  2305. --output-log "${CMake_BINARY_DIR}/Tests/CTestTest2/testOutput.log"
  2306. )
  2307. if("${CMAKE_GENERATOR}" MATCHES "Makefiles" OR "${CMAKE_GENERATOR}" MATCHES "Ninja")
  2308. configure_file("${CMake_SOURCE_DIR}/Tests/CTestTestLaunchers/test.cmake.in"
  2309. "${CMake_BINARY_DIR}/Tests/CTestTestLaunchers/test.cmake" @ONLY ESCAPE_QUOTES)
  2310. add_test(CTestTestLaunchers ${CMAKE_CTEST_COMMAND}
  2311. -S "${CMake_BINARY_DIR}/Tests/CTestTestLaunchers/test.cmake" -V
  2312. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestLaunchers/testOutput.log"
  2313. )
  2314. set_tests_properties(CTestTestLaunchers PROPERTIES
  2315. PASS_REGULAR_EXPRESSION "CTEST_TEST_LAUNCHER_SUCCESS")
  2316. endif()
  2317. configure_file("${CMake_SOURCE_DIR}/Tests/CTestTestChecksum/test.cmake.in"
  2318. "${CMake_BINARY_DIR}/Tests/CTestTestChecksum/test.cmake" @ONLY
  2319. ESCAPE_QUOTES)
  2320. add_test(CTestTestChecksum ${CMAKE_CTEST_COMMAND}
  2321. -S "${CMake_BINARY_DIR}/Tests/CTestTestChecksum/test.cmake" -V
  2322. --output-log
  2323. "${CMake_BINARY_DIR}/Tests/CTestTestChecksum/testOutput.log"
  2324. )
  2325. set_tests_properties(CTestTestChecksum PROPERTIES PASS_REGULAR_EXPRESSION
  2326. "Submission failed: Checksum failed for file")
  2327. # these tests take a long time, make sure they have it
  2328. # if timeouts have not already been set
  2329. get_test_property(CTestTest TIMEOUT PREVIOUS_TIMEOUT)
  2330. if ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND)
  2331. set_tests_properties ( CTestTest
  2332. PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT})
  2333. endif ()
  2334. get_test_property(CTestTest2 TIMEOUT PREVIOUS_TIMEOUT)
  2335. if ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND)
  2336. set_tests_properties ( CTestTest2
  2337. PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT})
  2338. endif ()
  2339. endif ()
  2340. if("${CMAKE_GENERATOR}" MATCHES Xcode)
  2341. set(CMAKE_SKIP_BOOTSTRAP_TEST 1)
  2342. endif()
  2343. if(EXISTS "${CMake_BINARY_DIR}/CMakeLists.txt")
  2344. # If there is CMakeLists.txt in the binary tree, assume in-source build
  2345. set(CMAKE_SKIP_BOOTSTRAP_TEST 1)
  2346. endif()
  2347. set(bootstrap "")
  2348. if(CMAKE_RUN_LONG_TESTS AND NOT CMAKE_SKIP_BOOTSTRAP_TEST)
  2349. if(UNIX)
  2350. set(bootstrap ${CMake_SOURCE_DIR}/bootstrap)
  2351. elseif(MSYS)
  2352. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/bootstrap.bat.in
  2353. ${CMAKE_CURRENT_BINARY_DIR}/bootstrap.bat @ONLY)
  2354. set(bootstrap ${CMAKE_CURRENT_BINARY_DIR}/bootstrap.bat)
  2355. endif()
  2356. endif()
  2357. if(bootstrap)
  2358. add_test(NAME BootstrapTest
  2359. COMMAND ${CMAKE_CMAKE_COMMAND}
  2360. -D "bootstrap=${bootstrap}"
  2361. -D "bin_dir=${CMake_BINARY_DIR}/Tests/BootstrapTest"
  2362. -P ${CMAKE_CURRENT_SOURCE_DIR}/BootstrapTest.cmake
  2363. )
  2364. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BootstrapTest")
  2365. # Make this test run early during parallel execution
  2366. set_tests_properties(BootstrapTest PROPERTIES COST 5000)
  2367. # provide more time for the bootstrap test
  2368. get_test_property(BootstrapTest TIMEOUT PREVIOUS_TIMEOUT)
  2369. if ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND)
  2370. set_tests_properties ( BootstrapTest
  2371. PROPERTIES TIMEOUT 5400)
  2372. endif ()
  2373. endif()
  2374. if(CMAKE_Fortran_COMPILER)
  2375. add_test(Fortran ${CMAKE_CTEST_COMMAND}
  2376. --build-and-test
  2377. "${CMake_SOURCE_DIR}/Tests/Fortran"
  2378. "${CMake_BINARY_DIR}/Tests/Fortran"
  2379. ${build_generator_args}
  2380. --build-project testf
  2381. --build-two-config
  2382. --build-options ${build_options}
  2383. -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM}
  2384. --test-command testf)
  2385. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Fortran")
  2386. # FortranCInterface tests.
  2387. if(UNIX)
  2388. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/FortranC/Flags.cmake.in
  2389. ${CMAKE_CURRENT_BINARY_DIR}/FortranC/Flags.cmake @ONLY)
  2390. add_test(FortranC.Flags ${CMAKE_CMAKE_COMMAND} -P
  2391. ${CMAKE_CURRENT_BINARY_DIR}/FortranC/Flags.cmake)
  2392. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/FortranC/Flags")
  2393. else()
  2394. add_test(FortranC ${CMAKE_CTEST_COMMAND}
  2395. --build-and-test
  2396. "${CMake_SOURCE_DIR}/Tests/FortranC"
  2397. "${CMake_BINARY_DIR}/Tests/FortranC"
  2398. ${build_generator_args}
  2399. --build-project FortranC
  2400. --build-two-config
  2401. --build-options ${build_options}
  2402. --test-command CMakeFiles/FortranCInterface/FortranCInterface)
  2403. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/FortranC")
  2404. endif()
  2405. endif()
  2406. find_package(Java COMPONENTS Development QUIET)
  2407. if(Java_JAVA_EXECUTABLE AND Java_JAVAC_EXECUTABLE AND Java_JAR_EXECUTABLE AND NOT MINGW
  2408. AND NOT "${CMAKE_GENERATOR}" MATCHES "Xcode")
  2409. get_filename_component(JNIPATH ${JAVA_COMPILE} PATH)
  2410. find_file(JNI_H jni.h
  2411. "${JNIPATH}/../include"
  2412. "${JNIPATH}/../java/include")
  2413. if(JNI_H AND EXISTS "${JNI_H}") # in case jni.h is a broken symlink
  2414. file(READ "${JNI_H}" JNI_FILE)
  2415. if("${JNI_FILE}" MATCHES "JDK1_2")
  2416. add_test(Java ${CMAKE_CTEST_COMMAND}
  2417. --build-and-test
  2418. "${CMake_SOURCE_DIR}/Tests/Java"
  2419. "${CMake_BINARY_DIR}/Tests/Java"
  2420. ${build_generator_args}
  2421. --build-project hello
  2422. --build-two-config
  2423. --build-run-dir "${CMake_BINARY_DIR}/Tests/Java/"
  2424. --build-options ${build_options}
  2425. --test-command ${JAVA_RUNTIME} -classpath hello.jar HelloWorld)
  2426. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Java")
  2427. endif()
  2428. endif()
  2429. endif()
  2430. # add some cross compiler tests, for now only with makefile based generators
  2431. if(CMAKE_GENERATOR MATCHES "Makefiles" OR CMAKE_GENERATOR MATCHES "KDevelop")
  2432. # if sdcc is found, build the SimpleCOnly project with sdcc
  2433. find_program(SDCC_EXECUTABLE sdcc)
  2434. mark_as_advanced(SDCC_EXECUTABLE)
  2435. if(SDCC_EXECUTABLE)
  2436. add_test(SimpleCOnly_sdcc ${CMAKE_CTEST_COMMAND}
  2437. --build-and-test
  2438. "${CMake_SOURCE_DIR}/Tests/SimpleCOnly"
  2439. "${CMake_BINARY_DIR}/Tests/SimpleCOnly_sdcc"
  2440. ${build_generator_args}
  2441. --build-project SimpleC
  2442. --build-options ${build_options}
  2443. "-DCMAKE_SYSTEM_NAME=Generic"
  2444. "-DCMAKE_C_COMPILER=${SDCC_EXECUTABLE}")
  2445. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SimpleCOnly_sdcc")
  2446. endif()
  2447. # If a Linux -> MinGW cross compiler is found then try it
  2448. find_program(MINGW_CC_LINUX2WIN_EXECUTABLE i586-mingw32msvc-gcc)
  2449. find_program(MINGW_CXX_LINUX2WIN_EXECUTABLE i586-mingw32msvc-g++)
  2450. find_program(MINGW_RC_LINUX2WIN_EXECUTABLE i586-mingw32msvc-windres)
  2451. mark_as_advanced(MINGW_CC_LINUX2WIN_EXECUTABLE MINGW_CXX_LINUX2WIN_EXECUTABLE MINGW_RC_LINUX2WIN_EXECUTABLE)
  2452. if(MINGW_CC_LINUX2WIN_EXECUTABLE AND MINGW_CXX_LINUX2WIN_EXECUTABLE AND MINGW_RC_LINUX2WIN_EXECUTABLE)
  2453. add_test(Simple_Mingw_Linux2Win ${CMAKE_CTEST_COMMAND}
  2454. --build-and-test
  2455. "${CMake_SOURCE_DIR}/Tests/Simple"
  2456. "${CMake_BINARY_DIR}/Tests/Simple_Mingw_Linux2Win"
  2457. ${build_generator_args}
  2458. --build-project Simple
  2459. --build-options ${build_options}
  2460. "-DCMAKE_SYSTEM_NAME=Windows"
  2461. "-DCMAKE_C_COMPILER=${MINGW_CC_LINUX2WIN_EXECUTABLE}"
  2462. "-DCMAKE_CXX_COMPILER=${MINGW_CXX_LINUX2WIN_EXECUTABLE}"
  2463. "-DCMAKE_RC_COMPILER=${MINGW_RC_LINUX2WIN_EXECUTABLE}"
  2464. )
  2465. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Simple_Mingw_Linux2Win")
  2466. endif()
  2467. endif()
  2468. if(CMAKE_TEST_PROJECT_CSE_DIR)
  2469. set(script "${CMAKE_TEST_PROJECT_CSE_DIR}/BuildProjectCSE.cmake")
  2470. if(NOT EXISTS "${script}")
  2471. set(script "${CMAKE_TEST_PROJECT_CSE_DIR}/cse_build.cmake")
  2472. endif()
  2473. if(NOT EXISTS "${script}")
  2474. message("warning: CMAKE_TEST_PROJECT_CSE_DIR set, but no build script found...")
  2475. endif()
  2476. add_test(BuildCSE ${CMAKE_CTEST_COMMAND} -V -S "${script}")
  2477. set_tests_properties(BuildCSE PROPERTIES TIMEOUT 5400)
  2478. endif()
  2479. if(CMAKE_TEST_PLPLOT_DIR)
  2480. add_test(plplot ${CMAKE_CTEST_COMMAND} -V -S ${CMAKE_TEST_PLPLOT_DIR}/../../EasyDashboardScripts/plplot.cmake )
  2481. set_tests_properties ( plplot PROPERTIES TIMEOUT 5400)
  2482. endif()
  2483. if(CMAKE_TEST_CHICKEN_DIR)
  2484. add_test(Chicken ${CMAKE_CTEST_COMMAND} -V -S ${CMAKE_TEST_CHICKEN_DIR}/../../EasyDashboardScripts/Chicken.cmake )
  2485. set_tests_properties ( Chicken PROPERTIES TIMEOUT 5400)
  2486. endif()
  2487. if(CMAKE_TEST_KDELIBS_ALPHA_1_DIR)
  2488. add_test(KDELibsAlpha1 ${CMAKE_CTEST_COMMAND} -V -S ${CMAKE_TEST_KDELIBS_ALPHA_1_DIR}/../../EasyDashboardScripts/kdelibs.cmake )
  2489. set_tests_properties ( KDELibsAlpha1 PROPERTIES TIMEOUT 5400)
  2490. endif()
  2491. # If this is not an in-source build, provide a target to wipe out
  2492. # all the test build directories.
  2493. if(NOT EXISTS "${CMake_BINARY_DIR}/CMakeLists.txt")
  2494. configure_file(${CMake_SOURCE_DIR}/Tests/test_clean.cmake.in
  2495. ${CMake_BINARY_DIR}/Tests/test_clean.cmake @ONLY)
  2496. add_custom_target(test_clean
  2497. COMMAND ${CMAKE_COMMAND} -P ${CMake_BINARY_DIR}/Tests/test_clean.cmake
  2498. COMMENT "Removing test build directories."
  2499. )
  2500. endif()
  2501. add_test(NAME CMakeWizardTest COMMAND cmake -i)
  2502. set_property(TEST CMakeWizardTest PROPERTY PASS_REGULAR_EXPRESSION
  2503. "The \"cmake -i\" wizard mode is no longer supported.")
  2504. # If the cache variable CMAKE_CONTRACT_PROJECTS is set
  2505. # then the dashboard will run a contract with CMake test of that
  2506. # name. For example CMAKE_CONTRACT_PROJECTS = vtk542 would run
  2507. # the vtk542 contract test.
  2508. # For each Contract test, the project should provide a directory
  2509. # with at least one CMakeLists.txt file that uses ExternalProject
  2510. # to download and configure the project. The directory should also
  2511. # contain a RunTest.cmake file that has a single set of the format:
  2512. # set(project_RUN_TEST testToRun)
  2513. # The testToRun should be a test executable that can be run to
  2514. # smoke test the build.
  2515. foreach(project ${CMAKE_CONTRACT_PROJECTS})
  2516. include(Contracts/${project}/RunTest.cmake)
  2517. ADD_TEST_MACRO(Contracts.${project}
  2518. ${${project}_RUN_TEST})
  2519. # Contract test timeout in seconds.
  2520. # Default to 6 hours.
  2521. if(DEFINED ${project}_TEST_TIMEOUT)
  2522. set(timeout ${${project}_TEST_TIMEOUT})
  2523. elseif(CMAKE_CONTRACT_TEST_TIMEOUT_DEFAULT)
  2524. set(timeout ${CMAKE_CONTRACT_TEST_TIMEOUT_DEFAULT})
  2525. else()
  2526. set(timeout 21600)
  2527. endif()
  2528. set_tests_properties(Contracts.${project} PROPERTIES TIMEOUT ${timeout})
  2529. endforeach()
  2530. if(TEST_CompileCommandOutput)
  2531. set(CompileCommandOutput_BUILD_OPTIONS
  2532. -DMAKE_SUPPORTS_SPACES=${MAKE_SUPPORTS_SPACES})
  2533. ADD_TEST_MACRO(CompileCommandOutput
  2534. "${CMake_BINARY_DIR}/Tests/CMakeLib/runcompilecommands")
  2535. endif()
  2536. add_test(IncludeDirectories ${CMAKE_CTEST_COMMAND}
  2537. --build-and-test
  2538. "${CMake_SOURCE_DIR}/Tests/IncludeDirectories"
  2539. "${CMake_BINARY_DIR}/Tests/IncludeDirectories"
  2540. --build-two-config
  2541. ${build_generator_args}
  2542. --build-project IncludeDirectories
  2543. --build-options ${build_options}
  2544. --test-command IncludeDirectories)
  2545. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/IncludeDirectories")
  2546. add_test(InterfaceLinkLibraries ${CMAKE_CTEST_COMMAND}
  2547. --build-and-test
  2548. "${CMake_SOURCE_DIR}/Tests/InterfaceLinkLibraries"
  2549. "${CMake_BINARY_DIR}/Tests/InterfaceLinkLibraries"
  2550. --build-two-config
  2551. ${build_generator_args}
  2552. --build-project InterfaceLinkLibraries
  2553. --build-options ${build_options}
  2554. --test-command InterfaceLinkLibraries)
  2555. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/InterfaceLinkLibraries")
  2556. if(CMAKE_USE_KWSTYLE AND KWSTYLE_EXECUTABLE)
  2557. # The "make StyleCheck" command line as a test. If the test fails, look
  2558. # for lines like "Error #0 (624) Line length exceed 88 (max=79)" in the
  2559. # output to find where the style errors are...
  2560. add_test(KWStyle ${KWSTYLE_EXECUTABLE}
  2561. -xml ${CMake_BINARY_DIR}/CMake.kws.xml
  2562. -o ${CMake_SOURCE_DIR}/Utilities/KWStyle/CMakeOverwrite.txt
  2563. -v
  2564. -D ${CMake_BINARY_DIR}/CMakeKWSFiles.txt
  2565. )
  2566. set_tests_properties(KWStyle PROPERTIES
  2567. WORKING_DIRECTORY ${CMake_BINARY_DIR}/Utilities/KWStyle)
  2568. endif()
  2569. if(NOT CMake_TEST_EXTERNAL_CMAKE)
  2570. add_subdirectory(CMakeTests)
  2571. endif()
  2572. endif()