CMakeLists.txt 116 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945
  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 "${NAME}" COMMAND "${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(ExternalProjectLocal ${CMAKE_CTEST_COMMAND}
  1146. --build-and-test
  1147. "${CMake_SOURCE_DIR}/Tests/ExternalProjectLocal"
  1148. "${CMake_BINARY_DIR}/Tests/ExternalProjectLocal"
  1149. ${build_generator_args}
  1150. --build-project ExternalProjectLocalTest
  1151. --build-exe-dir "${CMake_BINARY_DIR}/Tests/ExternalProjectLocal"
  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/ExternalProjectLocal")
  1157. set_tests_properties(ExternalProjectLocal PROPERTIES
  1158. TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT})
  1159. add_test(ExternalProjectUpdateSetup ${CMAKE_CTEST_COMMAND}
  1160. --build-and-test
  1161. "${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate"
  1162. "${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate"
  1163. ${build_generator_args}
  1164. --build-project ExternalProjectUpdateTest
  1165. --build-exe-dir "${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate"
  1166. --force-new-ctest-process
  1167. --build-options ${build_options}
  1168. --test-command ${CMAKE_CTEST_COMMAND} -V
  1169. )
  1170. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate")
  1171. set_tests_properties(ExternalProjectUpdateSetup PROPERTIES
  1172. TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT})
  1173. add_test(NAME ExternalProjectUpdate
  1174. COMMAND ${CMAKE_CMAKE_COMMAND}
  1175. -DExternalProjectUpdate_SOURCE_DIR:PATH=${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate
  1176. -DExternalProjectUpdate_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate
  1177. -DCMAKE_GENERATOR=${CMAKE_GENERATOR}
  1178. -DCMAKE_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET}
  1179. -DCMAKE_CTEST_COMMAND=${CMAKE_CTEST_COMMAND}
  1180. -P ${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake
  1181. )
  1182. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate")
  1183. set_tests_properties(ExternalProjectUpdate PROPERTIES
  1184. TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}
  1185. WORKING_DIRECTORY ${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate
  1186. DEPENDS ExternalProjectUpdateSetup )
  1187. # do each of the tutorial steps
  1188. foreach(STP RANGE 1 7)
  1189. add_test(TutorialStep${STP} ${CMAKE_CTEST_COMMAND}
  1190. --build-and-test
  1191. "${CMake_SOURCE_DIR}/Tests/Tutorial/Step${STP}"
  1192. "${CMake_BINARY_DIR}/Tests/Tutorial/Step${STP}"
  1193. --build-two-config
  1194. ${build_generator_args}
  1195. --build-project Tutorial
  1196. --build-options ${build_options}
  1197. --test-command Tutorial 25.0)
  1198. endforeach()
  1199. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Tutorial")
  1200. add_test(testing ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE}
  1201. --build-and-test
  1202. "${CMake_SOURCE_DIR}/Tests/Testing"
  1203. "${CMake_BINARY_DIR}/Tests/Testing"
  1204. ${build_generator_args}
  1205. --build-project Testing
  1206. --build-options ${build_options}
  1207. --test-command ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE}
  1208. )
  1209. set_tests_properties(testing PROPERTIES PASS_REGULAR_EXPRESSION "Passed")
  1210. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Testing")
  1211. add_test(wrapping ${CMAKE_CTEST_COMMAND}
  1212. --build-and-test
  1213. "${CMake_SOURCE_DIR}/Tests/Wrapping"
  1214. "${CMake_BINARY_DIR}/Tests/Wrapping"
  1215. ${build_generator_args}
  1216. --build-project Wrapping
  1217. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin"
  1218. --build-options ${build_options}
  1219. --test-command wrapping
  1220. )
  1221. add_test(qtwrapping ${CMAKE_CTEST_COMMAND}
  1222. --build-and-test
  1223. "${CMake_SOURCE_DIR}/Tests/Wrapping"
  1224. "${CMake_BINARY_DIR}/Tests/Wrapping"
  1225. ${build_generator_args}
  1226. --build-project Wrapping
  1227. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin"
  1228. --build-options ${build_options}
  1229. --test-command qtwrapping
  1230. )
  1231. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Wrapping")
  1232. add_test(testdriver1 ${CMAKE_CTEST_COMMAND}
  1233. --build-and-test
  1234. "${CMake_SOURCE_DIR}/Tests/TestDriver"
  1235. "${CMake_BINARY_DIR}/Tests/TestDriver"
  1236. ${build_generator_args}
  1237. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin"
  1238. --build-project TestDriverTest
  1239. --build-options ${build_options}
  1240. --test-command TestDriverTest test1
  1241. )
  1242. add_test(testdriver2 ${CMAKE_CTEST_COMMAND}
  1243. --build-and-test
  1244. "${CMake_SOURCE_DIR}/Tests/TestDriver"
  1245. "${CMake_BINARY_DIR}/Tests/TestDriver"
  1246. ${build_generator_args}
  1247. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin"
  1248. --build-project TestDriverTest
  1249. --build-options ${build_options}
  1250. --test-command TestDriverTest test2
  1251. )
  1252. add_test(testdriver3 ${CMAKE_CTEST_COMMAND}
  1253. --build-and-test
  1254. "${CMake_SOURCE_DIR}/Tests/TestDriver"
  1255. "${CMake_BINARY_DIR}/Tests/TestDriver"
  1256. ${build_generator_args}
  1257. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin"
  1258. --build-project TestDriverTest
  1259. --build-options ${build_options}
  1260. --test-command TestDriverTest subdir/test3
  1261. )
  1262. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/TestDriver")
  1263. add_test(Dependency ${CMAKE_CTEST_COMMAND}
  1264. --build-and-test
  1265. "${CMake_SOURCE_DIR}/Tests/Dependency"
  1266. "${CMake_BINARY_DIR}/Tests/Dependency"
  1267. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Dependency/Exec"
  1268. ${build_generator_args}
  1269. --build-project Dependency
  1270. --build-options ${build_options}
  1271. --test-command exec
  1272. )
  1273. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Dependency")
  1274. if("${CMAKE_SYSTEM_NAME}" MATCHES syllable)
  1275. # RPATH isn't supported under Syllable, so the tests don't
  1276. # find their libraries. In order to fix that LIBRARY_OUTPUT_DIR
  1277. # in the tests would have to be adjusted to ${EXECUTABLE_OUTPUT_DIR}/lib .
  1278. # For now we just require on Syllable that the user adjusts the DLL_PATH
  1279. # environment variable, so except the two tests below all other tests will succeed.
  1280. set(_DLL_PATH "$ENV{DLL_PATH}")
  1281. if(NOT "${_DLL_PATH}" MATCHES "^(.*:)?\\@bindir\\@/\\.(:.*)?$")
  1282. 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")
  1283. endif()
  1284. if(NOT "${_DLL_PATH}" MATCHES "^(.*:)?\\@bindir\\@/\\.\\./lib(:.*)?$")
  1285. 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")
  1286. endif()
  1287. else()
  1288. add_test(JumpWithLibOut ${CMAKE_CTEST_COMMAND}
  1289. --build-and-test
  1290. "${CMake_SOURCE_DIR}/Tests/Jump"
  1291. "${CMake_BINARY_DIR}/Tests/Jump/WithLibOut"
  1292. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Jump/WithLibOut/Executable"
  1293. --build-project Jump
  1294. ${build_generator_args}
  1295. --build-options ${build_options}
  1296. -DLIBRARY_OUTPUT_PATH:PATH=${CMake_BINARY_DIR}/Tests/Jump/WithLibOut/Lib
  1297. --test-command jumpExecutable
  1298. )
  1299. add_test(JumpNoLibOut ${CMAKE_CTEST_COMMAND}
  1300. --build-and-test
  1301. "${CMake_SOURCE_DIR}/Tests/Jump"
  1302. "${CMake_BINARY_DIR}/Tests/Jump/NoLibOut"
  1303. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Jump/NoLibOut/Executable"
  1304. --build-run-dir "${CMake_BINARY_DIR}/Tests/Jump/NoLibOut/Executable"
  1305. --build-project Jump
  1306. ${build_generator_args}
  1307. --build-options ${build_options}
  1308. --test-command jumpExecutable
  1309. )
  1310. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Jump")
  1311. add_test(Plugin ${CMAKE_CTEST_COMMAND}
  1312. --build-and-test
  1313. "${CMake_SOURCE_DIR}/Tests/Plugin"
  1314. "${CMake_BINARY_DIR}/Tests/Plugin"
  1315. ${build_generator_args}
  1316. --build-project Plugin
  1317. --build-two-config
  1318. --build-options ${build_options}
  1319. --test-command bin/example)
  1320. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Plugin")
  1321. if(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG)
  1322. ADD_TEST_MACRO(RuntimePath RuntimePath)
  1323. endif()
  1324. endif()
  1325. if(APPLE AND "${DARWIN_MAJOR_VERSION}" GREATER 9)
  1326. add_test(MacRuntimePath ${CMAKE_CTEST_COMMAND}
  1327. --build-and-test
  1328. "${CMake_SOURCE_DIR}/Tests/MacRuntimePath"
  1329. "${CMake_BINARY_DIR}/Tests/MacRuntimePath"
  1330. ${build_generator_args}
  1331. --build-project MacRuntimePath
  1332. --build-options ${build_options}
  1333. -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM}
  1334. )
  1335. endif()
  1336. add_test(linkorder1 ${CMAKE_CTEST_COMMAND}
  1337. --build-and-test
  1338. "${CMake_SOURCE_DIR}/Tests/LinkLineOrder"
  1339. "${CMake_BINARY_DIR}/Tests/LinkLineOrder"
  1340. ${build_generator_args}
  1341. --build-project LinkLineOrder
  1342. --build-options ${build_options}
  1343. --test-command Exec1
  1344. )
  1345. add_test(linkorder2 ${CMAKE_CTEST_COMMAND}
  1346. --build-and-test
  1347. "${CMake_SOURCE_DIR}/Tests/LinkLineOrder"
  1348. "${CMake_BINARY_DIR}/Tests/LinkLineOrder"
  1349. ${build_generator_args}
  1350. --build-project LinkLineOrder
  1351. --build-options ${build_options}
  1352. --test-command Exec2
  1353. )
  1354. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LinkLineOrder")
  1355. set_tests_properties ( qtwrapping PROPERTIES DEPENDS wrapping)
  1356. set_tests_properties ( testdriver1 PROPERTIES DEPENDS qtwrapping)
  1357. set_tests_properties ( testdriver2 PROPERTIES DEPENDS testdriver1)
  1358. set_tests_properties ( testdriver3 PROPERTIES DEPENDS testdriver2)
  1359. set_tests_properties ( linkorder2 PROPERTIES DEPENDS linkorder1)
  1360. set_tests_properties ( SimpleInstall-Stage2 PROPERTIES DEPENDS SimpleInstall)
  1361. # Test static linking on toolchains known to support it.
  1362. if("${CMAKE_C_COMPILER_ID}" MATCHES "^(GNU)$"
  1363. AND NOT APPLE AND NOT WIN32 AND NOT CYGWIN
  1364. AND EXISTS "/usr/lib/libm.a")
  1365. add_test(LinkStatic ${CMAKE_CTEST_COMMAND}
  1366. --build-and-test
  1367. "${CMake_SOURCE_DIR}/Tests/LinkStatic"
  1368. "${CMake_BINARY_DIR}/Tests/LinkStatic"
  1369. ${build_generator_args}
  1370. --build-project LinkStatic
  1371. --build-options ${build_options}
  1372. -DMATH_LIBRARY:FILEPATH=/usr/lib/libm.a
  1373. --test-command LinkStatic
  1374. )
  1375. endif()
  1376. if(MAKE_SUPPORTS_SPACES AND NOT CMAKE_GENERATOR STREQUAL "Xcode")
  1377. add_test(SubDirSpaces ${CMAKE_CTEST_COMMAND}
  1378. --build-and-test
  1379. "${CMake_SOURCE_DIR}/Tests/SubDirSpaces"
  1380. "${CMake_BINARY_DIR}/Tests/SubDirSpaces"
  1381. --build-exe-dir
  1382. "${CMake_BINARY_DIR}/Tests/SubDirSpaces/Executable Sources"
  1383. ${build_generator_args}
  1384. --build-project SUBDIR
  1385. --build-options ${build_options}
  1386. --test-command test
  1387. "${CMake_BINARY_DIR}/Tests/SubDirSpaces/ShouldBeHere"
  1388. "${CMake_BINARY_DIR}/Tests/SubDirSpaces/testfromsubdir.obj"
  1389. )
  1390. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SubDirSpaces")
  1391. endif ()
  1392. if (WIN32)
  1393. add_test(SubDir ${CMAKE_CTEST_COMMAND}
  1394. --build-and-test
  1395. "${CMake_SOURCE_DIR}/Tests/SubDir"
  1396. "${CMake_BINARY_DIR}/Tests/SubDir"
  1397. --build-exe-dir "${CMake_BINARY_DIR}/Tests/SubDir/Executable"
  1398. ${build_generator_args}
  1399. --build-project SUBDIR
  1400. --build-options ${build_options}
  1401. --test-command test
  1402. "${CMake_BINARY_DIR}/Tests/SubDir/ShouldBeHere"
  1403. "${CMake_BINARY_DIR}/Tests/SubDir/testfromsubdir.obj"
  1404. )
  1405. else ()
  1406. add_test(SubDir ${CMAKE_CTEST_COMMAND}
  1407. --build-and-test
  1408. "${CMake_SOURCE_DIR}/Tests/SubDir"
  1409. "${CMake_BINARY_DIR}/Tests/SubDir"
  1410. --build-exe-dir "${CMake_BINARY_DIR}/Tests/SubDir/Executable"
  1411. ${build_generator_args}
  1412. --build-project SUBDIR
  1413. --build-options ${build_options}
  1414. --test-command test
  1415. "${CMake_BINARY_DIR}/Tests/SubDir/ShouldBeHere"
  1416. "${CMake_BINARY_DIR}/Tests/SubDir/testfromsubdir.o"
  1417. )
  1418. endif ()
  1419. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SubDir")
  1420. if(MSVC)
  1421. ADD_TEST_MACRO(ForceInclude foo)
  1422. ADD_TEST_MACRO(PDBDirectoryAndName myexe)
  1423. ADD_TEST_MACRO(PrecompiledHeader foo)
  1424. endif()
  1425. if(MSVC OR
  1426. "${CMAKE_GENERATOR}" MATCHES "(MSYS|MinGW) Makefiles")
  1427. ADD_TEST_MACRO(ModuleDefinition example_exe)
  1428. endif()
  1429. ADD_TEST_MACRO(CheckCompilerRelatedVariables CheckCompilerRelatedVariables)
  1430. if("${CMAKE_GENERATOR}" MATCHES "Makefile")
  1431. add_test(MakeClean ${CMAKE_CTEST_COMMAND}
  1432. --build-and-test
  1433. "${CMake_SOURCE_DIR}/Tests/MakeClean"
  1434. "${CMake_BINARY_DIR}/Tests/MakeClean"
  1435. ${build_generator_args}
  1436. --build-project MakeClean
  1437. --build-exe-dir "${CMake_BINARY_DIR}/MakeClean"
  1438. --build-options ${build_options}
  1439. --test-command check_clean
  1440. )
  1441. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/MakeClean")
  1442. endif()
  1443. if(NOT DEFINED CTEST_RUN_MFC)
  1444. set(CTEST_RUN_MFC OFF)
  1445. if(MSVC)
  1446. set(CTEST_RUN_MFC ON)
  1447. # Look for evidence that this is a VCExpress build. If so, avoid
  1448. # the MFC test by default.
  1449. string(TOLOWER "${CMAKE_MAKE_PROGRAM}" mkprog)
  1450. if(mkprog MATCHES "vcexpress")
  1451. message(STATUS
  1452. "CMAKE_MAKE_PROGRAM indicates vcexpress, avoiding MFC test")
  1453. set(CTEST_RUN_MFC OFF)
  1454. endif()
  1455. # Since MSBuild might also be the "makeprogram" for a VCExpress
  1456. # build tree, use one more heuristic, too. The string representing
  1457. # the .vcproj file type contains "VCExpress" on machines where an
  1458. # express edition of VS was installed last:
  1459. if(CTEST_RUN_MFC)
  1460. execute_process(COMMAND cmd /c assoc .vcproj
  1461. OUTPUT_STRIP_TRAILING_WHITESPACE
  1462. OUTPUT_VARIABLE ov)
  1463. if(ov MATCHES "VCExpress")
  1464. message(STATUS
  1465. ".vcproj file association indicates VCExpress, avoiding MFC test")
  1466. set(CTEST_RUN_MFC OFF)
  1467. endif()
  1468. endif()
  1469. # For the Watcom WMake generator, avoid the MFC test by default.
  1470. if(CTEST_RUN_MFC)
  1471. if("${CMAKE_GENERATOR}" MATCHES "WMake")
  1472. message(STATUS
  1473. "using the Watcom WMake generator, avoiding MFC test")
  1474. set(CTEST_RUN_MFC OFF)
  1475. endif()
  1476. endif()
  1477. # Last resort, after quick checks are done. Do a try_compile, and avoid
  1478. # the MFC test if the simplest possible MFC app cannot be compiled.
  1479. if(CTEST_RUN_MFC AND NOT DEFINED HAVE_MFC)
  1480. configure_file(
  1481. ${CMAKE_CURRENT_SOURCE_DIR}/MFC/try_compile/CMakeLists.txt
  1482. ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile/CMakeLists.txt
  1483. COPYONLY
  1484. )
  1485. configure_file(
  1486. ${CMAKE_CURRENT_SOURCE_DIR}/MFC/mfc1/stdafx.cpp
  1487. ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile/stdafx.cpp
  1488. COPYONLY
  1489. )
  1490. configure_file(
  1491. ${CMAKE_CURRENT_SOURCE_DIR}/MFC/mfc1/stdafx.h
  1492. ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile/stdafx.h
  1493. COPYONLY
  1494. )
  1495. message(STATUS "Looking for MFC")
  1496. try_compile(HAVE_MFC
  1497. ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile/build
  1498. ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile
  1499. try_compile_mfc
  1500. OUTPUT_VARIABLE HAVE_MFC_OUTPUT)
  1501. if(HAVE_MFC)
  1502. message(STATUS "Looking for MFC - found")
  1503. set(HAVE_MFC 1 CACHE INTERNAL "Have MFC")
  1504. file(APPEND
  1505. ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
  1506. "Determining if MFC exists passed with the following output:\n"
  1507. "${HAVE_MFC_OUTPUT}\n\n")
  1508. else()
  1509. message(STATUS "Looking for MFC - not found")
  1510. set(HAVE_MFC "" CACHE INTERNAL "Have MFC")
  1511. file(APPEND
  1512. ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
  1513. "Determining if MFC exists failed with the following output:\n"
  1514. "${HAVE_MFC_OUTPUT}\n\n")
  1515. endif()
  1516. endif()
  1517. if(CTEST_RUN_MFC AND NOT HAVE_MFC)
  1518. message(STATUS
  1519. "cannot compile simplest ever MFC app, avoiding MFC test")
  1520. set(CTEST_RUN_MFC OFF)
  1521. endif()
  1522. endif()
  1523. endif()
  1524. if(CTEST_RUN_MFC)
  1525. add_test(MFC ${CMAKE_CTEST_COMMAND}
  1526. --build-and-test
  1527. "${CMake_SOURCE_DIR}/Tests/MFC"
  1528. "${CMake_BINARY_DIR}/Tests/MFC"
  1529. --build-two-config
  1530. ${build_generator_args}
  1531. --build-project mfc_driver
  1532. --build-options ${build_options}
  1533. --test-command ${CMAKE_CTEST_COMMAND}
  1534. -C \${CTEST_CONFIGURATION_TYPE} -VV)
  1535. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/MFC")
  1536. endif()
  1537. if(MSVC AND NOT MSVC_VERSION LESS 1310
  1538. AND NOT CMAKE_GENERATOR MATCHES "Visual Studio [67]( |$)"
  1539. AND (NOT CMAKE_GENERATOR MATCHES "Visual Studio [89]( |$)"
  1540. OR CMAKE_SIZEOF_VOID_P EQUAL 4)
  1541. )
  1542. ADD_TEST_MACRO(VSMASM VSMASM)
  1543. endif()
  1544. if(${CMAKE_GENERATOR} MATCHES "Visual Studio")
  1545. if(NOT MSVC60)
  1546. ADD_TEST_MACRO(SBCS SBCS)
  1547. endif()
  1548. if(NOT "${CMAKE_GENERATOR}" MATCHES "Visual Studio [6789]( |$)"
  1549. AND NOT CMAKE_GENERATOR_TOOLSET)
  1550. ADD_TEST_MACRO(VSWindowsFormsResx VSWindowsFormsResx)
  1551. endif()
  1552. add_test(VSExternalInclude ${CMAKE_CTEST_COMMAND}
  1553. --build-and-test
  1554. "${CMake_SOURCE_DIR}/Tests/VSExternalInclude"
  1555. "${CMake_BINARY_DIR}/Tests/VSExternalInclude"
  1556. --build-two-config
  1557. ${build_generator_args}
  1558. --build-project VSExternalInclude
  1559. --build-options ${build_options}
  1560. --test-command VSExternalInclude)
  1561. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSExternalInclude")
  1562. add_test(VSMidl ${CMAKE_CTEST_COMMAND}
  1563. --build-and-test
  1564. "${CMake_SOURCE_DIR}/Tests/VSMidl"
  1565. "${CMake_BINARY_DIR}/Tests/VSMidl"
  1566. --build-two-config
  1567. ${build_generator_args}
  1568. --build-project VSMidl
  1569. --build-options ${build_options}
  1570. --test-command VSMidl)
  1571. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSMidl")
  1572. if(CMake_TEST_DEVENV)
  1573. # The test (and tested property) works with .sln files, so it's skipped when:
  1574. # * Using VS6, which doesn't use .sln files
  1575. # * cmake --build is set up to use MSBuild, since the MSBuild invocation does not use the .sln file
  1576. set(_last_test "")
  1577. foreach(config ${CMAKE_CONFIGURATION_TYPES})
  1578. add_test(NAME VSExcludeFromDefaultBuild-${config} COMMAND ${CMAKE_CTEST_COMMAND}
  1579. --build-and-test
  1580. "${CMake_SOURCE_DIR}/Tests/VSExcludeFromDefaultBuild"
  1581. "${CMake_BINARY_DIR}/Tests/VSExcludeFromDefaultBuild"
  1582. --build-config ${config}
  1583. --build-two-config
  1584. --build-generator ${CMAKE_GENERATOR}
  1585. --build-makeprogram ${CMake_TEST_DEVENV}
  1586. --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
  1587. --build-project VSExcludeFromDefaultBuild
  1588. --test-command ${CMAKE_COMMAND}
  1589. -D "activeConfig=${config}"
  1590. -D "allConfigs=${CMAKE_CONFIGURATION_TYPES}"
  1591. -D "dir=${CMake_BINARY_DIR}/Tests/VSExcludeFromDefaultBuild"
  1592. -P "${CMake_SOURCE_DIR}/Tests/VSExcludeFromDefaultBuild/ResultTest.cmake")
  1593. if(_last_test)
  1594. set_property(TEST VSExcludeFromDefaultBuild-${config} PROPERTY DEPENDS ${_last_test})
  1595. endif()
  1596. set(_last_test "VSExcludeFromDefaultBuild-${config}")
  1597. endforeach()
  1598. unset(_last_test)
  1599. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSExcludeFromDefaultBuild")
  1600. endif()
  1601. if(CMAKE_GENERATOR MATCHES "Visual Studio ([0-5]|[6-9][0-9])")
  1602. # This is Visual Studio 10 or above, so the default build tool is MSBuild.
  1603. add_test(NAME VSProjectInSubdir COMMAND ${CMAKE_CTEST_COMMAND}
  1604. --build-and-test
  1605. "${CMake_SOURCE_DIR}/Tests/VSProjectInSubdir"
  1606. "${CMake_BINARY_DIR}/Tests/VSProjectInSubdir"
  1607. --build-two-config
  1608. --build-generator ${CMAKE_GENERATOR}
  1609. --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
  1610. --build-project VSProjectInSubdir
  1611. --build-target test)
  1612. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSProjectInSubdir")
  1613. endif()
  1614. endif()
  1615. get_filename_component(ntver "[HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion;CurrentVersion]" NAME)
  1616. if(WIN32 AND ntver VERSION_GREATER 6.1) # Windows >= 8.0
  1617. macro(add_test_VSWinStorePhone name generator systemName systemVersion)
  1618. add_test(NAME VSWinStorePhone.${name} COMMAND ${CMAKE_CTEST_COMMAND}
  1619. --build-and-test
  1620. "${CMake_SOURCE_DIR}/Tests/VSWinStorePhone"
  1621. "${CMake_BINARY_DIR}/Tests/VSWinStorePhone/${name}"
  1622. --build-generator "${generator}"
  1623. --build-project VSWinStorePhone
  1624. --build-config $<CONFIGURATION>
  1625. --build-options -DCMAKE_SYSTEM_NAME=${systemName}
  1626. -DCMAKE_SYSTEM_VERSION=${systemVersion}
  1627. )
  1628. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSWinStorePhone/${name}")
  1629. endmacro()
  1630. set(reg_vs11 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0;InstallDir]")
  1631. set(reg_vs12 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\12.0;InstallDir]")
  1632. set(reg_ws80 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.0;InstallationFolder]")
  1633. set(reg_ws81 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.1;InstallationFolder]")
  1634. set(reg_wp80 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\WindowsPhone\\v8.0;InstallationFolder]")
  1635. set(reg_wp81 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\WindowsPhone\\v8.1;InstallationFolder]")
  1636. foreach(reg vs11 vs12 ws80 ws81 wp80 wp81)
  1637. get_filename_component(r "${reg_${reg}}" ABSOLUTE)
  1638. if(IS_DIRECTORY "${r}")
  1639. set(${reg} 1)
  1640. else()
  1641. set(${reg} 0)
  1642. endif()
  1643. endforeach()
  1644. if(vs11 AND ws80)
  1645. add_test_VSWinStorePhone(vs11-store80-X86 "Visual Studio 11 2012" WindowsStore 8.0)
  1646. add_test_VSWinStorePhone(vs11-store80-ARM "Visual Studio 11 2012 ARM" WindowsStore 8.0)
  1647. add_test_VSWinStorePhone(vs11-store80-X64 "Visual Studio 11 2012 Win64" WindowsStore 8.0)
  1648. endif()
  1649. if(vs12 AND ws81)
  1650. add_test_VSWinStorePhone(vs12-store81-X86 "Visual Studio 12 2013" WindowsStore 8.1)
  1651. add_test_VSWinStorePhone(vs12-store81-ARM "Visual Studio 12 2013 ARM" WindowsStore 8.1)
  1652. add_test_VSWinStorePhone(vs12-store81-X64 "Visual Studio 12 2013 Win64" WindowsStore 8.1)
  1653. endif()
  1654. if(vs11 AND wp80)
  1655. add_test_VSWinStorePhone(vs11-phone80-X86 "Visual Studio 11 2012" WindowsPhone 8.0)
  1656. add_test_VSWinStorePhone(vs11-phone80-ARM "Visual Studio 11 2012 ARM" WindowsPhone 8.0)
  1657. endif()
  1658. if(vs12 AND wp81)
  1659. add_test_VSWinStorePhone(vs12-phone81-X86 "Visual Studio 12 2013" WindowsPhone 8.1)
  1660. add_test_VSWinStorePhone(vs12-phone81-ARM "Visual Studio 12 2013 ARM" WindowsPhone 8.1)
  1661. endif()
  1662. endif()
  1663. if (APPLE)
  1664. if (CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
  1665. set(BundleTestInstallDir
  1666. "${CMake_BINARY_DIR}/Tests/BundleTest/InstallDirectory")
  1667. add_test(BundleTest ${CMAKE_CTEST_COMMAND}
  1668. --build-and-test
  1669. "${CMake_SOURCE_DIR}/Tests/BundleTest"
  1670. "${CMake_BINARY_DIR}/Tests/BundleTest"
  1671. --build-two-config
  1672. ${build_generator_args}
  1673. --build-project BundleTest
  1674. --build-target install
  1675. # --build-target package
  1676. --build-options ${build_options}
  1677. "-DCMAKE_INSTALL_PREFIX:PATH=${BundleTestInstallDir}"
  1678. "-DCMake_SOURCE_DIR:PATH=${CMake_SOURCE_DIR}"
  1679. --test-command
  1680. ${BundleTestInstallDir}/Applications/SecondBundleExe.app/Contents/MacOS/SecondBundleExe)
  1681. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BundleTest")
  1682. add_test(CFBundleTest ${CMAKE_CTEST_COMMAND}
  1683. --build-and-test
  1684. "${CMake_SOURCE_DIR}/Tests/CFBundleTest"
  1685. "${CMake_BINARY_DIR}/Tests/CFBundleTest"
  1686. --build-two-config
  1687. ${build_generator_args}
  1688. --build-project CFBundleTest
  1689. --build-options ${build_options}
  1690. --test-command
  1691. ${CMAKE_CMAKE_COMMAND} -DCTEST_CONFIGURATION_TYPE=\${CTEST_CONFIGURATION_TYPE}
  1692. -Ddir=${CMake_BINARY_DIR}/Tests/CFBundleTest
  1693. -Dgen=${CMAKE_GENERATOR}
  1694. -P ${CMake_SOURCE_DIR}/Tests/CFBundleTest/VerifyResult.cmake)
  1695. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CFBundleTest")
  1696. ADD_TEST_MACRO(ObjC++ ObjC++)
  1697. endif ()
  1698. endif ()
  1699. if(APPLE AND CTEST_TEST_CPACK)
  1700. add_test(BundleGeneratorTest ${CMAKE_CTEST_COMMAND}
  1701. --build-and-test
  1702. "${CMake_SOURCE_DIR}/Tests/BundleGeneratorTest"
  1703. "${CMake_BINARY_DIR}/Tests/BundleGeneratorTest"
  1704. --build-two-config
  1705. ${build_generator_args}
  1706. --build-project BundleGeneratorTest
  1707. --build-target package
  1708. --build-options ${build_options}
  1709. "-DCMAKE_INSTALL_PREFIX:PATH=${CMake_BINARY_DIR}/Tests/BundleGeneratorTest/InstallDirectory"
  1710. )
  1711. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BundleGeneratorTest")
  1712. endif()
  1713. add_test(WarnUnusedUnusedViaSet ${CMAKE_CTEST_COMMAND}
  1714. --build-and-test
  1715. "${CMake_SOURCE_DIR}/Tests/VariableUnusedViaSet"
  1716. "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaSet"
  1717. ${build_generator_args}
  1718. --build-noclean
  1719. --build-project WarnUnusedUnusedViaSet
  1720. --build-options ${build_options}
  1721. "--warn-unused-vars")
  1722. set_tests_properties(WarnUnusedUnusedViaSet PROPERTIES
  1723. PASS_REGULAR_EXPRESSION "unused variable \\(changing definition\\) 'UNUSED_VARIABLE'")
  1724. set_tests_properties(WarnUnusedUnusedViaSet PROPERTIES
  1725. FAIL_REGULAR_EXPRESSION "unused variable \\(unsetting\\) 'UNUSED_VARIABLE'")
  1726. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaSet")
  1727. add_test(WarnUnusedUnusedViaUnset ${CMAKE_CTEST_COMMAND}
  1728. --build-and-test
  1729. "${CMake_SOURCE_DIR}/Tests/VariableUnusedViaUnset"
  1730. "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaUnset"
  1731. ${build_generator_args}
  1732. --build-noclean
  1733. --build-project WarnUnusedUnusedViaUnset
  1734. --build-options ${build_options}
  1735. "--warn-unused-vars")
  1736. set_tests_properties(WarnUnusedUnusedViaUnset PROPERTIES
  1737. PASS_REGULAR_EXPRESSION "CMake Warning \\(dev\\) at CMakeLists.txt:7 \\(set\\):")
  1738. set_tests_properties(WarnUnusedUnusedViaUnset PROPERTIES
  1739. FAIL_REGULAR_EXPRESSION "CMakeLists.txt:5 \\(set\\):")
  1740. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaUnset")
  1741. if("${CMAKE_GENERATOR}" MATCHES "Makefile" AND NOT WIN32)
  1742. # Ninja does not support ADDITIONAL_MAKE_CLEAN_FILES and therefore fails
  1743. # this test. (See #13371)
  1744. # Apparently Visual Studio does not support it either. As the MakeClean
  1745. # test above is only run with the Makefiles generator, only run this
  1746. # test with the Makefiles generator also.
  1747. add_test(WarnUnusedCliUnused ${CMAKE_CTEST_COMMAND}
  1748. --build-and-test
  1749. "${CMake_SOURCE_DIR}/Tests/WarnUnusedCliUnused"
  1750. "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused"
  1751. ${build_generator_args}
  1752. --build-project WarnUnusedCliUnused
  1753. --build-options ${build_options}
  1754. "-DUNUSED_CLI_VARIABLE=Unused")
  1755. set_tests_properties(WarnUnusedCliUnused PROPERTIES
  1756. PASS_REGULAR_EXPRESSION "CMake Warning:.*Manually-specified variables were not used by the project:.* UNUSED_CLI_VARIABLE")
  1757. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused")
  1758. endif()
  1759. add_test(WarnUnusedCliUsed ${CMAKE_CTEST_COMMAND}
  1760. --build-and-test
  1761. "${CMake_SOURCE_DIR}/Tests/VariableUsage"
  1762. "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUsed"
  1763. ${build_generator_args}
  1764. --build-noclean
  1765. --build-project WarnUnusedCliUsed
  1766. --build-options ${build_options}
  1767. "-DUSED_VARIABLE=Usage proven")
  1768. set_tests_properties(WarnUnusedCliUsed PROPERTIES
  1769. PASS_REGULAR_EXPRESSION "Usage proven")
  1770. set_tests_properties(WarnUnusedCliUsed PROPERTIES
  1771. FAIL_REGULAR_EXPRESSION "CMake Warning: The variable, 'USED_VARIABLE'")
  1772. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUsed")
  1773. add_test(WarnUninitialized ${CMAKE_CTEST_COMMAND}
  1774. --build-and-test
  1775. "${CMake_SOURCE_DIR}/Tests/VariableUsage"
  1776. "${CMake_BINARY_DIR}/Tests/WarnUninitialized"
  1777. ${build_generator_args}
  1778. --build-noclean
  1779. --build-project WarnUninitialized
  1780. --build-options ${build_options}
  1781. "--warn-uninitialized")
  1782. set_tests_properties(WarnUninitialized PROPERTIES
  1783. PASS_REGULAR_EXPRESSION "uninitialized variable 'USED_VARIABLE'")
  1784. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUninitialized")
  1785. add_test(TestsWorkingDirectory ${CMAKE_CTEST_COMMAND}
  1786. --build-and-test
  1787. "${CMake_SOURCE_DIR}/Tests/TestsWorkingDirectory"
  1788. "${CMake_BINARY_DIR}/Tests/TestsWorkingDirectory"
  1789. ${build_generator_args}
  1790. --build-project TestsWorkingDirectoryProj
  1791. --build-exe-dir "${CMake_BINARY_DIR}/Tests/TestsWorkingDirectory"
  1792. --force-new-ctest-process
  1793. --build-options ${build_options}
  1794. --test-command ${CMAKE_CTEST_COMMAND} -V -C \${CTEST_CONFIGURATION_TYPE}
  1795. )
  1796. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/TestsWorkingDirectory")
  1797. # Make sure CTest can handle a test with no newline in output.
  1798. add_test(CTest.NoNewline
  1799. ${CMAKE_CMAKE_COMMAND} -E echo_append "This line has no newline!")
  1800. # A simple test for ctest in script mode
  1801. configure_file("${CMake_SOURCE_DIR}/Tests/CTestScriptMode/CTestTestScriptMode.cmake.in"
  1802. "${CMake_BINARY_DIR}/Tests/CTestScriptMode/CTestTestScriptMode.cmake" @ONLY)
  1803. # add_test(CTest.ScriptMode ${CMAKE_CTEST_COMMAND}
  1804. # -S "${CMake_BINARY_DIR}/Tests/CTestScriptMode/CTestTestScriptMode.cmake"
  1805. # )
  1806. # A test for ctest_build() with targets in subdirectories
  1807. set(ctest_configure_options)
  1808. if(CMAKE_GENERATOR_TOOLSET)
  1809. list(APPEND ctest_configure_options -T ${CMAKE_GENERATOR_TOOLSET})
  1810. endif()
  1811. if(CMake_TEST_EXPLICIT_MAKE_PROGRAM)
  1812. list(APPEND ctest_configure_options -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM})
  1813. endif()
  1814. configure_file("${CMake_SOURCE_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in"
  1815. "${CMake_BINARY_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake" @ONLY)
  1816. unset(ctest_configure_options)
  1817. add_test(CTest.BuildCommand.ProjectInSubdir
  1818. ${CMAKE_CTEST_COMMAND} -S "${CMake_BINARY_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake")
  1819. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CTestBuildCommandProjectInSubdir/Nested")
  1820. set(CTEST_TEST_UPDATE 1)
  1821. if(CTEST_TEST_UPDATE)
  1822. # Test CTest Update with Subversion
  1823. find_package(Subversion QUIET)
  1824. if(Subversion_FOUND)
  1825. get_filename_component(_Subversion_BIN_DIR
  1826. ${Subversion_SVN_EXECUTABLE} PATH)
  1827. find_program(Subversion_SVNADMIN_EXECUTABLE svnadmin
  1828. HINTS ${_Subversion_BIN_DIR}
  1829. )
  1830. mark_as_advanced(Subversion_SVNADMIN_EXECUTABLE)
  1831. if(NOT Subversion_SVNADMIN_EXECUTABLE)
  1832. set(Subversion_FOUND FALSE)
  1833. endif()
  1834. endif()
  1835. if(Subversion_FOUND)
  1836. set(CTestUpdateSVN_DIR "CTest UpdateSVN")
  1837. configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateSVN.cmake.in"
  1838. "${CMake_BINARY_DIR}/Tests/CTestUpdateSVN.cmake" @ONLY)
  1839. add_test(CTest.UpdateSVN ${CMAKE_CMAKE_COMMAND}
  1840. -P "${CMake_BINARY_DIR}/Tests/CTestUpdateSVN.cmake"
  1841. )
  1842. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateSVN_DIR}")
  1843. endif()
  1844. # Test CTest Update with CVS
  1845. if(EXISTS ${CMAKE_ROOT}/Modules/FindCVS.cmake)
  1846. find_package(CVS QUIET)
  1847. else()
  1848. find_program(CVS_EXECUTABLE NAMES cvs)
  1849. set(CVS_FOUND ${CVS_EXECUTABLE})
  1850. endif()
  1851. set(CTEST_TEST_UPDATE_CVS ${CVS_FOUND})
  1852. if(CTEST_TEST_UPDATE_CVS AND NOT UNIX)
  1853. if("${CVS_EXECUTABLE}" MATCHES "cygwin")
  1854. message(STATUS "No CTest.UpdateCVS test with cygwin cvs.exe outside cygwin!")
  1855. set(CTEST_TEST_UPDATE_CVS 0)
  1856. endif()
  1857. endif()
  1858. if(CTEST_TEST_UPDATE_CVS)
  1859. set(CTestUpdateCVS_DIR "CTest UpdateCVS")
  1860. configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateCVS.cmake.in"
  1861. "${CMake_BINARY_DIR}/Tests/CTestUpdateCVS.cmake" @ONLY)
  1862. add_test(CTest.UpdateCVS ${CMAKE_CMAKE_COMMAND}
  1863. -P "${CMake_BINARY_DIR}/Tests/CTestUpdateCVS.cmake"
  1864. )
  1865. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateCVS_DIR}")
  1866. endif()
  1867. # Test CTest Update with BZR
  1868. find_program(BZR_EXECUTABLE NAMES bzr)
  1869. mark_as_advanced(BZR_EXECUTABLE)
  1870. set(CTEST_TEST_UPDATE_BZR 0)
  1871. if(BZR_EXECUTABLE)
  1872. if(NOT "${BZR_EXECUTABLE}" MATCHES "cygwin" OR UNIX)
  1873. set(CTEST_TEST_UPDATE_BZR 1)
  1874. endif()
  1875. endif()
  1876. if(CTEST_TEST_UPDATE_BZR)
  1877. # Check if xmloutput plugin is there
  1878. execute_process(COMMAND ${BZR_EXECUTABLE} xmlplugins RESULT_VARIABLE xmlplugres
  1879. OUTPUT_QUIET ERROR_QUIET)
  1880. if( NOT ${xmlplugres} )
  1881. set(CTestUpdateBZR_DIR "CTest UpdateBZR")
  1882. configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateBZR.cmake.in"
  1883. "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR.cmake" @ONLY)
  1884. add_test(CTest.UpdateBZR ${CMAKE_CMAKE_COMMAND}
  1885. -P "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR.cmake"
  1886. )
  1887. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateBZR_DIR}")
  1888. set(CTestUpdateBZR_DIR "CTest UpdateBZR_CLocale")
  1889. configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateBZR.cmake.in"
  1890. "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR_CLocale.cmake" @ONLY)
  1891. add_test(CTest.UpdateBZR.CLocale ${CMAKE_CMAKE_COMMAND}
  1892. -P "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR_CLocale.cmake"
  1893. )
  1894. set_tests_properties(CTest.UpdateBZR.CLocale PROPERTIES ENVIRONMENT LC_ALL=C)
  1895. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateBZR_DIR}")
  1896. endif()
  1897. endif()
  1898. # Test CTest Update with GIT
  1899. find_program(GIT_EXECUTABLE NAMES git)
  1900. mark_as_advanced(GIT_EXECUTABLE)
  1901. set(CTEST_TEST_UPDATE_GIT 0)
  1902. if(GIT_EXECUTABLE)
  1903. if(NOT "${GIT_EXECUTABLE}" MATCHES "cygwin" OR UNIX)
  1904. set(CTEST_TEST_UPDATE_GIT 1)
  1905. endif()
  1906. endif()
  1907. if(CTEST_TEST_UPDATE_GIT)
  1908. set(CTestUpdateGIT_DIR "CTest UpdateGIT")
  1909. configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateGIT.cmake.in"
  1910. "${CMake_BINARY_DIR}/Tests/CTestUpdateGIT.cmake" @ONLY)
  1911. add_test(CTest.UpdateGIT ${CMAKE_CMAKE_COMMAND}
  1912. -P "${CMake_BINARY_DIR}/Tests/CTestUpdateGIT.cmake"
  1913. )
  1914. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateGIT_DIR}")
  1915. endif()
  1916. # Test CTest Update with HG
  1917. find_program(HG_EXECUTABLE NAMES hg)
  1918. mark_as_advanced(HG_EXECUTABLE)
  1919. set(CTEST_TEST_UPDATE_HG 0)
  1920. if(HG_EXECUTABLE)
  1921. if(NOT "${HG_EXECUTABLE}" MATCHES "cygwin" OR UNIX)
  1922. set(CTEST_TEST_UPDATE_HG 1)
  1923. endif()
  1924. endif()
  1925. if(CTEST_TEST_UPDATE_HG)
  1926. set(CTestUpdateHG_DIR "CTest UpdateHG")
  1927. configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateHG.cmake.in"
  1928. "${CMake_BINARY_DIR}/Tests/CTestUpdateHG.cmake" @ONLY)
  1929. add_test(CTest.UpdateHG ${CMAKE_CMAKE_COMMAND}
  1930. -P "${CMake_BINARY_DIR}/Tests/CTestUpdateHG.cmake"
  1931. )
  1932. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateHG_DIR}")
  1933. endif()
  1934. # Test CTest Update with P4
  1935. find_program(P4_EXECUTABLE NAMES p4)
  1936. find_program(P4D_EXECUTABLE NAMES p4d)
  1937. mark_as_advanced(P4_EXECUTABLE P4D_EXECUTABLE)
  1938. set(CTEST_TEST_UPDATE_P4 0)
  1939. if(P4_EXECUTABLE AND P4D_EXECUTABLE)
  1940. if(NOT "${P4_EXECUTABLE};${P4D_EXECUTABLE}" MATCHES "cygwin" OR UNIX)
  1941. set(CTEST_TEST_UPDATE_P4 1)
  1942. endif()
  1943. endif()
  1944. if(CTEST_TEST_UPDATE_P4)
  1945. set(CTestUpdateP4_DIR "CTest UpdateP4")
  1946. configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateP4.cmake.in"
  1947. "${CMake_BINARY_DIR}/Tests/CTestUpdateP4.cmake" @ONLY)
  1948. add_test(CTest.UpdateP4 ${CMAKE_CMAKE_COMMAND}
  1949. -P "${CMake_BINARY_DIR}/Tests/CTestUpdateP4.cmake"
  1950. )
  1951. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateP4_DIR}")
  1952. endif()
  1953. endif()
  1954. configure_file(
  1955. "${CMake_SOURCE_DIR}/Tests/CTestTestFailure/testNoBuild.cmake.in"
  1956. "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testNoBuild.cmake"
  1957. @ONLY ESCAPE_QUOTES)
  1958. add_test(CTestTestNoBuild ${CMAKE_CTEST_COMMAND}
  1959. -S "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testNoBuild.cmake" -V
  1960. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testOut1.log"
  1961. )
  1962. set_tests_properties(CTestTestNoBuild PROPERTIES
  1963. FAIL_REGULAR_EXPRESSION "Error" WILL_FAIL true)
  1964. configure_file(
  1965. "${CMake_SOURCE_DIR}/Tests/CTestTestFailure/testNoExe.cmake.in"
  1966. "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testNoExe.cmake"
  1967. @ONLY ESCAPE_QUOTES)
  1968. add_test(CTestTestNoExe ${CMAKE_CTEST_COMMAND}
  1969. -S "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testNoExe.cmake" -V
  1970. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testOut2.log"
  1971. )
  1972. set_tests_properties(CTestTestNoExe PROPERTIES DEPENDS CTestTestNoBuild
  1973. PASS_REGULAR_EXPRESSION "Could not find executable"
  1974. FAIL_REGULAR_EXPRESSION "SegFault")
  1975. configure_file(
  1976. "${CMake_SOURCE_DIR}/Tests/CTestTestUpload/test.cmake.in"
  1977. "${CMake_BINARY_DIR}/Tests/CTestTestUpload/test.cmake"
  1978. @ONLY ESCAPE_QUOTES)
  1979. add_test(CTestTestUpload ${CMAKE_CTEST_COMMAND}
  1980. -S "${CMake_BINARY_DIR}/Tests/CTestTestUpload/test.cmake" -V
  1981. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestUpload/testOut.log"
  1982. )
  1983. set_tests_properties(CTestTestUpload PROPERTIES
  1984. PASS_REGULAR_EXPRESSION "Upload\\.xml")
  1985. configure_file(
  1986. "${CMake_SOURCE_DIR}/Tests/CTestTestEmptyBinaryDirectory/test.cmake.in"
  1987. "${CMake_BINARY_DIR}/Tests/CTestTestEmptyBinaryDirectory/test.cmake"
  1988. @ONLY ESCAPE_QUOTES)
  1989. add_test(CTestTestEmptyBinaryDirectory ${CMAKE_CTEST_COMMAND}
  1990. -S "${CMake_BINARY_DIR}/Tests/CTestTestEmptyBinaryDirectory/test.cmake" -V
  1991. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestEmptyBinaryDirectory/testOut.log"
  1992. )
  1993. set_tests_properties(CTestTestEmptyBinaryDirectory PROPERTIES
  1994. PASS_REGULAR_EXPRESSION "TEST_SUCCESS")
  1995. configure_file(
  1996. "${CMake_SOURCE_DIR}/Tests/CTestTestConfigFileInBuildDir/test1.cmake.in"
  1997. "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir1/test1.cmake"
  1998. @ONLY ESCAPE_QUOTES)
  1999. add_test(CTestTestConfigFileInBuildDir1 ${CMAKE_CTEST_COMMAND}
  2000. -S "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir1/test1.cmake" -V
  2001. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir1/testOut1.log"
  2002. )
  2003. REGEX_ESCAPE_STRING(CTEST_TEST_ESCAPED_SOURCE_DIR "${CMake_SOURCE_DIR}")
  2004. set_tests_properties(CTestTestConfigFileInBuildDir1 PROPERTIES DEPENDS CTestTestNoBuild
  2005. PASS_REGULAR_EXPRESSION
  2006. "Reading ctest configuration file: ${CTEST_TEST_ESCAPED_SOURCE_DIR}.Tests.CTestTestConfigFileInBuildDir.CTestConfig.cmake")
  2007. configure_file(
  2008. "${CMake_SOURCE_DIR}/Tests/CTestTestConfigFileInBuildDir/test2.cmake.in"
  2009. "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir2/test2.cmake"
  2010. @ONLY ESCAPE_QUOTES)
  2011. configure_file(
  2012. "${CMake_SOURCE_DIR}/Tests/CTestTestConfigFileInBuildDir/CTestConfig.cmake"
  2013. "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir2/CTestConfig.cmake"
  2014. @ONLY ESCAPE_QUOTES COPYONLY)
  2015. add_test(CTestTestConfigFileInBuildDir2 ${CMAKE_CTEST_COMMAND}
  2016. -S "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir2/test2.cmake" -V
  2017. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir2/testOut2.log"
  2018. )
  2019. REGEX_ESCAPE_STRING(CTEST_TEST_ESCAPED_BINARY_DIR "${CMake_BINARY_DIR}")
  2020. set_tests_properties(CTestTestConfigFileInBuildDir2 PROPERTIES DEPENDS CTestTestNoBuild
  2021. REQUIRED_FILES ${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir2/CTestConfig.cmake
  2022. PASS_REGULAR_EXPRESSION
  2023. "Reading ctest configuration file: ${CTEST_TEST_ESCAPED_BINARY_DIR}.Tests.CTestTestConfigFileInBuildDir2.CTestConfig.cmake")
  2024. # test coverage for mumps
  2025. # create a MumpsCoverage dir in the binary tree under Testing to
  2026. # avoid the .NoDartCoverage files in the cmake testing tree
  2027. configure_file(
  2028. "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/DartConfiguration.tcl.in"
  2029. "${CMake_BINARY_DIR}/Testing/MumpsCoverage/DartConfiguration.tcl")
  2030. configure_file(
  2031. "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/gtm_coverage.mcov.in"
  2032. "${CMake_BINARY_DIR}/Testing/MumpsCoverage/gtm_coverage.mcov")
  2033. file(REMOVE_RECURSE "${CMake_BINARY_DIR}/Testing/MumpsCoverage/VistA-FOIA")
  2034. file(COPY "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/VistA-FOIA"
  2035. DESTINATION "${CMake_BINARY_DIR}/Testing/MumpsCoverage")
  2036. add_test(NAME CTestGTMCoverage
  2037. COMMAND cmake -E chdir
  2038. ${CMake_BINARY_DIR}/Testing/MumpsCoverage
  2039. $<TARGET_FILE:ctest> -T Coverage --debug)
  2040. set_tests_properties(CTestGTMCoverage PROPERTIES
  2041. PASS_REGULAR_EXPRESSION
  2042. "Process file.*ZZCOVTST.m.*Total LOC:.*30.*Percentage Coverage: 80.00*"
  2043. ENVIRONMENT COVFILE=)
  2044. configure_file(
  2045. "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/DartConfiguration.cache.tcl.in"
  2046. "${CMake_BINARY_DIR}/Testing/MumpsCacheCoverage/DartConfiguration.tcl")
  2047. configure_file(
  2048. "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/cache_coverage.cmcov.in"
  2049. "${CMake_BINARY_DIR}/Testing/MumpsCacheCoverage/cache_coverage.cmcov")
  2050. file(REMOVE_RECURSE "${CMake_BINARY_DIR}/Testing/MumpsCacheCoverage/VistA-FOIA")
  2051. file(COPY "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/VistA-FOIA"
  2052. DESTINATION "${CMake_BINARY_DIR}/Testing/MumpsCacheCoverage")
  2053. add_test(NAME CTestCacheCoverage
  2054. COMMAND cmake -E chdir
  2055. ${CMake_BINARY_DIR}/Testing/MumpsCacheCoverage
  2056. $<TARGET_FILE:ctest> -T Coverage --debug)
  2057. set_tests_properties(CTestCacheCoverage PROPERTIES
  2058. PASS_REGULAR_EXPRESSION
  2059. "Process file.*ZZCOVTST.m.*Total LOC:.*29.*Percentage Coverage: 86.21.*"
  2060. ENVIRONMENT COVFILE=)
  2061. # Adding a test case for Python Coverage
  2062. configure_file(
  2063. "${CMake_SOURCE_DIR}/Tests/PythonCoverage/coverage.xml.in"
  2064. "${CMake_BINARY_DIR}/Testing/PythonCoverage/coverage.xml")
  2065. configure_file(
  2066. "${CMake_SOURCE_DIR}/Tests/PythonCoverage/DartConfiguration.tcl.in"
  2067. "${CMake_BINARY_DIR}/Testing/PythonCoverage/DartConfiguration.tcl")
  2068. file(COPY "${CMake_SOURCE_DIR}/Tests/PythonCoverage/coveragetest"
  2069. DESTINATION "${CMake_BINARY_DIR}/Testing/PythonCoverage")
  2070. add_test(NAME CTestPythonCoverage
  2071. COMMAND cmake -E chdir
  2072. ${CMake_BINARY_DIR}/Testing/PythonCoverage
  2073. $<TARGET_FILE:ctest> -T Coverage --debug)
  2074. set_tests_properties(CTestPythonCoverage PROPERTIES
  2075. PASS_REGULAR_EXPRESSION
  2076. "Process file.*foo.py.*Total LOC:.*13.*Percentage Coverage: 84.62.*"
  2077. ENVIRONMENT COVFILE=)
  2078. # Adding a test case for non-python Cobertura Coverage
  2079. configure_file(
  2080. "${CMake_SOURCE_DIR}/Tests/CoberturaCoverage/DartConfiguration.tcl.in"
  2081. "${CMake_BINARY_DIR}/Testing/CoberturaCoverage/DartConfiguration.tcl")
  2082. configure_file(
  2083. "${CMake_SOURCE_DIR}/Tests/CoberturaCoverage/coverage.xml.in"
  2084. "${CMake_BINARY_DIR}/Testing/CoberturaCoverage/coverage.xml")
  2085. file(COPY "${CMake_SOURCE_DIR}/Tests/CoberturaCoverage/src"
  2086. DESTINATION "${CMake_BINARY_DIR}/Testing/CoberturaCoverage")
  2087. add_test(NAME CTestCoberturaCoverage
  2088. COMMAND cmake -E chdir
  2089. ${CMake_BINARY_DIR}/Testing/CoberturaCoverage
  2090. $<TARGET_FILE:ctest> -T Coverage --debug)
  2091. set_tests_properties(CTestCoberturaCoverage PROPERTIES
  2092. PASS_REGULAR_EXPRESSION
  2093. "Process file.*CoverageTest.java.*Total LOC:.*18.*Percentage Coverage: 72.22.*"
  2094. ENVIRONMENT COVFILE=)
  2095. # Adding a test case for JaCoCo Coverage
  2096. configure_file(
  2097. "${CMake_SOURCE_DIR}/Tests/JacocoCoverage/DartConfiguration.tcl.in"
  2098. "${CMake_BINARY_DIR}/Testing/JacocoCoverage/DartConfiguration.tcl")
  2099. file(COPY "${CMake_SOURCE_DIR}/Tests/JacocoCoverage/Coverage"
  2100. DESTINATION "${CMake_BINARY_DIR}/Testing/JacocoCoverage")
  2101. add_test(NAME CTestJacocoCoverage
  2102. COMMAND cmake -E chdir
  2103. ${CMake_BINARY_DIR}/Testing/JacocoCoverage
  2104. $<TARGET_FILE:ctest> -T Coverage --debug)
  2105. set_tests_properties(CTestJacocoCoverage PROPERTIES
  2106. PASS_REGULAR_EXPRESSION
  2107. "Process file.*CoverageTest.java.*Total LOC:.*17.*Percentage Coverage: 76.47*"
  2108. ENVIRONMENT COVFILE=)
  2109. function(add_config_tests cfg)
  2110. set(base "${CMake_BINARY_DIR}/Tests/CTestConfig")
  2111. # Test -S script with a -C config arg to ctest:
  2112. configure_file(
  2113. "${CMake_SOURCE_DIR}/Tests/CTestConfig/script.cmake.in"
  2114. "${base}/${cfg}-script.cmake"
  2115. @ONLY ESCAPE_QUOTES)
  2116. add_test(CTestConfig.Script.${cfg} ${CMAKE_CTEST_COMMAND}
  2117. -C ${cfg}
  2118. -S "${base}/${cfg}-script.cmake" -VV
  2119. --output-log "${base}/${cfg}-script.log"
  2120. )
  2121. # Test -D dashboard with a -C config arg to ctest.
  2122. # (Actual commands inside a cmake -P script because we need to be able to set
  2123. # the working directory reliably...)
  2124. configure_file(
  2125. "${CMake_SOURCE_DIR}/Tests/CTestConfig/dashboard.cmake.in"
  2126. "${base}/${cfg}-dashboard.cmake"
  2127. @ONLY ESCAPE_QUOTES)
  2128. add_test(CTestConfig.Dashboard.${cfg} ${CMAKE_CMAKE_COMMAND}
  2129. -P "${base}/${cfg}-dashboard.cmake" -VV
  2130. )
  2131. endfunction()
  2132. add_config_tests(Debug)
  2133. add_config_tests(MinSizeRel)
  2134. add_config_tests(Release)
  2135. add_config_tests(RelWithDebInfo)
  2136. # Test -S script with some -D variable definition args to ctest:
  2137. add_test(CTestConfig.ScriptWithArgs ${CMAKE_CTEST_COMMAND}
  2138. -C "Release"
  2139. -D arg1=this
  2140. -D arg2=that
  2141. -D "arg3=the other"
  2142. "-Darg4=this is the fourth"
  2143. -Darg5=the_fifth
  2144. -Darg6:STRING=value-with-type
  2145. -S "${CMake_SOURCE_DIR}/Tests/CTestConfig/ScriptWithArgs.cmake" -VV
  2146. --output-log "${CMake_BINARY_DIR}/Tests/CTestConfig/ScriptWithArgs.log"
  2147. )
  2148. ADD_TEST_MACRO(CMakeCommands.add_compile_options add_compile_options)
  2149. ADD_TEST_MACRO(CMakeCommands.target_link_libraries target_link_libraries)
  2150. ADD_TEST_MACRO(CMakeCommands.target_include_directories target_include_directories)
  2151. ADD_TEST_MACRO(CMakeCommands.target_compile_definitions target_compile_definitions)
  2152. ADD_TEST_MACRO(CMakeCommands.target_compile_options target_compile_options)
  2153. configure_file(
  2154. "${CMake_SOURCE_DIR}/Tests/CTestTestCrash/test.cmake.in"
  2155. "${CMake_BINARY_DIR}/Tests/CTestTestCrash/test.cmake"
  2156. @ONLY ESCAPE_QUOTES)
  2157. add_test(CTestTestCrash ${CMAKE_CTEST_COMMAND}
  2158. -S "${CMake_BINARY_DIR}/Tests/CTestTestCrash/test.cmake" -V
  2159. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestCrash/testOutput.log"
  2160. )
  2161. # with watcom the SEGFAULT is not found, it just fails
  2162. if(CMAKE_GENERATOR MATCHES "Watcom WMake")
  2163. set_tests_properties(CTestTestCrash PROPERTIES
  2164. PASS_REGULAR_EXPRESSION "Failed")
  2165. else()
  2166. set_tests_properties(CTestTestCrash PROPERTIES
  2167. PASS_REGULAR_EXPRESSION "(Illegal|SegFault)")
  2168. endif()
  2169. configure_file(
  2170. "${CMake_SOURCE_DIR}/Tests/CTestTestBadExe/test.cmake.in"
  2171. "${CMake_BINARY_DIR}/Tests/CTestTestBadExe/test.cmake"
  2172. @ONLY ESCAPE_QUOTES)
  2173. add_test(CTestTestBadExe ${CMAKE_CTEST_COMMAND}
  2174. -S "${CMake_BINARY_DIR}/Tests/CTestTestBadExe/test.cmake" -V
  2175. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestBadExe/testOutput.log"
  2176. )
  2177. set(CTestTestBadExe_REGEX "BAD_COMMAND")
  2178. # some cygwin can not be made to produce a BAD_COMMAND error
  2179. # the best we can get from it is a failed test
  2180. if(CYGWIN)
  2181. set(CTestTestBadExe_REGEX "(\\*\\*\\*Failed)|BAD_COMMAND")
  2182. endif()
  2183. set_tests_properties(CTestTestBadExe PROPERTIES
  2184. PASS_REGULAR_EXPRESSION "${CTestTestBadExe_REGEX}")
  2185. configure_file(
  2186. "${CMake_SOURCE_DIR}/Tests/CTestTestBadGenerator/test.cmake.in"
  2187. "${CMake_BINARY_DIR}/Tests/CTestTestBadGenerator/test.cmake"
  2188. @ONLY ESCAPE_QUOTES)
  2189. add_test(CTestTestBadGenerator ${CMAKE_CTEST_COMMAND}
  2190. -C "\${CTestTest_CONFIG}"
  2191. -S "${CMake_BINARY_DIR}/Tests/CTestTestBadGenerator/test.cmake" -V
  2192. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestBadGenerator/testOutput.log"
  2193. )
  2194. set_property(TEST CTestTestBadGenerator PROPERTY
  2195. PASS_REGULAR_EXPRESSION "could not create generator named \"Bad Generator\"")
  2196. configure_file(
  2197. "${CMake_SOURCE_DIR}/Tests/CTestTestParallel/test.cmake.in"
  2198. "${CMake_BINARY_DIR}/Tests/CTestTestParallel/test.cmake"
  2199. @ONLY ESCAPE_QUOTES)
  2200. add_test(CTestTestParallel ${CMAKE_CTEST_COMMAND}
  2201. -S "${CMake_BINARY_DIR}/Tests/CTestTestParallel/test.cmake" -V
  2202. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestParallel/testOutput.log"
  2203. )
  2204. configure_file(
  2205. "${CMake_SOURCE_DIR}/Tests/CTestTestSkipReturnCode/test.cmake.in"
  2206. "${CMake_BINARY_DIR}/Tests/CTestTestSkipReturnCode/test.cmake"
  2207. @ONLY ESCAPE_QUOTES)
  2208. add_test(CTestTestSkipReturnCode ${CMAKE_CTEST_COMMAND}
  2209. -S "${CMake_BINARY_DIR}/Tests/CTestTestSkipReturnCode/test.cmake" -V
  2210. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestSkipReturnCode/testOutput.log"
  2211. -C \${CTEST_CONFIGURATION_TYPE}
  2212. )
  2213. set_tests_properties(CTestTestSkipReturnCode PROPERTIES
  2214. PASS_REGULAR_EXPRESSION "CMakeV1 \\.* +Passed.*CMakeV2 \\.+\\*+Skipped")
  2215. ADD_TEST_MACRO(CTestTestSerialInDepends ${CMAKE_CTEST_COMMAND} -j 4
  2216. --output-on-failure -C "\${CTestTest_CONFIG}")
  2217. ADD_TEST_MACRO(CTestTestMissingDependsExe ${CMAKE_CTEST_COMMAND}
  2218. --output-on-failure -C "\${CTestTest_CONFIG}")
  2219. set_tests_properties(CTestTestMissingDependsExe PROPERTIES
  2220. PASS_REGULAR_EXPRESSION "\\*\\*\\*Not Run"
  2221. )
  2222. ADD_TEST_MACRO(CTestTestSerialOrder ${CMAKE_CTEST_COMMAND}
  2223. --output-on-failure -C "\${CTestTest_CONFIG}")
  2224. if(NOT BORLAND)
  2225. set(CTestLimitDashJ_CTEST_OPTIONS --force-new-ctest-process)
  2226. add_test_macro(CTestLimitDashJ ${CMAKE_CTEST_COMMAND} -j 4
  2227. --output-on-failure -C "\${CTestTest_CONFIG}")
  2228. endif()
  2229. add_test(CTestTestPrintLabels ${CMAKE_CTEST_COMMAND} --print-labels)
  2230. set_tests_properties(CTestTestPrintLabels PROPERTIES LABELS "Label1;Label2")
  2231. set_tests_properties(CTestTestPrintLabels PROPERTIES PASS_REGULAR_EXPRESSION
  2232. "All Labels:.* Label1.* Label2")
  2233. configure_file(
  2234. "${CMake_SOURCE_DIR}/Tests/CTestTestLabelRegExp/test.cmake.in"
  2235. "${CMake_BINARY_DIR}/Tests/CTestTestLabelRegExp/test.cmake"
  2236. @ONLY ESCAPE_QUOTES)
  2237. add_test(NAME CTestTestLabelRegExp
  2238. COMMAND ${CMAKE_CMAKE_COMMAND}
  2239. -DSOURCE_DIR=${CMAKE_SOURCE_DIR}/Tests/CTestTestLabelRegExp
  2240. -P ${CMAKE_BINARY_DIR}/Tests/CTestTestLabelRegExp/test.cmake
  2241. WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/Tests/CTestTestLabelRegExp
  2242. )
  2243. configure_file(
  2244. "${CMake_SOURCE_DIR}/Tests/CTestTestResourceLock/test.cmake.in"
  2245. "${CMake_BINARY_DIR}/Tests/CTestTestResourceLock/test.cmake"
  2246. @ONLY ESCAPE_QUOTES)
  2247. add_test(CTestTestResourceLock ${CMAKE_CTEST_COMMAND}
  2248. -S "${CMake_BINARY_DIR}/Tests/CTestTestResourceLock/test.cmake" -V
  2249. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestResourceLock/output.log"
  2250. )
  2251. configure_file(
  2252. "${CMake_SOURCE_DIR}/Tests/CTestTestScheduler/test.cmake.in"
  2253. "${CMake_BINARY_DIR}/Tests/CTestTestScheduler/test.cmake"
  2254. @ONLY ESCAPE_QUOTES)
  2255. add_test(CTestTestScheduler ${CMAKE_CTEST_COMMAND}
  2256. -S "${CMake_BINARY_DIR}/Tests/CTestTestScheduler/test.cmake" -V
  2257. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestScheduler/testOutput.log"
  2258. )
  2259. set_tests_properties(CTestTestScheduler PROPERTIES
  2260. PASS_REGULAR_EXPRESSION "Start 1.*Start 2.*Start 3.*Start 4.*Start 4.*Start 3.*Start 2.*Start 1"
  2261. RESOURCE_LOCK "CostData")
  2262. configure_file(
  2263. "${CMake_SOURCE_DIR}/Tests/CTestTestCostSerial/test.cmake.in"
  2264. "${CMake_BINARY_DIR}/Tests/CTestTestCostSerial/test.cmake"
  2265. @ONLY ESCAPE_QUOTES)
  2266. add_test(CTestTestCostSerial ${CMAKE_CTEST_COMMAND}
  2267. -S "${CMake_BINARY_DIR}/Tests/CTestTestCostSerial/test.cmake" -V
  2268. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestCostSerial/testOutput.log"
  2269. )
  2270. set_tests_properties(CTestTestCostSerial PROPERTIES
  2271. PASS_REGULAR_EXPRESSION "Start 2.*Start 3.*Start 1.*Start 2.*Start 3.*Start 1"
  2272. RESOURCE_LOCK "CostData")
  2273. configure_file(
  2274. "${CMake_SOURCE_DIR}/Tests/CTestTestStopTime/test.cmake.in"
  2275. "${CMake_BINARY_DIR}/Tests/CTestTestStopTime/test.cmake"
  2276. @ONLY ESCAPE_QUOTES)
  2277. configure_file(
  2278. "${CMake_SOURCE_DIR}/Tests/CTestTestStopTime/GetDate.cmake"
  2279. "${CMake_BINARY_DIR}/Tests/CTestTestStopTime/GetDate.cmake"
  2280. COPYONLY)
  2281. add_test(CTestTestStopTime ${CMAKE_CTEST_COMMAND}
  2282. -S "${CMake_BINARY_DIR}/Tests/CTestTestStopTime/test.cmake" -V
  2283. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestStopTime/testOutput.log"
  2284. )
  2285. set_tests_properties(CTestTestStopTime PROPERTIES
  2286. PASS_REGULAR_EXPRESSION "The stop time has been passed")
  2287. configure_file(
  2288. "${CMake_SOURCE_DIR}/Tests/CTestTestSubdir/test.cmake.in"
  2289. "${CMake_BINARY_DIR}/Tests/CTestTestSubdir/test.cmake"
  2290. @ONLY ESCAPE_QUOTES)
  2291. add_test(CTestTestSubdir ${CMAKE_CTEST_COMMAND}
  2292. -S "${CMake_BINARY_DIR}/Tests/CTestTestSubdir/test.cmake" -V
  2293. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestSubdir/testOutput.log"
  2294. )
  2295. #make sure all 3 subdirs were added
  2296. set_tests_properties(CTestTestSubdir PROPERTIES
  2297. PASS_REGULAR_EXPRESSION "0 tests failed out of 3")
  2298. configure_file(
  2299. "${CMake_SOURCE_DIR}/Tests/CTestTestTimeout/test.cmake.in"
  2300. "${CMake_BINARY_DIR}/Tests/CTestTestTimeout/test.cmake"
  2301. @ONLY ESCAPE_QUOTES)
  2302. add_test(CTestTestTimeout ${CMAKE_CTEST_COMMAND}
  2303. -C "\${CTestTest_CONFIG}"
  2304. -S "${CMake_BINARY_DIR}/Tests/CTestTestTimeout/test.cmake" -V
  2305. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestTimeout/testOutput.log"
  2306. )
  2307. set_tests_properties(CTestTestTimeout PROPERTIES
  2308. PASS_REGULAR_EXPRESSION "TestTimeout *\\.+ *\\*\\*\\*Timeout.*TestSleep *\\.+ *Passed.*timeout correctly killed child")
  2309. add_test(
  2310. NAME CTestTestRerunFailed
  2311. COMMAND ${CMAKE_CTEST_COMMAND} --rerun-failed)
  2312. set_tests_properties(CTestTestRerunFailed PROPERTIES
  2313. PASS_REGULAR_EXPRESSION "1/1 Test #1: TestTimeout" DEPENDS CTestTestTimeout
  2314. WORKING_DIRECTORY ${CMake_BINARY_DIR}/Tests/CTestTestTimeout)
  2315. configure_file(
  2316. "${CMake_SOURCE_DIR}/Tests/CTestTestZeroTimeout/test.cmake.in"
  2317. "${CMake_BINARY_DIR}/Tests/CTestTestZeroTimeout/test.cmake"
  2318. @ONLY ESCAPE_QUOTES)
  2319. add_test(CTestTestZeroTimeout ${CMAKE_CTEST_COMMAND}
  2320. -S "${CMake_BINARY_DIR}/Tests/CTestTestZeroTimeout/test.cmake" -V
  2321. --output-log
  2322. "${CMake_BINARY_DIR}/Tests/CTestTestZeroTimeout/testOutput.log")
  2323. set_tests_properties(CTestTestZeroTimeout PROPERTIES
  2324. FAIL_REGULAR_EXPRESSION "\\*\\*\\*Timeout")
  2325. configure_file(
  2326. "${CMake_SOURCE_DIR}/Tests/CTestTestDepends/test.cmake.in"
  2327. "${CMake_BINARY_DIR}/Tests/CTestTestDepends/test.cmake"
  2328. @ONLY ESCAPE_QUOTES)
  2329. add_test(CTestTestDepends ${CMAKE_CTEST_COMMAND}
  2330. -C "\${CTestTest_CONFIG}"
  2331. -S "${CMake_BINARY_DIR}/Tests/CTestTestDepends/test.cmake" -V
  2332. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestDepends/testOutput.log"
  2333. )
  2334. configure_file(
  2335. "${CMake_SOURCE_DIR}/Tests/CTestTestCycle/test.cmake.in"
  2336. "${CMake_BINARY_DIR}/Tests/CTestTestCycle/test.cmake"
  2337. @ONLY ESCAPE_QUOTES)
  2338. add_test(CTestTestCycle ${CMAKE_CTEST_COMMAND}
  2339. -C "\${CTestTest_CONFIG}"
  2340. -S "${CMake_BINARY_DIR}/Tests/CTestTestCycle/test.cmake" -V
  2341. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestCycle/testOutput.log"
  2342. )
  2343. set_tests_properties(CTestTestCycle PROPERTIES
  2344. PASS_REGULAR_EXPRESSION "a cycle exists in the test dependency graph")
  2345. configure_file(
  2346. "${CMake_SOURCE_DIR}/Tests/CTestTestRunScript/test.cmake.in"
  2347. "${CMake_BINARY_DIR}/Tests/CTestTestRunScript/test.cmake"
  2348. @ONLY ESCAPE_QUOTES)
  2349. configure_file(
  2350. "${CMake_SOURCE_DIR}/Tests/CTestTestRunScript/hello.cmake.in"
  2351. "${CMake_BINARY_DIR}/Tests/CTestTestRunScript/hello.cmake"
  2352. @ONLY ESCAPE_QUOTES)
  2353. add_test(CTestTestRunScript ${CMAKE_CTEST_COMMAND}
  2354. -S "${CMake_BINARY_DIR}/Tests/CTestTestRunScript/test.cmake" -V
  2355. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestRunScript/testOutput.log"
  2356. )
  2357. add_test(CTestTestShowOnly ${CMAKE_CTEST_COMMAND} -N)
  2358. add_test(CTestBatchTest ${CMAKE_CTEST_COMMAND} -B)
  2359. configure_file(
  2360. "${CMake_SOURCE_DIR}/Tests/CTestTestFdSetSize/test.cmake.in"
  2361. "${CMake_BINARY_DIR}/Tests/CTestTestFdSetSize/test.cmake"
  2362. @ONLY ESCAPE_QUOTES)
  2363. add_test(CTestTestFdSetSize ${CMAKE_CTEST_COMMAND}
  2364. -S "${CMake_BINARY_DIR}/Tests/CTestTestFdSetSize/test.cmake" -j20 -V --timeout 120
  2365. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestFdSetSize/testOutput.log"
  2366. )
  2367. function(add_failed_submit_test name source build in out log regex)
  2368. configure_file("${in}" "${out}" @ONLY)
  2369. add_test(${name} ${CMAKE_CTEST_COMMAND} -S "${out}" -V --output-log "${log}")
  2370. set_tests_properties(${name} PROPERTIES PASS_REGULAR_EXPRESSION "${regex}")
  2371. endfunction()
  2372. set(regex "(Problems when submitting via S*CP")
  2373. set(regex "${regex}|Error message was: ")
  2374. set(regex "${regex}([Cc]ould *n.t resolve host")
  2375. set(regex "${regex}|[Cc]ould *n.t connect to host")
  2376. set(regex "${regex}|Failed connect to")
  2377. set(regex "${regex}|Empty reply from server")
  2378. set(regex "${regex}|The requested URL returned error")
  2379. set(regex "${regex}|libcurl was built with SSL disabled. https: not supported)")
  2380. set(regex "${regex}|Submission method .xmlrpc. not compiled into CTest")
  2381. set(regex "${regex}|Submission problem")
  2382. set(regex "${regex}|Submission successful)")
  2383. set(ctest_coverage_labels_args "")
  2384. foreach(drop_method cp ftp http https scp xmlrpc)
  2385. # Cycle through these values each time through the loop:
  2386. if(ctest_coverage_labels_args STREQUAL "")
  2387. set(ctest_coverage_labels_args "LABELS Everything")
  2388. elseif(ctest_coverage_labels_args STREQUAL "LABELS Everything")
  2389. set(ctest_coverage_labels_args "LABELS 0ArgTest")
  2390. else()
  2391. set(ctest_coverage_labels_args "")
  2392. endif()
  2393. add_failed_submit_test(CTestTestFailedSubmit-${drop_method}
  2394. "${CMake_SOURCE_DIR}/Tests/CTestTest/SmallAndFast"
  2395. "${CMake_BINARY_DIR}/Tests/CTestTestFailedSubmits/${drop_method}"
  2396. "${CMake_SOURCE_DIR}/Tests/CTestTestFailedSubmits/test.cmake.in"
  2397. "${CMake_BINARY_DIR}/Tests/CTestTestFailedSubmits/test-${drop_method}.cmake"
  2398. "${CMake_BINARY_DIR}/Tests/CTestTestFailedSubmits/test-${drop_method}.log"
  2399. "${regex}"
  2400. )
  2401. endforeach()
  2402. if (CMAKE_TESTS_CDASH_SERVER)
  2403. set(regex "^([^:]+)://([^/]+)(.*)$")
  2404. if ("${CMAKE_TESTS_CDASH_SERVER}" MATCHES "${regex}")
  2405. set(protocol "${CMAKE_MATCH_1}")
  2406. set(server "${CMAKE_MATCH_2}")
  2407. set(path "${CMAKE_MATCH_3}")
  2408. else ()
  2409. set(protocol "http")
  2410. set(server "open.cdash.org")
  2411. set(path "")
  2412. message("warning: CMAKE_TESTS_CDASH_SERVER does not match expected regex...")
  2413. message(" ...using default url='${protocol}://${server}${path}' for CTestTest[23]")
  2414. endif ()
  2415. endif ()
  2416. if (CTEST_TEST_CTEST AND CMAKE_RUN_LONG_TESTS AND CMAKE_TESTS_CDASH_SERVER)
  2417. configure_file("${CMake_SOURCE_DIR}/Tests/CTestTest/test.cmake.in"
  2418. "${CMake_BINARY_DIR}/Tests/CTestTest/test.cmake" @ONLY ESCAPE_QUOTES)
  2419. add_test(CTestTest ${CMAKE_CTEST_COMMAND}
  2420. -S "${CMake_BINARY_DIR}/Tests/CTestTest/test.cmake" -V
  2421. --output-log "${CMake_BINARY_DIR}/Tests/CTestTest/testOutput.log"
  2422. )
  2423. configure_file("${CMake_SOURCE_DIR}/Tests/CTestTest2/test.cmake.in"
  2424. "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" @ONLY ESCAPE_QUOTES)
  2425. add_test(CTestTest2 ${CMAKE_CTEST_COMMAND}
  2426. -S "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" -V
  2427. --output-log "${CMake_BINARY_DIR}/Tests/CTestTest2/testOutput.log"
  2428. )
  2429. if("${CMAKE_GENERATOR}" MATCHES "Makefiles" OR "${CMAKE_GENERATOR}" MATCHES "Ninja")
  2430. configure_file("${CMake_SOURCE_DIR}/Tests/CTestTestLaunchers/test.cmake.in"
  2431. "${CMake_BINARY_DIR}/Tests/CTestTestLaunchers/test.cmake" @ONLY ESCAPE_QUOTES)
  2432. add_test(CTestTestLaunchers ${CMAKE_CTEST_COMMAND}
  2433. -S "${CMake_BINARY_DIR}/Tests/CTestTestLaunchers/test.cmake" -V
  2434. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestLaunchers/testOutput.log"
  2435. )
  2436. set_tests_properties(CTestTestLaunchers PROPERTIES
  2437. PASS_REGULAR_EXPRESSION "CTEST_TEST_LAUNCHER_SUCCESS")
  2438. endif()
  2439. configure_file("${CMake_SOURCE_DIR}/Tests/CTestTestChecksum/test.cmake.in"
  2440. "${CMake_BINARY_DIR}/Tests/CTestTestChecksum/test.cmake" @ONLY
  2441. ESCAPE_QUOTES)
  2442. add_test(CTestTestChecksum ${CMAKE_CTEST_COMMAND}
  2443. -S "${CMake_BINARY_DIR}/Tests/CTestTestChecksum/test.cmake" -V
  2444. --output-log
  2445. "${CMake_BINARY_DIR}/Tests/CTestTestChecksum/testOutput.log"
  2446. )
  2447. set_tests_properties(CTestTestChecksum PROPERTIES PASS_REGULAR_EXPRESSION
  2448. "Submission failed: Checksum failed for file")
  2449. # these tests take a long time, make sure they have it
  2450. # if timeouts have not already been set
  2451. get_test_property(CTestTest TIMEOUT PREVIOUS_TIMEOUT)
  2452. if ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND)
  2453. set_tests_properties ( CTestTest
  2454. PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT})
  2455. endif ()
  2456. get_test_property(CTestTest2 TIMEOUT PREVIOUS_TIMEOUT)
  2457. if ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND)
  2458. set_tests_properties ( CTestTest2
  2459. PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT})
  2460. endif ()
  2461. endif ()
  2462. if("${CMAKE_GENERATOR}" MATCHES Xcode)
  2463. set(CMAKE_SKIP_BOOTSTRAP_TEST 1)
  2464. endif()
  2465. if(EXISTS "${CMake_BINARY_DIR}/CMakeLists.txt")
  2466. # If there is CMakeLists.txt in the binary tree, assume in-source build
  2467. set(CMAKE_SKIP_BOOTSTRAP_TEST 1)
  2468. endif()
  2469. set(bootstrap "")
  2470. if(CMAKE_RUN_LONG_TESTS AND NOT CMAKE_SKIP_BOOTSTRAP_TEST)
  2471. if(UNIX)
  2472. set(bootstrap ${CMake_SOURCE_DIR}/bootstrap)
  2473. elseif(MSYS)
  2474. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/bootstrap.bat.in
  2475. ${CMAKE_CURRENT_BINARY_DIR}/bootstrap.bat @ONLY)
  2476. set(bootstrap ${CMAKE_CURRENT_BINARY_DIR}/bootstrap.bat)
  2477. endif()
  2478. endif()
  2479. if(bootstrap)
  2480. add_test(NAME BootstrapTest
  2481. COMMAND ${CMAKE_CMAKE_COMMAND}
  2482. -D "bootstrap=${bootstrap}"
  2483. -D "bin_dir=${CMake_BINARY_DIR}/Tests/BootstrapTest"
  2484. -P ${CMAKE_CURRENT_SOURCE_DIR}/BootstrapTest.cmake
  2485. )
  2486. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BootstrapTest")
  2487. # Make this test run early during parallel execution
  2488. set_tests_properties(BootstrapTest PROPERTIES COST 5000)
  2489. # provide more time for the bootstrap test
  2490. get_test_property(BootstrapTest TIMEOUT PREVIOUS_TIMEOUT)
  2491. if ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND)
  2492. set_tests_properties ( BootstrapTest
  2493. PROPERTIES TIMEOUT 5400)
  2494. endif ()
  2495. endif()
  2496. if(CMAKE_Fortran_COMPILER)
  2497. add_test(Fortran ${CMAKE_CTEST_COMMAND}
  2498. --build-and-test
  2499. "${CMake_SOURCE_DIR}/Tests/Fortran"
  2500. "${CMake_BINARY_DIR}/Tests/Fortran"
  2501. ${build_generator_args}
  2502. --build-project testf
  2503. --build-two-config
  2504. --build-options ${build_options}
  2505. -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM}
  2506. --test-command testf)
  2507. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Fortran")
  2508. # FortranCInterface tests.
  2509. if(UNIX)
  2510. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/FortranC/Flags.cmake.in
  2511. ${CMAKE_CURRENT_BINARY_DIR}/FortranC/Flags.cmake @ONLY)
  2512. add_test(FortranC.Flags ${CMAKE_CMAKE_COMMAND} -P
  2513. ${CMAKE_CURRENT_BINARY_DIR}/FortranC/Flags.cmake)
  2514. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/FortranC/Flags")
  2515. else()
  2516. add_test(FortranC ${CMAKE_CTEST_COMMAND}
  2517. --build-and-test
  2518. "${CMake_SOURCE_DIR}/Tests/FortranC"
  2519. "${CMake_BINARY_DIR}/Tests/FortranC"
  2520. ${build_generator_args}
  2521. --build-project FortranC
  2522. --build-two-config
  2523. --build-options ${build_options}
  2524. --test-command CMakeFiles/FortranCInterface/FortranCInterface)
  2525. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/FortranC")
  2526. endif()
  2527. endif()
  2528. find_package(Java COMPONENTS Development QUIET)
  2529. if(Java_JAVA_EXECUTABLE AND Java_JAVAC_EXECUTABLE AND Java_JAR_EXECUTABLE AND NOT MINGW
  2530. AND NOT "${CMAKE_GENERATOR}" MATCHES "Xcode")
  2531. get_filename_component(JNIPATH ${JAVA_COMPILE} PATH)
  2532. find_file(JNI_H jni.h
  2533. "${JNIPATH}/../include"
  2534. "${JNIPATH}/../java/include")
  2535. if(JNI_H AND EXISTS "${JNI_H}") # in case jni.h is a broken symlink
  2536. file(READ "${JNI_H}" JNI_FILE)
  2537. if("${JNI_FILE}" MATCHES "JDK1_2")
  2538. add_test(Java ${CMAKE_CTEST_COMMAND}
  2539. --build-and-test
  2540. "${CMake_SOURCE_DIR}/Tests/Java"
  2541. "${CMake_BINARY_DIR}/Tests/Java"
  2542. ${build_generator_args}
  2543. --build-project hello
  2544. --build-two-config
  2545. --build-run-dir "${CMake_BINARY_DIR}/Tests/Java/"
  2546. --build-options ${build_options}
  2547. --test-command ${JAVA_RUNTIME} -classpath hello.jar HelloWorld)
  2548. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Java")
  2549. endif()
  2550. endif()
  2551. endif()
  2552. # add some cross compiler tests, for now only with makefile based generators
  2553. if(CMAKE_GENERATOR MATCHES "Makefiles" OR CMAKE_GENERATOR MATCHES "KDevelop")
  2554. # if sdcc is found, build the SimpleCOnly project with sdcc
  2555. find_program(SDCC_EXECUTABLE sdcc)
  2556. mark_as_advanced(SDCC_EXECUTABLE)
  2557. if(SDCC_EXECUTABLE)
  2558. add_test(SimpleCOnly_sdcc ${CMAKE_CTEST_COMMAND}
  2559. --build-and-test
  2560. "${CMake_SOURCE_DIR}/Tests/SimpleCOnly"
  2561. "${CMake_BINARY_DIR}/Tests/SimpleCOnly_sdcc"
  2562. ${build_generator_args}
  2563. --build-project SimpleC
  2564. --build-options ${build_options}
  2565. "-DCMAKE_SYSTEM_NAME=Generic"
  2566. "-DCMAKE_C_COMPILER=${SDCC_EXECUTABLE}")
  2567. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SimpleCOnly_sdcc")
  2568. endif()
  2569. # If a Linux -> MinGW cross compiler is found then try it
  2570. find_program(MINGW_CC_LINUX2WIN_EXECUTABLE i586-mingw32msvc-gcc)
  2571. find_program(MINGW_CXX_LINUX2WIN_EXECUTABLE i586-mingw32msvc-g++)
  2572. find_program(MINGW_RC_LINUX2WIN_EXECUTABLE i586-mingw32msvc-windres)
  2573. mark_as_advanced(MINGW_CC_LINUX2WIN_EXECUTABLE MINGW_CXX_LINUX2WIN_EXECUTABLE MINGW_RC_LINUX2WIN_EXECUTABLE)
  2574. if(MINGW_CC_LINUX2WIN_EXECUTABLE AND MINGW_CXX_LINUX2WIN_EXECUTABLE AND MINGW_RC_LINUX2WIN_EXECUTABLE)
  2575. add_test(Simple_Mingw_Linux2Win ${CMAKE_CTEST_COMMAND}
  2576. --build-and-test
  2577. "${CMake_SOURCE_DIR}/Tests/Simple"
  2578. "${CMake_BINARY_DIR}/Tests/Simple_Mingw_Linux2Win"
  2579. ${build_generator_args}
  2580. --build-project Simple
  2581. --build-options ${build_options}
  2582. "-DCMAKE_SYSTEM_NAME=Windows"
  2583. "-DCMAKE_C_COMPILER=${MINGW_CC_LINUX2WIN_EXECUTABLE}"
  2584. "-DCMAKE_CXX_COMPILER=${MINGW_CXX_LINUX2WIN_EXECUTABLE}"
  2585. "-DCMAKE_RC_COMPILER=${MINGW_RC_LINUX2WIN_EXECUTABLE}"
  2586. )
  2587. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Simple_Mingw_Linux2Win")
  2588. endif()
  2589. endif()
  2590. if(CMAKE_TEST_PROJECT_CSE_DIR)
  2591. set(script "${CMAKE_TEST_PROJECT_CSE_DIR}/BuildProjectCSE.cmake")
  2592. if(NOT EXISTS "${script}")
  2593. set(script "${CMAKE_TEST_PROJECT_CSE_DIR}/cse_build.cmake")
  2594. endif()
  2595. if(NOT EXISTS "${script}")
  2596. message("warning: CMAKE_TEST_PROJECT_CSE_DIR set, but no build script found...")
  2597. endif()
  2598. add_test(BuildCSE ${CMAKE_CTEST_COMMAND} -V -S "${script}")
  2599. set_tests_properties(BuildCSE PROPERTIES TIMEOUT 5400)
  2600. endif()
  2601. if(CMAKE_TEST_PLPLOT_DIR)
  2602. add_test(plplot ${CMAKE_CTEST_COMMAND} -V -S ${CMAKE_TEST_PLPLOT_DIR}/../../EasyDashboardScripts/plplot.cmake )
  2603. set_tests_properties ( plplot PROPERTIES TIMEOUT 5400)
  2604. endif()
  2605. if(CMAKE_TEST_CHICKEN_DIR)
  2606. add_test(Chicken ${CMAKE_CTEST_COMMAND} -V -S ${CMAKE_TEST_CHICKEN_DIR}/../../EasyDashboardScripts/Chicken.cmake )
  2607. set_tests_properties ( Chicken PROPERTIES TIMEOUT 5400)
  2608. endif()
  2609. if(CMAKE_TEST_KDELIBS_ALPHA_1_DIR)
  2610. add_test(KDELibsAlpha1 ${CMAKE_CTEST_COMMAND} -V -S ${CMAKE_TEST_KDELIBS_ALPHA_1_DIR}/../../EasyDashboardScripts/kdelibs.cmake )
  2611. set_tests_properties ( KDELibsAlpha1 PROPERTIES TIMEOUT 5400)
  2612. endif()
  2613. # If this is not an in-source build, provide a target to wipe out
  2614. # all the test build directories.
  2615. if(NOT EXISTS "${CMake_BINARY_DIR}/CMakeLists.txt")
  2616. configure_file(${CMake_SOURCE_DIR}/Tests/test_clean.cmake.in
  2617. ${CMake_BINARY_DIR}/Tests/test_clean.cmake @ONLY)
  2618. add_custom_target(test_clean
  2619. COMMAND ${CMAKE_COMMAND} -P ${CMake_BINARY_DIR}/Tests/test_clean.cmake
  2620. COMMENT "Removing test build directories."
  2621. )
  2622. endif()
  2623. add_test(NAME CMakeWizardTest COMMAND cmake -i)
  2624. set_property(TEST CMakeWizardTest PROPERTY PASS_REGULAR_EXPRESSION
  2625. "The \"cmake -i\" wizard mode is no longer supported.")
  2626. # If the cache variable CMAKE_CONTRACT_PROJECTS is set
  2627. # then the dashboard will run a contract with CMake test of that
  2628. # name. For example CMAKE_CONTRACT_PROJECTS = vtk542 would run
  2629. # the vtk542 contract test.
  2630. # For each Contract test, the project should provide a directory
  2631. # with at least one CMakeLists.txt file that uses ExternalProject
  2632. # to download and configure the project. The directory should also
  2633. # contain a RunTest.cmake file that has a single set of the format:
  2634. # set(project_RUN_TEST testToRun)
  2635. # The testToRun should be a test executable that can be run to
  2636. # smoke test the build.
  2637. foreach(project ${CMAKE_CONTRACT_PROJECTS})
  2638. include(Contracts/${project}/RunTest.cmake)
  2639. ADD_TEST_MACRO(Contracts.${project}
  2640. ${${project}_RUN_TEST})
  2641. # Contract test timeout in seconds.
  2642. # Default to 6 hours.
  2643. if(DEFINED ${project}_TEST_TIMEOUT)
  2644. set(timeout ${${project}_TEST_TIMEOUT})
  2645. elseif(CMAKE_CONTRACT_TEST_TIMEOUT_DEFAULT)
  2646. set(timeout ${CMAKE_CONTRACT_TEST_TIMEOUT_DEFAULT})
  2647. else()
  2648. set(timeout 21600)
  2649. endif()
  2650. set_tests_properties(Contracts.${project} PROPERTIES TIMEOUT ${timeout})
  2651. endforeach()
  2652. if(TEST_CompileCommandOutput)
  2653. set(CompileCommandOutput_BUILD_OPTIONS
  2654. -DMAKE_SUPPORTS_SPACES=${MAKE_SUPPORTS_SPACES})
  2655. ADD_TEST_MACRO(CompileCommandOutput
  2656. "${CMake_BINARY_DIR}/Tests/CMakeLib/runcompilecommands")
  2657. endif()
  2658. add_test(IncludeDirectories ${CMAKE_CTEST_COMMAND}
  2659. --build-and-test
  2660. "${CMake_SOURCE_DIR}/Tests/IncludeDirectories"
  2661. "${CMake_BINARY_DIR}/Tests/IncludeDirectories"
  2662. --build-two-config
  2663. ${build_generator_args}
  2664. --build-project IncludeDirectories
  2665. --build-options ${build_options}
  2666. --test-command IncludeDirectories)
  2667. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/IncludeDirectories")
  2668. add_test(InterfaceLinkLibraries ${CMAKE_CTEST_COMMAND}
  2669. --build-and-test
  2670. "${CMake_SOURCE_DIR}/Tests/InterfaceLinkLibraries"
  2671. "${CMake_BINARY_DIR}/Tests/InterfaceLinkLibraries"
  2672. --build-two-config
  2673. ${build_generator_args}
  2674. --build-project InterfaceLinkLibraries
  2675. --build-options ${build_options}
  2676. --test-command InterfaceLinkLibraries)
  2677. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/InterfaceLinkLibraries")
  2678. if(CMAKE_USE_KWSTYLE AND KWSTYLE_EXECUTABLE)
  2679. # The "make StyleCheck" command line as a test. If the test fails, look
  2680. # for lines like "Error #0 (624) Line length exceed 88 (max=79)" in the
  2681. # output to find where the style errors are...
  2682. add_test(KWStyle ${KWSTYLE_EXECUTABLE}
  2683. -xml ${CMake_BINARY_DIR}/CMake.kws.xml
  2684. -o ${CMake_SOURCE_DIR}/Utilities/KWStyle/CMakeOverwrite.txt
  2685. -v
  2686. -D ${CMake_BINARY_DIR}/CMakeKWSFiles.txt
  2687. )
  2688. set_tests_properties(KWStyle PROPERTIES
  2689. WORKING_DIRECTORY ${CMake_BINARY_DIR}/Utilities/KWStyle)
  2690. endif()
  2691. if(NOT CMake_TEST_EXTERNAL_CMAKE)
  2692. add_subdirectory(CMakeTests)
  2693. endif()
  2694. endif()