CMakeLists.txt 112 KB

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