CMakeLists.txt 133 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392
  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}/CheckFortran.cmake)
  20. # Fake a user home directory to avoid polluting the real one.
  21. if(DEFINED ENV{HOME} AND NOT CTEST_NO_TEST_HOME)
  22. set(TEST_HOME "${CMake_BINARY_DIR}/Tests/CMakeFiles/TestHome")
  23. file(MAKE_DIRECTORY "${TEST_HOME}")
  24. file(WRITE "${TEST_HOME}/.cvspass" ":pserver:[email protected]:/cvsroot/KWSys A\n")
  25. set(TEST_HOME_ENV_CODE "# Fake a user home directory to avoid polluting the real one.
  26. # But provide original ENV{HOME} value in ENV{CTEST_REAL_HOME} for tests that
  27. # need access to the real HOME directory.
  28. set(ENV{CTEST_REAL_HOME} \"\$ENV{HOME}\")
  29. set(ENV{HOME} \"${TEST_HOME}\")
  30. ")
  31. endif()
  32. # Choose a default configuration for CTest tests.
  33. set(CTestTest_CONFIG Debug)
  34. if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE)
  35. set(CTestTest_CONFIG ${CMAKE_BUILD_TYPE})
  36. endif()
  37. configure_file(${CMake_SOURCE_DIR}/Tests/EnforceConfig.cmake.in
  38. ${CMake_BINARY_DIR}/Tests/EnforceConfig.cmake @ONLY)
  39. # Testing
  40. if(BUILD_TESTING)
  41. set(CMake_TEST_DEVENV "")
  42. if(CMAKE_VS_DEVENV_COMMAND)
  43. set(CMake_TEST_DEVENV "${CMAKE_VS_DEVENV_COMMAND}")
  44. elseif(CMAKE_GENERATOR MATCHES "Visual Studio [89] " AND
  45. NOT CMAKE_MAKE_PROGRAM MATCHES "[mM][sS][bB][uU][iI][lL][dD]\\.[eE][xX][eE]")
  46. set(CMake_TEST_DEVENV "${CMAKE_MAKE_PROGRAM}")
  47. endif()
  48. if(CMAKE_GENERATOR MATCHES "Visual Studio|Xcode")
  49. set(CMake_TEST_EXPLICIT_MAKE_PROGRAM "")
  50. else()
  51. set(CMake_TEST_EXPLICIT_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM}")
  52. endif()
  53. if(NOT CMake_TEST_EXTERNAL_CMAKE)
  54. if("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles" OR ("${CMAKE_GENERATOR}" MATCHES Ninja AND NOT WIN32))
  55. set(TEST_CompileCommandOutput 1)
  56. endif()
  57. endif()
  58. set(MAKE_IS_GNU )
  59. if(CMAKE_MAKE_PROGRAM MATCHES make)
  60. execute_process(COMMAND ${CMAKE_MAKE_PROGRAM} no_such_target --version
  61. RESULT_VARIABLE res OUTPUT_VARIABLE out ERROR_VARIABLE out)
  62. if("${res}" STREQUAL "0")
  63. if("${out}" MATCHES "GNU")
  64. set(MAKE_IS_GNU 1)
  65. endif()
  66. endif()
  67. endif()
  68. # some old versions of make simply cannot handle spaces in paths
  69. if (MAKE_IS_GNU OR
  70. CMAKE_MAKE_PROGRAM MATCHES "nmake|gmake|wmake" OR
  71. CMAKE_GENERATOR MATCHES "Visual Studio|Xcode|Borland")
  72. set(MAKE_SUPPORTS_SPACES 1)
  73. else()
  74. set(MAKE_SUPPORTS_SPACES 0)
  75. endif()
  76. # assume no resources building to test
  77. set(CMake_TEST_RESOURCES FALSE)
  78. # for windows and cygwin assume we have resources
  79. if(WIN32 OR CYGWIN)
  80. set(CMake_TEST_RESOURCES TRUE)
  81. endif()
  82. # for borland and watcom there is no resource support
  83. if(WATCOM OR BORLAND)
  84. set(CMake_TEST_RESOURCES FALSE)
  85. endif()
  86. set(build_generator_args
  87. --build-generator ${CMAKE_GENERATOR}
  88. )
  89. if(CMAKE_GENERATOR_PLATFORM)
  90. list(APPEND build_generator_args
  91. --build-generator-platform ${CMAKE_GENERATOR_PLATFORM}
  92. )
  93. endif()
  94. if(CMAKE_GENERATOR_TOOLSET)
  95. list(APPEND build_generator_args
  96. --build-generator-toolset ${CMAKE_GENERATOR_TOOLSET}
  97. )
  98. endif()
  99. set(build_options)
  100. if(CMake_TEST_EXPLICIT_MAKE_PROGRAM)
  101. list(APPEND build_options -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM})
  102. endif()
  103. # Look for rpmbuild to use for tests.
  104. # The tool does not work with spaces in the path.
  105. if(NOT CMAKE_CURRENT_BINARY_DIR MATCHES " ")
  106. find_program(RPMBUILD_EXECUTABLE NAMES rpmbuild)
  107. else()
  108. set(RPMBUILD_EXECUTABLE "RPMBUILD_EXECUTABLE-NOTFOUND")
  109. endif()
  110. if(RPMBUILD_EXECUTABLE)
  111. set(CPACK_BINARY_RPM ON)
  112. else()
  113. set(CPACK_BINARY_RPM OFF)
  114. endif()
  115. # Look for rpmbuild to use for tests.
  116. # The tool does not work with spaces in the path.
  117. find_program(DPKG_EXECUTABLE NAMES dpkg)
  118. if(DPKG_EXECUTABLE)
  119. set(CPACK_BINARY_DEB ON)
  120. else()
  121. set(CPACK_BINARY_DEB OFF)
  122. endif()
  123. #---------------------------------------------------------------------------
  124. # Add tests below here.
  125. if(NOT CMake_TEST_EXTERNAL_CMAKE)
  126. add_subdirectory(CMakeLib)
  127. endif()
  128. add_subdirectory(CMakeOnly)
  129. add_subdirectory(RunCMake)
  130. add_subdirectory(FindPackageModeMakefileTest)
  131. # Collect a list of all test build directories.
  132. set(TEST_BUILD_DIRS)
  133. # Should the long tests be run?
  134. option(CMAKE_RUN_LONG_TESTS
  135. "Should the long tests be run (such as Bootstrap)." ON)
  136. mark_as_advanced(CMAKE_RUN_LONG_TESTS)
  137. if (CMAKE_RUN_LONG_TESTS)
  138. option(CTEST_TEST_CTEST
  139. "Should the tests that run a full sub ctest process be run?"
  140. OFF)
  141. mark_as_advanced(CTEST_TEST_CTEST)
  142. endif ()
  143. # Should tests that use CVS be run?
  144. #
  145. set(do_cvs_tests 0)
  146. if(EXISTS ${CMAKE_ROOT}/Modules/FindCVS.cmake)
  147. find_package(CVS QUIET)
  148. else()
  149. find_program(CVS_EXECUTABLE NAMES cvs)
  150. endif()
  151. if(CVS_EXECUTABLE)
  152. set(do_cvs_tests 1)
  153. endif()
  154. if(do_cvs_tests AND NOT UNIX)
  155. if("${CVS_EXECUTABLE}" MATCHES "cygwin")
  156. set(do_cvs_tests 0)
  157. endif()
  158. endif()
  159. # Should CPack tests be run? By default, yes, but...
  160. #
  161. # Disable packaging test on Apple 10.3 and below. PackageMaker starts
  162. # DiskManagementTool as root and disowns it
  163. # (http://lists.apple.com/archives/installer-dev/2005/Jul/msg00005.html).
  164. # It is left holding open pipe handles and preventing ProcessUNIX from
  165. # detecting end-of-data even after its immediate child exits. Then
  166. # the test hangs until it times out and is killed. This is a
  167. # well-known bug in kwsys process execution that I would love to get
  168. # time to fix.
  169. #
  170. option(CTEST_TEST_CPACK
  171. "Should the tests that use '--build-target package' be run?"
  172. ON)
  173. mark_as_advanced(CTEST_TEST_CPACK)
  174. set(CTEST_TEST_OSX_ARCH 0)
  175. set(CMake_TEST_XCODE_VERSION 0)
  176. if(APPLE)
  177. execute_process(
  178. COMMAND sw_vers -productVersion
  179. OUTPUT_VARIABLE OSX_VERSION
  180. OUTPUT_STRIP_TRAILING_WHITESPACE
  181. )
  182. if(OSX_VERSION VERSION_LESS 10.4)
  183. message(STATUS "Forcing CTEST_TEST_CPACK=OFF on OSX < 10.4")
  184. message(STATUS "OSX_VERSION='${OSX_VERSION}'")
  185. set(CTEST_TEST_CPACK OFF)
  186. else()
  187. set(CTEST_TEST_OSX_ARCH 1)
  188. endif()
  189. if(XCODE_VERSION)
  190. set(CMake_TEST_XCODE_VERSION "${XCODE_VERSION}")
  191. else()
  192. execute_process(
  193. COMMAND xcodebuild -version
  194. OUTPUT_VARIABLE _version ERROR_VARIABLE _version
  195. )
  196. if(_version MATCHES "^Xcode ([0-9]+(\\.[0-9]+)*)")
  197. set(CMake_TEST_XCODE_VERSION "${CMAKE_MATCH_1}")
  198. endif()
  199. endif()
  200. if(CMAKE_OSX_SYSROOT)
  201. execute_process(
  202. COMMAND xcodebuild -sdk ${CMAKE_OSX_SYSROOT} -version ProductName
  203. OUTPUT_VARIABLE _stdout
  204. OUTPUT_STRIP_TRAILING_WHITESPACE
  205. ERROR_VARIABLE _stderr
  206. RESULT_VARIABLE _failed
  207. )
  208. if(NOT _failed)
  209. set(CMAKE_OSX_SDKPRODUCT "${_stdout}")
  210. endif()
  211. execute_process(
  212. COMMAND xcodebuild -sdk ${CMAKE_OSX_SYSROOT} -version SDKVersion
  213. OUTPUT_VARIABLE _stdout
  214. OUTPUT_STRIP_TRAILING_WHITESPACE
  215. ERROR_VARIABLE _stderr
  216. RESULT_VARIABLE _failed
  217. )
  218. if(NOT _failed)
  219. set(CMAKE_OSX_SDKVERSION "${_stdout}")
  220. endif()
  221. endif()
  222. endif()
  223. # Use 1500 or CTEST_TEST_TIMEOUT for long test timeout value,
  224. # whichever is greater.
  225. set(CMAKE_LONG_TEST_TIMEOUT 1500)
  226. if(CTEST_TEST_TIMEOUT)
  227. set(CMAKE_LONG_TEST_TIMEOUT ${CTEST_TEST_TIMEOUT})
  228. endif()
  229. if(CMAKE_LONG_TEST_TIMEOUT LESS 1500)
  230. set(CMAKE_LONG_TEST_TIMEOUT 1500)
  231. endif()
  232. add_test(NAME CMake.Copyright
  233. COMMAND cmake -P ${CMAKE_CURRENT_SOURCE_DIR}/CMakeCopyright.cmake)
  234. # add a bunch of standard build-and-test style tests
  235. ADD_TEST_MACRO(CommandLineTest CommandLineTest)
  236. ADD_TEST_MACRO(FindPackageTest FindPackageTest)
  237. ADD_TEST_MACRO(FindModulesExecuteAll FindModulesExecuteAll)
  238. ADD_TEST_MACRO(StringFileTest StringFileTest)
  239. ADD_TEST_MACRO(TryCompile TryCompile)
  240. ADD_TEST_MACRO(SystemInformation SystemInformation)
  241. ADD_TEST_MACRO(MathTest MathTest)
  242. ADD_TEST_MACRO(CompileFeatures CompileFeatures)
  243. ADD_TEST_MACRO(CMakeCommands.target_compile_features target_compile_features)
  244. if(CMake_TEST_RESOURCES)
  245. ADD_TEST_MACRO(VSResource VSResource)
  246. if (CMAKE_GENERATOR MATCHES "Ninja")
  247. add_test_macro(VSResourceNinjaForceRSP VSResourceNinjaForceRSP)
  248. endif ()
  249. endif()
  250. ADD_TEST_MACRO(MSManifest MSManifest)
  251. ADD_TEST_MACRO(Simple Simple)
  252. ADD_TEST_MACRO(PreOrder PreOrder)
  253. ADD_TEST_MACRO(MissingSourceFile MissingSourceFile)
  254. set_tests_properties(MissingSourceFile PROPERTIES
  255. PASS_REGULAR_EXPRESSION "CMake Error at CMakeLists.txt:3 \\(add_executable\\):[ \r\n]*Cannot find source file:[ \r\n]*DoesNotExist/MissingSourceFile.c")
  256. if(CMake_TEST_XCODE_VERSION AND CMAKE_OSX_SDKVERSION AND CMAKE_OSX_SDKPRODUCT)
  257. if((NOT CMake_TEST_XCODE_VERSION VERSION_LESS 6.1) AND
  258. ((NOT CMAKE_OSX_SDKPRODUCT STREQUAL "Mac OS X") OR
  259. (NOT CMAKE_OSX_SDKVERSION VERSION_LESS 10.10)))
  260. if(CMAKE_GENERATOR STREQUAL "Xcode")
  261. ADD_TEST_MACRO(SwiftMix SwiftMix)
  262. ADD_TEST_MACRO(SwiftOnly SwiftOnly)
  263. endif()
  264. endif()
  265. endif()
  266. if(CMAKE_Fortran_COMPILER)
  267. ADD_TEST_MACRO(FortranOnly FortranOnly)
  268. endif()
  269. # test Visual Studio GNU Fortran mixing with cmake_add_fortran_subdirectory
  270. # run this project if we have a working fortran compiler or
  271. # the test is enabled with CMAKE_TEST_CMAKE_ADD_FORTRAN cache variable.
  272. # If you enable the test, CMake should find the MinGW fortran install,
  273. # or in some cases you might need to set the PATH so that cmake can find
  274. # the gfortran from mingw.
  275. if(CMAKE_Fortran_COMPILER OR CMAKE_TEST_CMAKE_ADD_FORTRAN)
  276. set(CMAKE_SKIP_VSGNUFortran FALSE)
  277. # disable test for apple builds using ifort if they are building
  278. # more than one architecture, as ifort does not support that.
  279. if(APPLE AND (CMAKE_Fortran_COMPILER MATCHES ifort))
  280. list(LENGTH CMAKE_OSX_ARCHITECTURES len)
  281. if("${len}" GREATER 1)
  282. message(STATUS "Skip VSGNUFortran for ifort dual cpu mac build")
  283. set(CMAKE_SKIP_VSGNUFortran TRUE)
  284. endif()
  285. endif()
  286. if((CMAKE_C_COMPILER MATCHES lsb)
  287. AND (CMAKE_Fortran_COMPILER MATCHES ifort))
  288. message(STATUS "Skip VSGNUFortran for ifort and lsb compilers")
  289. set(CMAKE_SKIP_VSGNUFortran TRUE)
  290. endif()
  291. if(NOT CMAKE_SKIP_VSGNUFortran)
  292. ADD_TEST_MACRO(VSGNUFortran ${CMAKE_COMMAND} -P runtest.cmake)
  293. endif()
  294. endif()
  295. if(${CMAKE_GENERATOR} MATCHES "Visual Studio ([^89]|[89][0-9])")
  296. ADD_TEST_MACRO(CSharpOnly CSharpOnly)
  297. endif()
  298. ADD_TEST_MACRO(COnly COnly)
  299. ADD_TEST_MACRO(CxxOnly CxxOnly)
  300. ADD_TEST_MACRO(CxxSubdirC CxxSubdirC)
  301. ADD_TEST_MACRO(IPO COnly/COnly)
  302. ADD_TEST_MACRO(OutDir runtime/OutDir)
  303. ADD_TEST_MACRO(ObjectLibrary UseCshared)
  304. ADD_TEST_MACRO(NewlineArgs NewlineArgs)
  305. ADD_TEST_MACRO(SetLang SetLang)
  306. ADD_TEST_MACRO(EmptyProperty EmptyProperty)
  307. ADD_TEST_MACRO(ExternalOBJ ExternalOBJ)
  308. if(NOT CMake_TEST_EXTERNAL_CMAKE)
  309. ADD_TEST_MACRO(LoadCommand LoadedCommand)
  310. endif()
  311. ADD_TEST_MACRO(LinkDirectory bin/LinkDirectory)
  312. ADD_TEST_MACRO(LinkLanguage LinkLanguage)
  313. ADD_TEST_MACRO(LinkLine LinkLine)
  314. ADD_TEST_MACRO(MacroTest miniMacroTest)
  315. ADD_TEST_MACRO(FunctionTest miniFunctionTest)
  316. ADD_TEST_MACRO(ReturnTest ReturnTest)
  317. ADD_TEST_MACRO(Properties Properties)
  318. ADD_TEST_MACRO(Assembler HelloAsm)
  319. ADD_TEST_MACRO(SourceGroups SourceGroups)
  320. ADD_TEST_MACRO(Preprocess Preprocess)
  321. set(ExportImport_BUILD_OPTIONS -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM})
  322. ADD_TEST_MACRO(ExportImport ExportImport)
  323. ADD_TEST_MACRO(Unset Unset)
  324. ADD_TEST_MACRO(PolicyScope PolicyScope)
  325. ADD_TEST_MACRO(EmptyLibrary EmptyLibrary)
  326. ADD_TEST_MACRO(CompileDefinitions CompileDefinitions)
  327. ADD_TEST_MACRO(CompileOptions CompileOptions)
  328. ADD_TEST_MACRO(CompatibleInterface CompatibleInterface)
  329. ADD_TEST_MACRO(AliasTarget AliasTarget)
  330. ADD_TEST_MACRO(StagingPrefix StagingPrefix)
  331. ADD_TEST_MACRO(InterfaceLibrary InterfaceLibrary)
  332. if (CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]")
  333. set(ConfigSources_BUILD_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
  334. ADD_TEST_MACRO(ConfigSources ConfigSources)
  335. endif()
  336. ADD_TEST_MACRO(SourcesProperty SourcesProperty)
  337. ADD_TEST_MACRO(SourceFileProperty SourceFileProperty)
  338. if(CMAKE_CXX_COMPILER_ID STREQUAL GNU
  339. AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
  340. set(runCxxDialectTest 1)
  341. endif()
  342. if(CMAKE_CXX_COMPILER_ID STREQUAL Clang
  343. AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4)
  344. if(NOT APPLE OR POLICY CMP0025)
  345. set(runCxxDialectTest 1)
  346. endif()
  347. endif()
  348. if(runCxxDialectTest)
  349. ADD_TEST_MACRO(CxxDialect CxxDialect)
  350. endif()
  351. set_tests_properties(EmptyLibrary PROPERTIES
  352. PASS_REGULAR_EXPRESSION "CMake Error: CMake can not determine linker language for target: test")
  353. ADD_TEST_MACRO(CrossCompile CrossCompile)
  354. set_tests_properties(CrossCompile PROPERTIES
  355. PASS_REGULAR_EXPRESSION "TRY_RUN.. invoked in cross-compiling mode")
  356. if("${CMAKE_GENERATOR}" MATCHES "Make")
  357. ADD_TEST_MACRO(Policy0002 Policy0002)
  358. endif()
  359. if(CTEST_TEST_OSX_ARCH)
  360. ADD_TEST_MACRO(Architecture Architecture)
  361. set_tests_properties(Architecture PROPERTIES
  362. PASS_REGULAR_EXPRESSION "(file is not of required architecture|does not match cputype|not the architecture being linked)")
  363. endif()
  364. list(APPEND TEST_BUILD_DIRS ${CMake_TEST_INSTALL_PREFIX})
  365. if(NOT QT4_FOUND)
  366. find_package(Qt4 QUIET)
  367. endif()
  368. if(QT4_FOUND)
  369. # test whether the Qt4 which has been found works, on some machines
  370. # which run nightly builds there were errors like "wrong file format"
  371. # for libQtCore.so. So first check it works, and only if it does add
  372. # the automoc test.
  373. include(CheckCXXSourceCompiles)
  374. set(_save_CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES}")
  375. set(_save_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
  376. set(CMAKE_REQUIRED_INCLUDES ${QT_INCLUDES})
  377. set(CMAKE_REQUIRED_LIBRARIES ${QT_QTCORE_LIBRARIES})
  378. CHECK_CXX_SOURCE_COMPILES("#include <QCoreApplication>\n int main() {return (qApp == 0 ? 0 : 1); }\n"
  379. QT4_WORKS)
  380. set(CMAKE_REQUIRED_INCLUDES "${_save_CMAKE_REQUIRED_INCLUDES}")
  381. set(CMAKE_REQUIRED_LIBRARIES "${_save_CMAKE_REQUIRED_LIBRARIES}")
  382. endif()
  383. # run test for BundleUtilities on supported platforms/compilers
  384. if(MSVC OR
  385. MINGW OR
  386. CMAKE_SYSTEM_NAME MATCHES "Linux" OR
  387. CMAKE_SYSTEM_NAME MATCHES "Darwin")
  388. if(NOT "${CMAKE_GENERATOR}" STREQUAL "Watcom WMake")
  389. add_test(BundleUtilities ${CMAKE_CTEST_COMMAND}
  390. --build-and-test
  391. "${CMake_SOURCE_DIR}/Tests/BundleUtilities"
  392. "${CMake_BINARY_DIR}/Tests/BundleUtilities"
  393. ${build_generator_args}
  394. --build-project BundleUtilities
  395. --build-options ${build_options}
  396. )
  397. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BundleUtilities")
  398. # run test for DeployQt4 on supported platforms/compilers (which depends on BundleUtilities)
  399. # this test also depends on the existence of the standard qtiff plugin
  400. if(QT4_WORKS AND QT_QTSQL_FOUND)
  401. add_test(Qt4Deploy ${CMAKE_CTEST_COMMAND}
  402. --build-and-test
  403. "${CMake_SOURCE_DIR}/Tests/Qt4Deploy"
  404. "${CMake_BINARY_DIR}/Tests/Qt4Deploy"
  405. ${build_generator_args}
  406. --build-project Qt4Deploy
  407. --build-options ${build_options}
  408. -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
  409. -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}
  410. )
  411. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4Deploy")
  412. endif()
  413. endif()
  414. endif()
  415. set(CMAKE_BUILD_TEST_SOURCE_DIR "${CMake_SOURCE_DIR}/Tests/COnly")
  416. set(CMAKE_BUILD_TEST_BINARY_DIR "${CMake_BINARY_DIR}/Tests/CMakeBuildCOnly")
  417. set(CMAKE_BUILD_TEST_EXE COnly)
  418. configure_file("${CMake_SOURCE_DIR}/Tests/CMakeBuildTest.cmake.in"
  419. "${CMake_BINARY_DIR}/Tests/CMakeBuildTest.cmake" @ONLY)
  420. add_test(CMakeBuildTest ${CMAKE_CMAKE_COMMAND} -P
  421. "${CMake_BINARY_DIR}/Tests/CMakeBuildTest.cmake")
  422. list(APPEND TEST_BUILD_DIRS ${CMAKE_BUILD_TEST_BINARY_DIR})
  423. # now do it again for a project that has two project commands
  424. set(CMAKE_BUILD_TEST_SOURCE_DIR "${CMake_SOURCE_DIR}/Tests/DoubleProject")
  425. set(CMAKE_BUILD_TEST_BINARY_DIR "${CMake_BINARY_DIR}/Tests/DoubleProject")
  426. set(CMAKE_BUILD_TEST_EXE just_silly)
  427. configure_file("${CMake_SOURCE_DIR}/Tests/CMakeBuildTest.cmake.in"
  428. "${CMake_BINARY_DIR}/Tests/CMakeBuildDoubleProjectTest.cmake" @ONLY)
  429. add_test(CMakeDoubleProject ${CMAKE_CMAKE_COMMAND} -P
  430. "${CMake_BINARY_DIR}/Tests/CMakeBuildDoubleProjectTest.cmake")
  431. list(APPEND TEST_BUILD_DIRS ${CMAKE_BUILD_TEST_BINARY_DIR})
  432. ADD_TEST_MACRO(Module.CheckTypeSize CheckTypeSize)
  433. set(Module.CheckIPOSupported-C_BUILD_OPTIONS -DCMake_TEST_IPO_WORKS_C=${CMake_TEST_IPO_WORKS_C})
  434. ADD_TEST_MACRO(Module.CheckIPOSupported-C CheckIPOSupported-C)
  435. set(Module.CheckIPOSupported-CXX_BUILD_OPTIONS -DCMake_TEST_IPO_WORKS_CXX=${CMake_TEST_IPO_WORKS_CXX})
  436. ADD_TEST_MACRO(Module.CheckIPOSupported-CXX CheckIPOSupported-CXX)
  437. if(CMAKE_Fortran_COMPILER)
  438. set(Module.CheckIPOSupported-Fortran_BUILD_OPTIONS -DCMake_TEST_IPO_WORKS_Fortran=${CMake_TEST_IPO_WORKS_Fortran})
  439. ADD_TEST_MACRO(Module.CheckIPOSupported-Fortran CheckIPOSupported-Fortran)
  440. endif()
  441. add_test(Module.ExternalData ${CMAKE_CTEST_COMMAND}
  442. --build-and-test
  443. "${CMake_SOURCE_DIR}/Tests/Module/ExternalData"
  444. "${CMake_BINARY_DIR}/Tests/Module/ExternalData"
  445. ${build_generator_args}
  446. --build-project ExternalDataTest
  447. --build-noclean
  448. --force-new-ctest-process
  449. --build-options ${build_options}
  450. -DMAKE_SUPPORTS_SPACES=${MAKE_SUPPORTS_SPACES}
  451. --test-command ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE} -V
  452. )
  453. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Module/ExternalData")
  454. ADD_TEST_MACRO(Module.FindDependency FindDependency)
  455. ADD_TEST_MACRO(Module.WriteCompilerDetectionHeader WriteCompilerDetectionHeader)
  456. if (APPLE OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
  457. include(CheckCXXCompilerFlag)
  458. check_cxx_compiler_flag(-fPIE run_pic_test)
  459. else()
  460. if (CMAKE_CXX_COMPILER_ID MATCHES "PGI"
  461. OR CMAKE_CXX_COMPILER_ID MATCHES "PathScale"
  462. OR CMAKE_SYSTEM_NAME MATCHES "IRIX64"
  463. OR CMAKE_CXX_COMPILER_ID MATCHES "Intel")
  464. set(run_pic_test 0)
  465. else()
  466. set(run_pic_test 1)
  467. endif()
  468. endif()
  469. if (run_pic_test)
  470. ADD_TEST_MACRO(PositionIndependentTargets PositionIndependentTargets)
  471. endif()
  472. if((CMAKE_CXX_COMPILER_ID MATCHES "GNU") AND
  473. (NOT "${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 4.2) AND
  474. (CMAKE_SYSTEM_NAME MATCHES "Linux"))
  475. include(CheckCXXCompilerFlag)
  476. check_cxx_compiler_flag(
  477. -fvisibility-inlines-hidden run_inlines_hidden_test)
  478. endif()
  479. if(run_inlines_hidden_test)
  480. add_test(Visibility ${CMAKE_CTEST_COMMAND}
  481. --build-and-test
  482. "${CMake_SOURCE_DIR}/Tests/Visibility"
  483. "${CMake_BINARY_DIR}/Tests/Visibility"
  484. ${build_generator_args}
  485. --build-project Visibility
  486. --build-options ${build_options}
  487. )
  488. list(APPEND TEST_BUILD_DIRS
  489. "${CMake_BINARY_DIR}/Tests/Visibility"
  490. )
  491. endif()
  492. add_test(LinkFlags-prepare
  493. ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE}
  494. --build-and-test
  495. "${CMake_SOURCE_DIR}/Tests/LinkFlags"
  496. "${CMake_BINARY_DIR}/Tests/LinkFlags"
  497. ${build_generator_args}
  498. --build-project LinkFlags
  499. --build-target LinkFlags
  500. --build-options ${build_options}
  501. -DTEST_CONFIG=\${CTEST_CONFIGURATION_TYPE}
  502. )
  503. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LinkFlags")
  504. macro(ADD_LINK_FLAGS_TEST name depends)
  505. add_test(LinkFlags-${name}
  506. ${CMAKE_CMAKE_COMMAND} --build "${CMake_BINARY_DIR}/Tests/LinkFlags"
  507. --target LinkFlags_${name} --config \${CTEST_CONFIGURATION_TYPE}
  508. )
  509. set_tests_properties(LinkFlags-${name} PROPERTIES
  510. PASS_REGULAR_EXPRESSION "BADFLAG" DEPENDS LinkFlags-${depends})
  511. endmacro()
  512. ADD_LINK_FLAGS_TEST(lib prepare)
  513. ADD_LINK_FLAGS_TEST(dll lib)
  514. ADD_LINK_FLAGS_TEST(mod dll)
  515. ADD_LINK_FLAGS_TEST(exe mod)
  516. ADD_LINK_FLAGS_TEST(lib_config exe)
  517. ADD_LINK_FLAGS_TEST(dll_config lib_config)
  518. ADD_LINK_FLAGS_TEST(mod_config dll_config)
  519. ADD_LINK_FLAGS_TEST(exe_config mod_config)
  520. ADD_LINK_FLAGS_TEST(lib_flags exe_config)
  521. ADD_LINK_FLAGS_TEST(dll_flags lib_flags)
  522. ADD_LINK_FLAGS_TEST(mod_flags dll_flags)
  523. ADD_LINK_FLAGS_TEST(exe_flags mod_flags)
  524. ADD_LINK_FLAGS_TEST(lib_flags_config exe_flags)
  525. ADD_LINK_FLAGS_TEST(dll_flags_config lib_flags_config)
  526. ADD_LINK_FLAGS_TEST(mod_flags_config dll_flags_config)
  527. ADD_LINK_FLAGS_TEST(exe_flags_config mod_flags_config)
  528. # If we are running right now with a Unix Makefiles or Ninja based generator,
  529. # build the "Simple" test with the ExtraGenerators, if available
  530. # This doesn't test whether the generated project files work (unfortunately),
  531. # mainly it tests that cmake doesn't crash when generating these project files.
  532. if(${CMAKE_GENERATOR} MATCHES "Unix Makefiles" OR ${CMAKE_GENERATOR} MATCHES "Ninja")
  533. # check which generators we have
  534. execute_process(COMMAND ${CMAKE_CMAKE_COMMAND} --help
  535. OUTPUT_VARIABLE cmakeOutput ERROR_VARIABLE cmakeOutput)
  536. set(extraGenerators
  537. "CodeBlocks"
  538. "CodeLite"
  539. "Eclipse CDT4"
  540. "Kate"
  541. "KDevelop3"
  542. "Sublime Text 2")
  543. foreach(extraGenerator ${extraGenerators})
  544. if ("${cmakeOutput}" MATCHES "${extraGenerator} - ${CMAKE_GENERATOR}")
  545. set(extraGeneratorTestName "Simple_${extraGenerator}Generator")
  546. string(REPLACE " " "" extraGeneratorTestName ${extraGeneratorTestName})
  547. add_test(${extraGeneratorTestName} ${CMAKE_CTEST_COMMAND}
  548. --build-and-test
  549. "${CMake_SOURCE_DIR}/Tests/Simple"
  550. "${CMake_BINARY_DIR}/Tests/${extraGeneratorTestName}"
  551. --build-two-config
  552. --build-generator "${extraGenerator} - ${CMAKE_GENERATOR}"
  553. --build-generator-platform "${CMAKE_GENERATOR_PLATFORM}"
  554. --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
  555. --build-project Simple
  556. --build-options ${build_options}
  557. --test-command Simple)
  558. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${extraGeneratorTestName}")
  559. endif ()
  560. endforeach(extraGenerator)
  561. endif()
  562. # test for correct sub-project generation
  563. # not implemented in Xcode or Ninja
  564. if(NOT CMAKE_GENERATOR MATCHES "Xcode|Ninja")
  565. # run cmake and configure all of SubProject
  566. # but only build the independent executable car
  567. add_test(SubProject ${CMAKE_CTEST_COMMAND}
  568. --build-and-test
  569. "${CMake_SOURCE_DIR}/Tests/SubProject"
  570. "${CMake_BINARY_DIR}/Tests/SubProject"
  571. --build-project SubProject
  572. ${build_generator_args}
  573. --build-target car
  574. --build-options ${build_options}
  575. --test-command car
  576. )
  577. # For stage 2, do not run cmake again.
  578. # Then build the foo sub project which should build
  579. # the bar library which should be referenced because
  580. # foo links to the static library bar, but bar is not
  581. # directly in the foo sub project
  582. if(CMake_TEST_EXPLICIT_MAKE_PROGRAM)
  583. set(SubProject-Stage2_BUILD_MAKEPROGRAM
  584. --build-makeprogram ${CMake_TEST_EXPLICIT_MAKE_PROGRAM}
  585. )
  586. endif()
  587. add_test(SubProject-Stage2 ${CMAKE_CTEST_COMMAND}
  588. --build-and-test
  589. "${CMake_SOURCE_DIR}/Tests/SubProject/foo"
  590. "${CMake_BINARY_DIR}/Tests/SubProject/foo"
  591. --build-generator ${CMAKE_GENERATOR}
  592. --build-generator-platform "${CMAKE_GENERATOR_PLATFORM}"
  593. --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
  594. ${SubProject-Stage2_BUILD_MAKEPROGRAM}
  595. --build-nocmake
  596. --build-project foo
  597. --build-target foo
  598. --build-exe-dir "${CMake_BINARY_DIR}/Tests/SubProject/foo"
  599. --build-options ${build_options}
  600. --test-command foo
  601. )
  602. set_tests_properties ( SubProject-Stage2 PROPERTIES DEPENDS SubProject)
  603. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SubProject")
  604. endif()
  605. # macro to add a test that will build a nightly release
  606. # of CMake for given platform using the release scripts
  607. macro(ADD_NIGHTLY_BUILD_TEST name script)
  608. set(_TEST_DIR "${CMake_BINARY_DIR}/Tests/${name}")
  609. file(MAKE_DIRECTORY "${_TEST_DIR}")
  610. file(WRITE "${_TEST_DIR}/nightly-cmake.sh"
  611. "cd ${_TEST_DIR}
  612. ${CMake_BINARY_DIR}/bin/cmake -DCMAKE_CREATE_VERSION=nightly -P ${CMake_SOURCE_DIR}/Utilities/Release/${script}
  613. ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release/upload_release.cmake
  614. ")
  615. add_test(${name} /bin/sh ${_TEST_DIR}/nightly-cmake.sh)
  616. if(COMMAND SET_TESTS_PROPERTIES AND COMMAND GET_TEST_PROPERTY)
  617. set_tests_properties (${name} PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT})
  618. endif()
  619. endmacro()
  620. if(CMAKE_BUILD_NIGHTLY_RELEASES)
  621. ADD_NIGHTLY_BUILD_TEST(CMakeNightlyWin32
  622. win32_release.cmake)
  623. ADD_NIGHTLY_BUILD_TEST(CMakeNightlyWin64
  624. win64_release.cmake)
  625. ADD_NIGHTLY_BUILD_TEST(CMakeNightlyOSX
  626. osx_release.cmake)
  627. ADD_NIGHTLY_BUILD_TEST(CMakeNightlyLinux64
  628. linux64_release.cmake)
  629. set_property(TEST CMakeNightlyWin64 PROPERTY DEPENDS CMakeNightlyWin32)
  630. endif()
  631. # add tests with more complex invocations
  632. add_test(Framework ${CMAKE_CTEST_COMMAND}
  633. --build-and-test
  634. "${CMake_SOURCE_DIR}/Tests/Framework"
  635. "${CMake_BINARY_DIR}/Tests/Framework"
  636. --build-two-config
  637. ${build_generator_args}
  638. --build-project Framework
  639. --build-options ${build_options}
  640. "-DCMAKE_INSTALL_PREFIX:PATH=${CMake_BINARY_DIR}/Tests/Framework/Install"
  641. --test-command bar)
  642. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Framework")
  643. add_test(TargetName ${CMAKE_CTEST_COMMAND}
  644. --build-and-test
  645. "${CMake_SOURCE_DIR}/Tests/TargetName"
  646. "${CMake_BINARY_DIR}/Tests/TargetName"
  647. --build-two-config
  648. ${build_generator_args}
  649. --build-project TargetName
  650. --build-options ${build_options}
  651. --test-command ${CMAKE_CMAKE_COMMAND} -E compare_files
  652. ${CMake_SOURCE_DIR}/Tests/TargetName/scripts/hello_world
  653. ${CMake_BINARY_DIR}/Tests/TargetName/scripts/hello_world)
  654. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/TargetName")
  655. add_test(LibName ${CMAKE_CTEST_COMMAND}
  656. --build-and-test
  657. "${CMake_SOURCE_DIR}/Tests/LibName"
  658. "${CMake_BINARY_DIR}/Tests/LibName"
  659. --build-two-config
  660. ${build_generator_args}
  661. --build-project LibName
  662. --build-exe-dir "${CMake_BINARY_DIR}/Tests/LibName/lib"
  663. --build-options ${build_options}
  664. --test-command foobar
  665. )
  666. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LibName")
  667. add_test(CustComDepend ${CMAKE_CTEST_COMMAND}
  668. --build-and-test
  669. "${CMake_SOURCE_DIR}/Tests/CustComDepend"
  670. "${CMake_BINARY_DIR}/Tests/CustComDepend"
  671. --build-two-config
  672. ${build_generator_args}
  673. --build-project CustComDepend
  674. --build-exe-dir "${CMake_BINARY_DIR}/Tests/CustComDepend/bin"
  675. --build-options ${build_options}
  676. --test-command foo bar.c
  677. )
  678. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CustComDepend")
  679. add_test(ArgumentExpansion ${CMAKE_CTEST_COMMAND}
  680. --build-and-test
  681. "${CMake_SOURCE_DIR}/Tests/ArgumentExpansion"
  682. "${CMake_BINARY_DIR}/Tests/ArgumentExpansion"
  683. ${build_generator_args}
  684. --build-project ArgumentExpansion
  685. --build-exe-dir "${CMake_BINARY_DIR}/Tests/ArgumentExpansion/bin"
  686. --build-options ${build_options}
  687. )
  688. set_tests_properties(ArgumentExpansion PROPERTIES
  689. FAIL_REGULAR_EXPRESSION "Unexpected: ")
  690. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ArgumentExpansion")
  691. add_test(GeneratorExpression
  692. ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE}
  693. --build-and-test
  694. "${CMake_SOURCE_DIR}/Tests/GeneratorExpression"
  695. "${CMake_BINARY_DIR}/Tests/GeneratorExpression"
  696. ${build_generator_args}
  697. --build-project GeneratorExpression
  698. --build-options ${build_options}
  699. -DCMAKE_BUILD_TYPE=\${CTEST_CONFIGURATION_TYPE}
  700. --test-command ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE} -V
  701. )
  702. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/GeneratorExpression")
  703. add_test(CustomCommand ${CMAKE_CTEST_COMMAND}
  704. --build-and-test
  705. "${CMake_SOURCE_DIR}/Tests/CustomCommand"
  706. "${CMake_BINARY_DIR}/Tests/CustomCommand"
  707. --build-two-config
  708. ${build_generator_args}
  709. --build-project CustomCommand
  710. --build-exe-dir "${CMake_BINARY_DIR}/Tests/CustomCommand/bin"
  711. --build-options ${build_options}
  712. --test-command CustomCommand
  713. )
  714. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CustomCommand")
  715. ADD_TEST_MACRO(CustomCommandByproducts CustomCommandByproducts)
  716. ADD_TEST_MACRO(EmptyDepends ${CMAKE_CTEST_COMMAND})
  717. add_test(CustomCommandWorkingDirectory ${CMAKE_CTEST_COMMAND}
  718. --build-and-test
  719. "${CMake_SOURCE_DIR}/Tests/CustomCommandWorkingDirectory"
  720. "${CMake_BINARY_DIR}/Tests/CustomCommandWorkingDirectory"
  721. --build-two-config
  722. ${build_generator_args}
  723. --build-project TestWorkingDir
  724. --build-options ${build_options}
  725. --test-command working
  726. )
  727. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CustomCommandWorkingDirectory")
  728. #add_test(SimpleExclude ${CMAKE_CTEST_COMMAND}
  729. # --build-and-test
  730. # "${CMake_SOURCE_DIR}/Tests/SimpleExclude"
  731. # "${CMake_BINARY_DIR}/Tests/SimpleExclude"
  732. # ${build_generator_args}
  733. # --build-project SimpleExclude
  734. # --build-two-config
  735. # --build-options ${build_options}
  736. # --test-command t4
  737. #--test-command "${CMAKE_COMMAND}"
  738. #"-DCONFIGURATION=\${CTEST_CONFIGURATION_TYPE}"
  739. #-P "${CMake_BINARY_DIR}/Tests/SimpleExclude/run.cmake"
  740. #)
  741. # add_test(SameName ${CMAKE_CTEST_COMMAND}
  742. # --build-and-test
  743. # "${CMake_SOURCE_DIR}/Tests/SameName"
  744. # "${CMake_BINARY_DIR}/Tests/SameName"
  745. # ${build_generator_args}
  746. # --build-project SameName
  747. # --build-two-config
  748. # --build-options ${build_options}
  749. # --test-command
  750. # "${CMake_BINARY_DIR}/Tests/SameName/Exe1/mytest2")
  751. add_test(OutOfSource ${CMAKE_CTEST_COMMAND}
  752. --build-and-test
  753. "${CMake_SOURCE_DIR}/Tests/OutOfSource"
  754. "${CMake_BINARY_DIR}/Tests/OutOfSource"
  755. ${build_generator_args}
  756. --build-project OutOfSource
  757. --build-two-config
  758. --build-options ${build_options}
  759. --test-command
  760. "${CMake_BINARY_DIR}/Tests/OutOfSource/SubDir/OutOfSourceSubdir/simple")
  761. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/OutOfSource")
  762. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/OutOfSourceDeep")
  763. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/OutOfBinary")
  764. add_test(BuildDepends ${CMAKE_CTEST_COMMAND}
  765. --build-and-test
  766. "${CMake_SOURCE_DIR}/Tests/BuildDepends"
  767. "${CMake_BINARY_DIR}/Tests/BuildDepends"
  768. ${build_generator_args}
  769. --build-project BuildDepends
  770. --build-options ${build_options}
  771. )
  772. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BuildDepends")
  773. set(SimpleInstallInstallDir
  774. "${CMake_BINARY_DIR}/Tests/SimpleInstall/InstallDirectory")
  775. add_test(SimpleInstall ${CMAKE_CTEST_COMMAND}
  776. --build-and-test
  777. "${CMake_SOURCE_DIR}/Tests/SimpleInstall"
  778. "${CMake_BINARY_DIR}/Tests/SimpleInstall"
  779. ${build_generator_args}
  780. --build-project TestSimpleInstall
  781. --build-two-config
  782. --build-options ${build_options}
  783. "-DCMAKE_INSTALL_PREFIX:PATH=${SimpleInstallInstallDir}"
  784. "-DCTEST_TEST_CPACK:BOOL=${CTEST_TEST_CPACK}"
  785. --test-command ${SimpleInstallInstallDir}/MyTest/bin/SimpleInstExe)
  786. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SimpleInstall")
  787. add_test(SimpleInstall-Stage2 ${CMAKE_CTEST_COMMAND}
  788. --build-and-test
  789. "${CMake_SOURCE_DIR}/Tests/SimpleInstallS2"
  790. "${CMake_BINARY_DIR}/Tests/SimpleInstallS2"
  791. ${build_generator_args}
  792. --build-project TestSimpleInstall
  793. --build-two-config
  794. --build-options ${build_options}
  795. "-DCMAKE_INSTALL_PREFIX:PATH=${SimpleInstallInstallDir}"
  796. "-DSTAGE2:BOOL=1"
  797. --test-command ${SimpleInstallInstallDir}/MyTest/bin/SimpleInstExeS2)
  798. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SimpleInstallS2")
  799. set(MissingInstallInstallDir
  800. "${CMake_BINARY_DIR}/Tests/MissingInstall/InstallDirectory")
  801. add_test(MissingInstall ${CMAKE_CTEST_COMMAND}
  802. --build-and-test
  803. "${CMake_SOURCE_DIR}/Tests/MissingInstall"
  804. "${CMake_BINARY_DIR}/Tests/MissingInstall"
  805. ${build_generator_args}
  806. --build-project TestMissingInstall
  807. --build-two-config
  808. --build-options ${build_options}
  809. "-DCMAKE_INSTALL_PREFIX:PATH=${MissingInstallInstallDir}")
  810. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/MissingInstall")
  811. # By default, run the CPackComponents test if the CTEST_TEST_CPACK
  812. # option is ON:
  813. #
  814. set(CTEST_RUN_CPackComponents ${CTEST_TEST_CPACK})
  815. set(CTEST_package_X11_TEST ${CTEST_TEST_CPACK})
  816. set(CTEST_RUN_CPackComponentsForAll ${CTEST_TEST_CPACK})
  817. set(CTEST_RUN_CPackComponentsPrefix ${CTEST_TEST_CPACK})
  818. find_program(NSIS_MAKENSIS_EXECUTABLE NAMES makensis
  819. PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS]
  820. DOC "makensis program location"
  821. )
  822. # But on Windows, only run the CPackComponents test if the NSIS
  823. # installer builder is available:
  824. #
  825. if(WIN32)
  826. if(NSIS_MAKENSIS_EXECUTABLE)
  827. set(CTEST_RUN_CPackComponents ON)
  828. else()
  829. set(CTEST_RUN_CPackComponents OFF)
  830. set(CTEST_package_X11_TEST OFF)
  831. endif()
  832. endif()
  833. # On Windows run the CPackWiXGenerator test
  834. # if the WiX Toolset seems to be available
  835. if(WIN32)
  836. file(TO_CMAKE_PATH "$ENV{WIX}" WIX_ROOT)
  837. find_program(WIX_LIGHT_EXECUTABLE light
  838. PATHS "${WIX_ROOT}/bin"
  839. DOC "WiX Toolset light.exe location")
  840. if(WIX_LIGHT_EXECUTABLE)
  841. add_test(CPackWiXGenerator ${CMAKE_CTEST_COMMAND}
  842. -C \${CTEST_CONFIGURATION_TYPE}
  843. --build-and-test
  844. "${CMake_SOURCE_DIR}/Tests/CPackWiXGenerator"
  845. "${CMake_BINARY_DIR}/Tests/CPackWiXGenerator"
  846. ${build_generator_args}
  847. --build-project CPackWiXGenerator
  848. --build-options ${build_options}
  849. --test-command ${CMAKE_CMAKE_COMMAND}
  850. "-DCPackWiXGenerator_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/CPackWiXGenerator"
  851. "-Dconfig=\${CTEST_CONFIGURATION_TYPE}"
  852. -P "${CMake_SOURCE_DIR}/Tests/CPackWiXGenerator/RunCPackVerifyResult.cmake")
  853. set_property(TEST CPackWiXGenerator PROPERTY
  854. ATTACHED_FILES_ON_FAIL
  855. "${CMake_BINARY_DIR}/Tests/CPackWiXGenerator/_CPack_Packages/win32/WIX/wix.log")
  856. endif()
  857. endif()
  858. if(CTEST_RUN_CPackComponents)
  859. set(CPackComponents_BUILD_OPTIONS)
  860. if(APPLE)
  861. set(CPackComponents_BUILD_OPTIONS -DCPACK_BINARY_DRAGNDROP:BOOL=ON)
  862. if(CMake_TEST_XCODE_VERSION VERSION_GREATER "4.6")
  863. set(CPackComponents_BUILD_OPTIONS ${CPackComponents_BUILD_OPTIONS}
  864. -DCPACK_BINARY_PRODUCTBUILD:BOOL=ON)
  865. endif()
  866. endif()
  867. if(NSIS_MAKENSIS_EXECUTABLE)
  868. set(CPackComponents_BUILD_OPTIONS ${CPackComponents_BUILD_OPTIONS}
  869. -DCPACK_BINARY_NSIS:BOOL=ON)
  870. endif()
  871. add_test(CPackComponents ${CMAKE_CTEST_COMMAND}
  872. --build-and-test
  873. "${CMake_SOURCE_DIR}/Tests/CPackComponents"
  874. "${CMake_BINARY_DIR}/Tests/CPackComponents"
  875. ${build_generator_args}
  876. --build-project CPackComponents
  877. --build-two-config
  878. --build-target package
  879. --build-options ${build_options}
  880. -DCPACK_BINARY_DEB:BOOL=${CPACK_BINARY_DEB}
  881. -DCPACK_BINARY_RPM:BOOL=${CPACK_BINARY_RPM}
  882. ${CPackComponents_BUILD_OPTIONS}
  883. --graphviz=CPackComponents.dot
  884. --test-command ${CMAKE_CMAKE_COMMAND}
  885. "-DCPackComponents_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/CPackComponents"
  886. -P "${CMake_SOURCE_DIR}/Tests/CPackComponents/VerifyResult.cmake")
  887. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CPackComponents")
  888. endif()
  889. if(CTEST_RUN_CPackComponentsForAll)
  890. # Check whether if rpmbuild command is found
  891. # before adding RPM tests
  892. if(CPACK_BINARY_RPM)
  893. list(APPEND ACTIVE_CPACK_GENERATORS RPM)
  894. endif()
  895. # Check whether if dpkg command is found
  896. # before adding DEB tests
  897. if(CPACK_BINARY_DEB)
  898. list(APPEND ACTIVE_CPACK_GENERATORS DEB)
  899. endif()
  900. # ACTIVE_CPACK_GENERATORS variable
  901. # now contains the list of 'active generators'
  902. set(CPackComponentsForAll_BUILD_OPTIONS)
  903. # set up list of CPack generators
  904. list(APPEND ACTIVE_CPACK_GENERATORS "ZIP")
  905. if(APPLE)
  906. list(APPEND ACTIVE_CPACK_GENERATORS "DragNDrop")
  907. if(CMake_TEST_XCODE_VERSION VERSION_GREATER "4.6")
  908. list(APPEND ACTIVE_CPACK_GENERATORS "productbuild")
  909. endif()
  910. endif()
  911. # set up list of component packaging ways
  912. list(APPEND CWAYLST "default")
  913. list(APPEND CWAYLST "OnePackPerGroup")
  914. list(APPEND CWAYLST "IgnoreGroup")
  915. list(APPEND CWAYLST "AllInOne")
  916. foreach(CPackGen IN LISTS ACTIVE_CPACK_GENERATORS)
  917. set(CPackRun_CPackGen "-DCPackGen=${CPackGen}")
  918. foreach(CPackComponentWay ${CWAYLST})
  919. set(CPackRun_CPackComponentWay "-DCPackComponentWay=${CPackComponentWay}")
  920. add_test(CPackComponentsForAll-${CPackGen}-${CPackComponentWay}
  921. ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE}
  922. --build-and-test
  923. "${CMake_SOURCE_DIR}/Tests/CPackComponentsForAll"
  924. "${CMake_BINARY_DIR}/Tests/CPackComponentsForAll/build${CPackGen}-${CPackComponentWay}"
  925. ${build_generator_args}
  926. --build-project CPackComponentsForAll
  927. --build-options ${build_options}
  928. -DCPACK_GENERATOR:STRING=${CPackGen}
  929. -DCPACK_BINARY_${CPackGen}:BOOL=ON
  930. ${CPackRun_CPackComponentWay}
  931. ${CPackComponentsForAll_BUILD_OPTIONS}
  932. --graphviz=CPackComponentsForAll.dot
  933. --test-command ${CMAKE_CMAKE_COMMAND}
  934. "-DCPackComponentsForAll_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/CPackComponentsForAll/build${CPackGen}-${CPackComponentWay}"
  935. "${CPackRun_CPackGen}"
  936. "${CPackRun_CPackComponentWay}"
  937. -P "${CMake_SOURCE_DIR}/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake")
  938. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CPackComponentsForAll/build${CPackGen}-${CPackComponentWay}")
  939. endforeach()
  940. endforeach()
  941. # debian specific
  942. if(DPKG_EXECUTABLE)
  943. unset(CPackRun_CPackDEBConfiguration_ALL_CONFIGS)
  944. set(DEB_TEST_NAMES "CPackComponentsDEB")
  945. set(DEB_CONFIGURATIONS_TO_TEST "components-lintian-dpkgdeb-checks"
  946. "components-description1"
  947. "components-description2"
  948. "components-source"
  949. "components-shlibdeps1"
  950. "components-depend1"
  951. "components-depend2"
  952. "compression")
  953. set(CPackGen "DEB")
  954. set(CPackRun_CPackGen "-DCPackGen=${CPackGen}")
  955. foreach(CPackDEBConfiguration IN LISTS DEB_CONFIGURATIONS_TO_TEST)
  956. set(CPackRun_CPackDEBConfiguration "-DCPackDEBConfiguration=${CPackDEBConfiguration}")
  957. add_test(${DEB_TEST_NAMES}-${CPackDEBConfiguration}
  958. ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE}
  959. --build-and-test
  960. "${CMake_SOURCE_DIR}/Tests/${DEB_TEST_NAMES}"
  961. "${CMake_BINARY_DIR}/Tests/${DEB_TEST_NAMES}/build${CPackGen}-${CPackDEBConfiguration}"
  962. ${build_generator_args}
  963. --build-project CPackComponentsDEB
  964. --build-options ${build_options}
  965. -DCPACK_GENERATOR:STRING=${CPackGen}
  966. -DCPACK_BINARY_${CPackGen}:BOOL=ON
  967. ${CPackRun_CPackDEBConfiguration}
  968. ${CPackRun_CPackDEBConfiguration_ALL_CONFIGS}
  969. --graphviz=${DEB_TEST_NAMES}.dot
  970. --test-command ${CMAKE_CMAKE_COMMAND}
  971. "-D${DEB_TEST_NAMES}_SOURCE_DIR:PATH=${CMake_SOURCE_DIR}/Tests/${DEB_TEST_NAMES}"
  972. "-D${DEB_TEST_NAMES}_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/${DEB_TEST_NAMES}/build${CPackGen}-${CPackDEBConfiguration}"
  973. "${CPackRun_CPackGen}"
  974. "${CPackRun_CPackDEBConfiguration}"
  975. -P "${CMake_SOURCE_DIR}/Tests/${DEB_TEST_NAMES}/RunCPackVerifyResult-${CPackDEBConfiguration}.cmake")
  976. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${DEB_TEST_NAMES}/build${CPackGen}-${CPackDEBConfiguration}")
  977. endforeach()
  978. endif()
  979. endif()
  980. # By default, turn this test off (because it takes a long time...)
  981. #
  982. if(NOT DEFINED CTEST_RUN_CPackTestAllGenerators)
  983. set(CTEST_RUN_CPackTestAllGenerators OFF)
  984. # ...but: if it appears to be a coverage dashboard, or long tests are
  985. # on, then set it to the generic CTEST_TEST_CPACK setting.
  986. #
  987. if(CMAKE_CXX_FLAGS MATCHES "-ftest-coverage" OR
  988. NOT "$ENV{COVFILE}" STREQUAL "" OR
  989. CMAKE_RUN_LONG_TESTS)
  990. set(CTEST_RUN_CPackTestAllGenerators ${CTEST_TEST_CPACK})
  991. endif()
  992. endif()
  993. if(CTEST_RUN_CPackTestAllGenerators)
  994. add_test(CPackTestAllGenerators ${CMAKE_CTEST_COMMAND}
  995. --build-and-test
  996. "${CMake_SOURCE_DIR}/Tests/CPackTestAllGenerators"
  997. "${CMake_BINARY_DIR}/Tests/CPackTestAllGenerators"
  998. ${build_generator_args}
  999. --build-project CPackTestAllGenerators
  1000. --build-options ${build_options}
  1001. --test-command
  1002. ${CMAKE_CMAKE_COMMAND}
  1003. -D dir=${CMake_BINARY_DIR}/Tests/CPackTestAllGenerators
  1004. -P ${CMake_SOURCE_DIR}/Tests/CPackTestAllGenerators/RunCPack.cmake
  1005. )
  1006. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CPackTestAllGenerators")
  1007. endif()
  1008. if(CTEST_RUN_CPackComponentsPrefix)
  1009. set(CPackComponents_BUILD_OPTIONS)
  1010. if(APPLE)
  1011. set(CPackComponents_BUILD_OPTIONS -DCPACK_BINARY_DRAGNDROP:BOOL=ON)
  1012. if(CMake_TEST_XCODE_VERSION VERSION_GREATER "4.6")
  1013. set(CPackComponents_BUILD_OPTIONS ${CPackComponents_BUILD_OPTIONS}
  1014. -DCPACK_BINARY_PRODUCTBUILD:BOOL=ON)
  1015. endif()
  1016. endif()
  1017. if(NOT NSIS_MAKENSIS_EXECUTABLE)
  1018. set(CPackComponents_BUILD_OPTIONS ${CPackComponents_BUILD_OPTIONS}
  1019. -DCPACK_BINARY_NSIS:BOOL=OFF)
  1020. endif()
  1021. add_test(CPackComponentsPrefix ${CMAKE_CTEST_COMMAND}
  1022. --build-and-test
  1023. "${CMake_SOURCE_DIR}/Tests/CPackComponentsPrefix"
  1024. "${CMake_BINARY_DIR}/Tests/CPackComponentsPrefix"
  1025. ${build_generator_args}
  1026. --build-project CPackComponentsPrefix
  1027. --build-two-config
  1028. --build-target package
  1029. --build-options ${build_options}
  1030. -DCPACK_BINARY_DEB:BOOL=${CPACK_BINARY_DEB}
  1031. -DCPACK_BINARY_RPM:BOOL=${CPACK_BINARY_RPM}
  1032. -DCPACK_BINARY_ZIP:BOOL=ON
  1033. ${CPackComponents_BUILD_OPTIONS}
  1034. )
  1035. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CPackComponentsPrefix")
  1036. endif()
  1037. if(CTEST_package_X11_TEST)
  1038. set(X11_build_target_arg --build-target package)
  1039. else()
  1040. set(X11_build_target_arg)
  1041. endif()
  1042. add_test(X11 ${CMAKE_CTEST_COMMAND}
  1043. --build-and-test
  1044. "${CMake_SOURCE_DIR}/Tests/X11"
  1045. "${CMake_BINARY_DIR}/Tests/X11"
  1046. ${build_generator_args}
  1047. --build-project UseX11
  1048. --build-two-config
  1049. ${X11_build_target_arg}
  1050. --build-options ${build_options}
  1051. --test-command UseX11)
  1052. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/X11")
  1053. if(NOT DEFINED CTEST_RUN_CMakeTestAllGenerators)
  1054. set(CTEST_RUN_CMakeTestAllGenerators ON)
  1055. endif()
  1056. if(CTEST_RUN_CMakeTestAllGenerators)
  1057. add_test(CMakeTestAllGenerators ${CMAKE_CMAKE_COMMAND}
  1058. -D dir=${CMake_BINARY_DIR}/Tests/CMakeTestAllGenerators
  1059. -D CMake_SOURCE_DIR=${CMake_SOURCE_DIR}
  1060. -P ${CMake_SOURCE_DIR}/Tests/CMakeTestAllGenerators/RunCMake.cmake
  1061. )
  1062. list(APPEND TEST_BUILD_DIRS
  1063. "${CMake_BINARY_DIR}/Tests/CMakeTestAllGenerators")
  1064. # This test runs a lot of processes. Do not make them compete
  1065. # for resources with other tests.
  1066. set_property(TEST CMakeTestAllGenerators PROPERTY RUN_SERIAL 1)
  1067. endif()
  1068. if(NOT DEFINED CTEST_RUN_CMakeTestMultipleConfigures)
  1069. set(CTEST_RUN_CMakeTestMultipleConfigures ON)
  1070. endif()
  1071. if(CTEST_RUN_CMakeTestMultipleConfigures)
  1072. add_test(CMakeTestMultipleConfigures ${CMAKE_CMAKE_COMMAND}
  1073. -D dir=${CMake_BINARY_DIR}/Tests/CMakeTestMultipleConfigures
  1074. -D gen=${CMAKE_GENERATOR}
  1075. -D CMake_SOURCE_DIR=${CMake_SOURCE_DIR}
  1076. -P ${CMake_SOURCE_DIR}/Tests/CMakeTestMultipleConfigures/RunCMake.cmake
  1077. )
  1078. list(APPEND TEST_BUILD_DIRS
  1079. "${CMake_BINARY_DIR}/Tests/CMakeTestMultipleConfigures")
  1080. endif()
  1081. if(NOT CMake_TEST_EXTERNAL_CMAKE)
  1082. add_test(LoadedCommandOneConfig ${CMAKE_CTEST_COMMAND}
  1083. --build-and-test
  1084. "${CMake_SOURCE_DIR}/Tests/LoadCommandOneConfig"
  1085. "${CMake_BINARY_DIR}/Tests/LoadCommandOneConfig"
  1086. ${build_generator_args}
  1087. --build-project LoadCommand
  1088. --build-options ${build_options}
  1089. --test-command LoadedCommand
  1090. )
  1091. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LoadCommandOneConfig")
  1092. endif()
  1093. add_test(complex ${CMAKE_CTEST_COMMAND}
  1094. --build-and-test
  1095. "${CMake_SOURCE_DIR}/Tests/Complex"
  1096. "${CMake_BINARY_DIR}/Tests/Complex"
  1097. --build-two-config
  1098. --build-config-sample "${CMAKE_CTEST_COMMAND}"
  1099. ${build_generator_args}
  1100. --build-project Complex
  1101. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Complex/bin"
  1102. --build-options ${build_options}
  1103. -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
  1104. --test-command complex
  1105. )
  1106. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Complex")
  1107. add_test(complexOneConfig ${CMAKE_CTEST_COMMAND}
  1108. --build-and-test
  1109. "${CMake_SOURCE_DIR}/Tests/ComplexOneConfig"
  1110. "${CMake_BINARY_DIR}/Tests/ComplexOneConfig"
  1111. ${build_generator_args}
  1112. --build-project Complex
  1113. --build-exe-dir "${CMake_BINARY_DIR}/Tests/ComplexOneConfig/bin"
  1114. --build-options ${build_options}
  1115. -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
  1116. --test-command complex)
  1117. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ComplexOneConfig")
  1118. # because of the registry write these tests depend on each other
  1119. set_tests_properties ( complex PROPERTIES DEPENDS complexOneConfig)
  1120. add_test(Environment ${CMAKE_CTEST_COMMAND}
  1121. --build-and-test
  1122. "${CMake_SOURCE_DIR}/Tests/Environment"
  1123. "${CMake_BINARY_DIR}/Tests/Environment"
  1124. ${build_generator_args}
  1125. --build-project EnvironmentProj
  1126. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Environment"
  1127. --force-new-ctest-process
  1128. --build-options ${build_options}
  1129. --test-command ${CMAKE_CTEST_COMMAND} -V
  1130. )
  1131. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Environment")
  1132. add_test(QtAutomocNoQt ${CMAKE_CTEST_COMMAND}
  1133. --build-and-test
  1134. "${CMake_SOURCE_DIR}/Tests/QtAutomocNoQt"
  1135. "${CMake_BINARY_DIR}/Tests/QtAutomocNoQt"
  1136. ${build_generator_args}
  1137. --build-project QtAutomocNoQt
  1138. --build-options ${build_options}
  1139. -DCMAKE_BUILD_TYPE=\${CTEST_CONFIGURATION_TYPE}
  1140. )
  1141. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/QtAutomocNoQt")
  1142. # On Windows there is no RPATH, so while Qt might be available for building,
  1143. # the required dlls may not be in the PATH, so we can't run the executables
  1144. # on that platform.
  1145. if(WIN32)
  1146. set(run_autogen_test ${CMAKE_CTEST_COMMAND} -V)
  1147. set(run_autouic_test ${CMAKE_CTEST_COMMAND} -V)
  1148. else()
  1149. set(run_autogen_test complex/QtAutogen)
  1150. set(run_autouic_test QtAutoUicInterface)
  1151. endif()
  1152. if(NOT CMAKE_CONFIGURATION_TYPES)
  1153. set(QtAutogen_BUILD_OPTIONS -DCMAKE_BUILD_TYPE=$<CONFIGURATION>)
  1154. endif()
  1155. find_package(Qt5Widgets QUIET NO_MODULE)
  1156. if(Qt5Widgets_FOUND)
  1157. add_test(NAME Qt5Autogen COMMAND ${CMAKE_CTEST_COMMAND}
  1158. --build-and-test
  1159. "${CMake_SOURCE_DIR}/Tests/QtAutogen"
  1160. "${CMake_BINARY_DIR}/Tests/Qt5Autogen"
  1161. ${build_generator_args}
  1162. --build-project QtAutogen
  1163. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt5Autogen"
  1164. --force-new-ctest-process
  1165. --build-options ${build_options}
  1166. -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DQT_TEST_VERSION=5
  1167. ${QtAutogen_BUILD_OPTIONS}
  1168. --test-command ${run_autogen_test}
  1169. )
  1170. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt5Autogen")
  1171. add_test(Qt5AutoUicInterface ${CMAKE_CTEST_COMMAND}
  1172. --build-and-test
  1173. "${CMake_SOURCE_DIR}/Tests/QtAutoUicInterface"
  1174. "${CMake_BINARY_DIR}/Tests/Qt5AutoUicInterface"
  1175. ${build_generator_args}
  1176. --build-project QtAutoUicInterface
  1177. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt5AutoUicInterface"
  1178. --force-new-ctest-process
  1179. --build-options ${build_options}
  1180. -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DQT_TEST_VERSION=5
  1181. --test-command ${run_autouic_test}
  1182. )
  1183. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt5AutoUicInterface")
  1184. endif()
  1185. if(QT4_WORKS AND QT_QTGUI_FOUND)
  1186. add_test(NAME Qt4Autogen COMMAND ${CMAKE_CTEST_COMMAND}
  1187. --build-and-test
  1188. "${CMake_SOURCE_DIR}/Tests/QtAutogen"
  1189. "${CMake_BINARY_DIR}/Tests/Qt4Autogen"
  1190. ${build_generator_args}
  1191. --build-project QtAutogen
  1192. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4Autogen"
  1193. --force-new-ctest-process
  1194. --build-options ${build_options}
  1195. -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DQT_TEST_VERSION=4
  1196. ${QtAutogen_BUILD_OPTIONS}
  1197. --test-command ${run_autogen_test}
  1198. )
  1199. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4Autogen")
  1200. add_test(Qt4AutoUicInterface ${CMAKE_CTEST_COMMAND}
  1201. --build-and-test
  1202. "${CMake_SOURCE_DIR}/Tests/QtAutoUicInterface"
  1203. "${CMake_BINARY_DIR}/Tests/Qt4AutoUicInterface"
  1204. ${build_generator_args}
  1205. --build-project QtAutoUicInterface
  1206. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4AutoUicInterface"
  1207. --force-new-ctest-process
  1208. --build-options ${build_options}
  1209. -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DQT_TEST_VERSION=4
  1210. --test-command ${run_autouic_test}
  1211. )
  1212. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4AutoUicInterface")
  1213. add_test(Qt4Targets ${CMAKE_CTEST_COMMAND}
  1214. --build-and-test
  1215. "${CMake_SOURCE_DIR}/Tests/Qt4Targets"
  1216. "${CMake_BINARY_DIR}/Tests/Qt4Targets"
  1217. ${build_generator_args}
  1218. --build-project Qt4Targets
  1219. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4Targets"
  1220. --force-new-ctest-process
  1221. --build-options ${build_options}
  1222. -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}
  1223. --test-command ${CMAKE_CTEST_COMMAND} -V
  1224. )
  1225. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4Targets")
  1226. if(Qt5Widgets_FOUND AND NOT Qt5Widgets_VERSION VERSION_LESS 5.1.0)
  1227. add_test(Qt4And5Automoc ${CMAKE_CTEST_COMMAND}
  1228. --build-and-test
  1229. "${CMake_SOURCE_DIR}/Tests/Qt4And5Automoc"
  1230. "${CMake_BINARY_DIR}/Tests/Qt4And5Automoc"
  1231. ${build_generator_args}
  1232. --build-project Qt4And5Automoc
  1233. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4And5Automoc"
  1234. --force-new-ctest-process
  1235. --build-options ${build_options}
  1236. --test-command ${CMAKE_CTEST_COMMAND} -V
  1237. )
  1238. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4And5Automoc")
  1239. add_test(Qt4And5AutomocReverse ${CMAKE_CTEST_COMMAND}
  1240. --build-and-test
  1241. "${CMake_SOURCE_DIR}/Tests/Qt4And5Automoc"
  1242. "${CMake_BINARY_DIR}/Tests/Qt4And5AutomocReverse"
  1243. ${build_generator_args}
  1244. --build-project Qt4And5Automoc
  1245. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4And5AutomocReverse"
  1246. --force-new-ctest-process
  1247. --build-options ${build_options} -DQT_REVERSE_FIND_ORDER=1
  1248. --test-command ${CMAKE_CTEST_COMMAND} -V
  1249. )
  1250. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4And5AutomocReverse")
  1251. endif()
  1252. endif()
  1253. if(CMake_TEST_CUDA)
  1254. add_subdirectory(Cuda)
  1255. add_subdirectory(CudaOnly)
  1256. endif()
  1257. if(CMake_TEST_FindBoost)
  1258. add_subdirectory(FindBoost)
  1259. endif()
  1260. if(CMake_TEST_FindBZip2)
  1261. add_subdirectory(FindBZip2)
  1262. endif()
  1263. if(CMake_TEST_FindGSL)
  1264. add_subdirectory(FindGSL)
  1265. endif()
  1266. if(CMake_TEST_FindGTest)
  1267. add_subdirectory(FindGTest)
  1268. endif()
  1269. if(CMake_TEST_FindICU)
  1270. add_subdirectory(FindICU)
  1271. endif()
  1272. if(CMake_TEST_FindJsonCpp)
  1273. add_subdirectory(FindJsonCpp)
  1274. endif()
  1275. if(CMake_TEST_FindLibRHash)
  1276. add_subdirectory(FindLibRHash)
  1277. endif()
  1278. if(CMake_TEST_FindLibUV)
  1279. add_subdirectory(FindLibUV)
  1280. endif()
  1281. if(CMake_TEST_FindLTTngUST)
  1282. add_subdirectory(FindLTTngUST)
  1283. endif()
  1284. if(CMake_TEST_FindOpenCL)
  1285. add_subdirectory(FindOpenCL)
  1286. endif()
  1287. if(CMake_TEST_FindOpenGL)
  1288. add_subdirectory(FindOpenGL)
  1289. endif()
  1290. if(CMake_TEST_FindOpenSSL)
  1291. add_subdirectory(FindOpenSSL)
  1292. endif()
  1293. if(CMake_TEST_FindMPI)
  1294. add_subdirectory(FindMPI)
  1295. endif()
  1296. if(CMake_TEST_FindPNG)
  1297. add_subdirectory(FindPNG)
  1298. endif()
  1299. if(CMake_TEST_FindTIFF)
  1300. add_subdirectory(FindTIFF)
  1301. endif()
  1302. if(CMake_TEST_FindVulkan)
  1303. add_subdirectory(FindVulkan)
  1304. endif()
  1305. if(CMake_TEST_FindXalanC)
  1306. add_subdirectory(FindXalanC)
  1307. endif()
  1308. if(CMake_TEST_FindXercesC)
  1309. add_subdirectory(FindXercesC)
  1310. endif()
  1311. add_subdirectory(FindThreads)
  1312. # Matlab module
  1313. if(CMake_TEST_FindMatlab)
  1314. ADD_TEST_MACRO(FindMatlab.basic_checks ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>)
  1315. ADD_TEST_MACRO(FindMatlab.versions_checks ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>)
  1316. ADD_TEST_MACRO(FindMatlab.components_checks ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>)
  1317. endif()
  1318. find_package(GTK2 QUIET)
  1319. if(GTK2_FOUND)
  1320. add_subdirectory(FindGTK2)
  1321. endif()
  1322. add_test(ExternalProject ${CMAKE_CTEST_COMMAND}
  1323. --build-and-test
  1324. "${CMake_SOURCE_DIR}/Tests/ExternalProject"
  1325. "${CMake_BINARY_DIR}/Tests/ExternalProject"
  1326. ${build_generator_args}
  1327. --build-project ExternalProjectTest
  1328. --build-exe-dir "${CMake_BINARY_DIR}/Tests/ExternalProject"
  1329. --force-new-ctest-process
  1330. --build-options ${build_options}
  1331. --test-command ${CMAKE_CTEST_COMMAND} -V
  1332. )
  1333. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProject")
  1334. set_tests_properties(ExternalProject PROPERTIES
  1335. TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT})
  1336. add_test(NAME ExternalProjectSubdir
  1337. COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
  1338. --build-and-test
  1339. "${CMake_SOURCE_DIR}/Tests/ExternalProjectSubdir"
  1340. "${CMake_BINARY_DIR}/Tests/ExternalProjectSubdir"
  1341. ${build_generator_args}
  1342. --build-project ExternalProjectSubdir
  1343. --force-new-ctest-process
  1344. --build-options ${build_options}
  1345. )
  1346. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProjectSubdir")
  1347. add_test(NAME ExternalProjectSourceSubdir
  1348. COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
  1349. --build-and-test
  1350. "${CMake_SOURCE_DIR}/Tests/ExternalProjectSourceSubdir"
  1351. "${CMake_BINARY_DIR}/Tests/ExternalProjectSourceSubdir"
  1352. ${build_generator_args}
  1353. --build-project ExternalProjectSourceSubdir
  1354. --force-new-ctest-process
  1355. --build-options ${build_options}
  1356. )
  1357. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProjectSourceSubdir")
  1358. add_test(ExternalProjectLocal ${CMAKE_CTEST_COMMAND}
  1359. --build-and-test
  1360. "${CMake_SOURCE_DIR}/Tests/ExternalProjectLocal"
  1361. "${CMake_BINARY_DIR}/Tests/ExternalProjectLocal"
  1362. ${build_generator_args}
  1363. --build-project ExternalProjectLocalTest
  1364. --build-exe-dir "${CMake_BINARY_DIR}/Tests/ExternalProjectLocal"
  1365. --force-new-ctest-process
  1366. --build-options ${build_options}
  1367. --test-command ${CMAKE_CTEST_COMMAND} -V
  1368. )
  1369. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProjectLocal")
  1370. set_tests_properties(ExternalProjectLocal PROPERTIES
  1371. TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT})
  1372. add_test(ExternalProjectUpdateSetup ${CMAKE_CTEST_COMMAND}
  1373. --build-and-test
  1374. "${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate"
  1375. "${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate"
  1376. ${build_generator_args}
  1377. --build-project ExternalProjectUpdateTest
  1378. --build-exe-dir "${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate"
  1379. --force-new-ctest-process
  1380. --build-options ${build_options}
  1381. --test-command ${CMAKE_CTEST_COMMAND} -V
  1382. )
  1383. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate")
  1384. set_tests_properties(ExternalProjectUpdateSetup PROPERTIES
  1385. TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT})
  1386. add_test(NAME ExternalProjectUpdate
  1387. COMMAND ${CMAKE_CMAKE_COMMAND}
  1388. -DExternalProjectUpdate_SOURCE_DIR:PATH=${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate
  1389. -DExternalProjectUpdate_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate
  1390. -DCMAKE_GENERATOR=${CMAKE_GENERATOR}
  1391. -DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
  1392. -DCMAKE_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET}
  1393. -DCMAKE_CTEST_COMMAND=${CMAKE_CTEST_COMMAND}
  1394. -P ${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake
  1395. )
  1396. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate")
  1397. set_tests_properties(ExternalProjectUpdate PROPERTIES
  1398. TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}
  1399. WORKING_DIRECTORY ${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate
  1400. DEPENDS ExternalProjectUpdateSetup )
  1401. # do each of the tutorial steps
  1402. foreach(STP RANGE 1 7)
  1403. add_test(TutorialStep${STP} ${CMAKE_CTEST_COMMAND}
  1404. --build-and-test
  1405. "${CMake_SOURCE_DIR}/Tests/Tutorial/Step${STP}"
  1406. "${CMake_BINARY_DIR}/Tests/Tutorial/Step${STP}"
  1407. --build-two-config
  1408. ${build_generator_args}
  1409. --build-project Tutorial
  1410. --build-options ${build_options}
  1411. --test-command Tutorial 25.0)
  1412. endforeach()
  1413. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Tutorial")
  1414. add_test(testing ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE}
  1415. --build-and-test
  1416. "${CMake_SOURCE_DIR}/Tests/Testing"
  1417. "${CMake_BINARY_DIR}/Tests/Testing"
  1418. ${build_generator_args}
  1419. --build-project Testing
  1420. --build-options ${build_options}
  1421. --test-command ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE}
  1422. )
  1423. set_tests_properties(testing PROPERTIES PASS_REGULAR_EXPRESSION "Passed")
  1424. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Testing")
  1425. add_test(wrapping ${CMAKE_CTEST_COMMAND}
  1426. --build-and-test
  1427. "${CMake_SOURCE_DIR}/Tests/Wrapping"
  1428. "${CMake_BINARY_DIR}/Tests/Wrapping"
  1429. ${build_generator_args}
  1430. --build-project Wrapping
  1431. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin"
  1432. --build-options ${build_options}
  1433. --test-command wrapping
  1434. )
  1435. add_test(qtwrapping ${CMAKE_CTEST_COMMAND}
  1436. --build-and-test
  1437. "${CMake_SOURCE_DIR}/Tests/Wrapping"
  1438. "${CMake_BINARY_DIR}/Tests/Wrapping"
  1439. ${build_generator_args}
  1440. --build-project Wrapping
  1441. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin"
  1442. --build-options ${build_options}
  1443. --test-command qtwrapping
  1444. )
  1445. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Wrapping")
  1446. add_test(testdriver1 ${CMAKE_CTEST_COMMAND}
  1447. --build-and-test
  1448. "${CMake_SOURCE_DIR}/Tests/TestDriver"
  1449. "${CMake_BINARY_DIR}/Tests/TestDriver"
  1450. ${build_generator_args}
  1451. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin"
  1452. --build-project TestDriverTest
  1453. --build-options ${build_options}
  1454. --test-command TestDriverTest test1
  1455. )
  1456. add_test(testdriver2 ${CMAKE_CTEST_COMMAND}
  1457. --build-and-test
  1458. "${CMake_SOURCE_DIR}/Tests/TestDriver"
  1459. "${CMake_BINARY_DIR}/Tests/TestDriver"
  1460. ${build_generator_args}
  1461. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin"
  1462. --build-project TestDriverTest
  1463. --build-options ${build_options}
  1464. --test-command TestDriverTest test2
  1465. )
  1466. add_test(testdriver3 ${CMAKE_CTEST_COMMAND}
  1467. --build-and-test
  1468. "${CMake_SOURCE_DIR}/Tests/TestDriver"
  1469. "${CMake_BINARY_DIR}/Tests/TestDriver"
  1470. ${build_generator_args}
  1471. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin"
  1472. --build-project TestDriverTest
  1473. --build-options ${build_options}
  1474. --test-command TestDriverTest subdir/test3
  1475. )
  1476. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/TestDriver")
  1477. add_test(Dependency ${CMAKE_CTEST_COMMAND}
  1478. --build-and-test
  1479. "${CMake_SOURCE_DIR}/Tests/Dependency"
  1480. "${CMake_BINARY_DIR}/Tests/Dependency"
  1481. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Dependency/Exec"
  1482. ${build_generator_args}
  1483. --build-project Dependency
  1484. --build-options ${build_options}
  1485. --test-command exec
  1486. )
  1487. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Dependency")
  1488. if(CMAKE_SYSTEM_NAME MATCHES syllable)
  1489. # RPATH isn't supported under Syllable, so the tests don't
  1490. # find their libraries. In order to fix that LIBRARY_OUTPUT_DIR
  1491. # in the tests would have to be adjusted to ${EXECUTABLE_OUTPUT_DIR}/lib .
  1492. # For now we just require on Syllable that the user adjusts the DLL_PATH
  1493. # environment variable, so except the two tests below all other tests will succeed.
  1494. set(_DLL_PATH "$ENV{DLL_PATH}")
  1495. if(NOT "${_DLL_PATH}" MATCHES "^(.*:)?\\@bindir\\@/\\.(:.*)?$")
  1496. 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")
  1497. endif()
  1498. if(NOT "${_DLL_PATH}" MATCHES "^(.*:)?\\@bindir\\@/\\.\\./lib(:.*)?$")
  1499. 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")
  1500. endif()
  1501. else()
  1502. add_test(JumpWithLibOut ${CMAKE_CTEST_COMMAND}
  1503. --build-and-test
  1504. "${CMake_SOURCE_DIR}/Tests/Jump"
  1505. "${CMake_BINARY_DIR}/Tests/Jump/WithLibOut"
  1506. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Jump/WithLibOut/Executable"
  1507. --build-project Jump
  1508. ${build_generator_args}
  1509. --build-options ${build_options}
  1510. -DLIBRARY_OUTPUT_PATH:PATH=${CMake_BINARY_DIR}/Tests/Jump/WithLibOut/Lib
  1511. --test-command jumpExecutable
  1512. )
  1513. add_test(JumpNoLibOut ${CMAKE_CTEST_COMMAND}
  1514. --build-and-test
  1515. "${CMake_SOURCE_DIR}/Tests/Jump"
  1516. "${CMake_BINARY_DIR}/Tests/Jump/NoLibOut"
  1517. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Jump/NoLibOut/Executable"
  1518. --build-run-dir "${CMake_BINARY_DIR}/Tests/Jump/NoLibOut/Executable"
  1519. --build-project Jump
  1520. ${build_generator_args}
  1521. --build-options ${build_options}
  1522. --test-command jumpExecutable
  1523. )
  1524. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Jump")
  1525. add_test(Plugin ${CMAKE_CTEST_COMMAND}
  1526. --build-and-test
  1527. "${CMake_SOURCE_DIR}/Tests/Plugin"
  1528. "${CMake_BINARY_DIR}/Tests/Plugin"
  1529. ${build_generator_args}
  1530. --build-project Plugin
  1531. --build-two-config
  1532. --build-options ${build_options}
  1533. --test-command bin/example)
  1534. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Plugin")
  1535. if(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG)
  1536. ADD_TEST_MACRO(RuntimePath RuntimePath)
  1537. endif()
  1538. endif()
  1539. if(APPLE AND "${DARWIN_MAJOR_VERSION}" GREATER 9)
  1540. add_test(MacRuntimePath ${CMAKE_CTEST_COMMAND}
  1541. --build-and-test
  1542. "${CMake_SOURCE_DIR}/Tests/MacRuntimePath"
  1543. "${CMake_BINARY_DIR}/Tests/MacRuntimePath"
  1544. ${build_generator_args}
  1545. --build-project MacRuntimePath
  1546. --build-options ${build_options}
  1547. -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM}
  1548. )
  1549. endif()
  1550. if(CMake_TEST_XCODE_VERSION AND NOT CMake_TEST_XCODE_VERSION VERSION_LESS 5
  1551. AND OSX_VERSION MATCHES "^([0-9]+\\.[0-9]+)")
  1552. set(XCTest_BUILD_OPTIONS -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_MATCH_1} -DCMAKE_OSX_SYSROOT=macosx)
  1553. ADD_TEST_MACRO(XCTest ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> -V)
  1554. endif()
  1555. add_test(linkorder1 ${CMAKE_CTEST_COMMAND}
  1556. --build-and-test
  1557. "${CMake_SOURCE_DIR}/Tests/LinkLineOrder"
  1558. "${CMake_BINARY_DIR}/Tests/LinkLineOrder"
  1559. ${build_generator_args}
  1560. --build-project LinkLineOrder
  1561. --build-options ${build_options}
  1562. --test-command Exec1
  1563. )
  1564. add_test(linkorder2 ${CMAKE_CTEST_COMMAND}
  1565. --build-and-test
  1566. "${CMake_SOURCE_DIR}/Tests/LinkLineOrder"
  1567. "${CMake_BINARY_DIR}/Tests/LinkLineOrder"
  1568. ${build_generator_args}
  1569. --build-project LinkLineOrder
  1570. --build-options ${build_options}
  1571. --test-command Exec2
  1572. )
  1573. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LinkLineOrder")
  1574. set_tests_properties ( qtwrapping PROPERTIES DEPENDS wrapping)
  1575. set_tests_properties ( testdriver1 PROPERTIES DEPENDS qtwrapping)
  1576. set_tests_properties ( testdriver2 PROPERTIES DEPENDS testdriver1)
  1577. set_tests_properties ( testdriver3 PROPERTIES DEPENDS testdriver2)
  1578. set_tests_properties ( linkorder2 PROPERTIES DEPENDS linkorder1)
  1579. set_tests_properties ( SimpleInstall-Stage2 PROPERTIES DEPENDS SimpleInstall)
  1580. # Test static linking on toolchains known to support it.
  1581. if(CMAKE_C_COMPILER_ID STREQUAL "GNU"
  1582. AND NOT APPLE AND NOT WIN32 AND NOT CYGWIN
  1583. AND EXISTS "/usr/lib/libm.a")
  1584. add_test(LinkStatic ${CMAKE_CTEST_COMMAND}
  1585. --build-and-test
  1586. "${CMake_SOURCE_DIR}/Tests/LinkStatic"
  1587. "${CMake_BINARY_DIR}/Tests/LinkStatic"
  1588. ${build_generator_args}
  1589. --build-project LinkStatic
  1590. --build-options ${build_options}
  1591. -DMATH_LIBRARY:FILEPATH=/usr/lib/libm.a
  1592. --test-command LinkStatic
  1593. )
  1594. endif()
  1595. if(MAKE_SUPPORTS_SPACES AND NOT CMAKE_GENERATOR STREQUAL "Xcode")
  1596. add_test(SubDirSpaces ${CMAKE_CTEST_COMMAND}
  1597. --build-and-test
  1598. "${CMake_SOURCE_DIR}/Tests/SubDirSpaces"
  1599. "${CMake_BINARY_DIR}/Tests/SubDirSpaces"
  1600. --build-exe-dir
  1601. "${CMake_BINARY_DIR}/Tests/SubDirSpaces/Executable Sources"
  1602. ${build_generator_args}
  1603. --build-project SUBDIR
  1604. --build-options ${build_options}
  1605. --test-command test
  1606. "${CMake_BINARY_DIR}/Tests/SubDirSpaces/ShouldBeHere"
  1607. "${CMake_BINARY_DIR}/Tests/SubDirSpaces/testfromsubdir.obj"
  1608. )
  1609. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SubDirSpaces")
  1610. endif ()
  1611. if (WIN32)
  1612. add_test(SubDir ${CMAKE_CTEST_COMMAND}
  1613. --build-and-test
  1614. "${CMake_SOURCE_DIR}/Tests/SubDir"
  1615. "${CMake_BINARY_DIR}/Tests/SubDir"
  1616. --build-exe-dir "${CMake_BINARY_DIR}/Tests/SubDir/Executable"
  1617. ${build_generator_args}
  1618. --build-project SUBDIR
  1619. --build-options ${build_options}
  1620. --test-command test
  1621. "${CMake_BINARY_DIR}/Tests/SubDir/ShouldBeHere"
  1622. "${CMake_BINARY_DIR}/Tests/SubDir/testfromsubdir.obj"
  1623. )
  1624. else ()
  1625. add_test(SubDir ${CMAKE_CTEST_COMMAND}
  1626. --build-and-test
  1627. "${CMake_SOURCE_DIR}/Tests/SubDir"
  1628. "${CMake_BINARY_DIR}/Tests/SubDir"
  1629. --build-exe-dir "${CMake_BINARY_DIR}/Tests/SubDir/Executable"
  1630. ${build_generator_args}
  1631. --build-project SUBDIR
  1632. --build-options ${build_options}
  1633. --test-command test
  1634. "${CMake_BINARY_DIR}/Tests/SubDir/ShouldBeHere"
  1635. "${CMake_BINARY_DIR}/Tests/SubDir/testfromsubdir.o"
  1636. )
  1637. endif ()
  1638. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SubDir")
  1639. if(MSVC)
  1640. ADD_TEST_MACRO(ForceInclude foo)
  1641. ADD_TEST_MACRO(PDBDirectoryAndName myexe)
  1642. if(NOT CMAKE_C_COMPILER_ID STREQUAL "Clang")
  1643. ADD_TEST_MACRO(PrecompiledHeader foo)
  1644. endif()
  1645. endif()
  1646. if(MSVC OR
  1647. "${CMAKE_GENERATOR}" MATCHES "(MSYS|MinGW) Makefiles")
  1648. ADD_TEST_MACRO(ModuleDefinition example_exe)
  1649. endif()
  1650. ADD_TEST_MACRO(CheckCompilerRelatedVariables CheckCompilerRelatedVariables)
  1651. if("${CMAKE_GENERATOR}" MATCHES "Makefile")
  1652. add_test(MakeClean ${CMAKE_CTEST_COMMAND}
  1653. --build-and-test
  1654. "${CMake_SOURCE_DIR}/Tests/MakeClean"
  1655. "${CMake_BINARY_DIR}/Tests/MakeClean"
  1656. ${build_generator_args}
  1657. --build-project MakeClean
  1658. --build-exe-dir "${CMake_BINARY_DIR}/MakeClean"
  1659. --build-options ${build_options}
  1660. --test-command check_clean
  1661. )
  1662. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/MakeClean")
  1663. endif()
  1664. if(NOT DEFINED CTEST_RUN_MFC)
  1665. set(CTEST_RUN_MFC OFF)
  1666. if(MSVC)
  1667. set(CTEST_RUN_MFC ON)
  1668. # Look for evidence that this is a VCExpress build. If so, avoid
  1669. # the MFC test by default.
  1670. string(TOLOWER "${CMAKE_MAKE_PROGRAM}" mkprog)
  1671. if(mkprog MATCHES "vcexpress")
  1672. message(STATUS
  1673. "CMAKE_MAKE_PROGRAM indicates vcexpress, avoiding MFC test")
  1674. set(CTEST_RUN_MFC OFF)
  1675. endif()
  1676. # Since MSBuild might also be the "makeprogram" for a VCExpress
  1677. # build tree, use one more heuristic, too. The string representing
  1678. # the .vcproj file type contains "VCExpress" on machines where an
  1679. # express edition of VS was installed last:
  1680. if(CTEST_RUN_MFC)
  1681. execute_process(COMMAND cmd /c assoc .vcproj
  1682. OUTPUT_STRIP_TRAILING_WHITESPACE
  1683. OUTPUT_VARIABLE ov)
  1684. if(ov MATCHES "VCExpress")
  1685. message(STATUS
  1686. ".vcproj file association indicates VCExpress, avoiding MFC test")
  1687. set(CTEST_RUN_MFC OFF)
  1688. endif()
  1689. endif()
  1690. # For the Watcom WMake generator, avoid the MFC test by default.
  1691. if(CTEST_RUN_MFC)
  1692. if("${CMAKE_GENERATOR}" MATCHES "WMake")
  1693. message(STATUS
  1694. "using the Watcom WMake generator, avoiding MFC test")
  1695. set(CTEST_RUN_MFC OFF)
  1696. endif()
  1697. endif()
  1698. # Last resort, after quick checks are done. Do a try_compile, and avoid
  1699. # the MFC test if the simplest possible MFC app cannot be compiled.
  1700. if(CTEST_RUN_MFC AND NOT DEFINED HAVE_MFC)
  1701. configure_file(
  1702. ${CMAKE_CURRENT_SOURCE_DIR}/MFC/try_compile/CMakeLists.txt
  1703. ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile/CMakeLists.txt
  1704. COPYONLY
  1705. )
  1706. configure_file(
  1707. ${CMAKE_CURRENT_SOURCE_DIR}/MFC/mfc1/stdafx.cpp
  1708. ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile/stdafx.cpp
  1709. COPYONLY
  1710. )
  1711. configure_file(
  1712. ${CMAKE_CURRENT_SOURCE_DIR}/MFC/mfc1/stdafx.h
  1713. ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile/stdafx.h
  1714. COPYONLY
  1715. )
  1716. message(STATUS "Looking for MFC")
  1717. try_compile(HAVE_MFC
  1718. ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile/build
  1719. ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile
  1720. try_compile_mfc
  1721. OUTPUT_VARIABLE HAVE_MFC_OUTPUT)
  1722. if(HAVE_MFC)
  1723. message(STATUS "Looking for MFC - found")
  1724. set(HAVE_MFC 1 CACHE INTERNAL "Have MFC")
  1725. file(APPEND
  1726. ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
  1727. "Determining if MFC exists passed with the following output:\n"
  1728. "${HAVE_MFC_OUTPUT}\n\n")
  1729. else()
  1730. message(STATUS "Looking for MFC - not found")
  1731. set(HAVE_MFC "" CACHE INTERNAL "Have MFC")
  1732. file(APPEND
  1733. ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
  1734. "Determining if MFC exists failed with the following output:\n"
  1735. "${HAVE_MFC_OUTPUT}\n\n")
  1736. endif()
  1737. endif()
  1738. if(CTEST_RUN_MFC AND NOT HAVE_MFC)
  1739. message(STATUS
  1740. "cannot compile simplest ever MFC app, avoiding MFC test")
  1741. set(CTEST_RUN_MFC OFF)
  1742. endif()
  1743. endif()
  1744. endif()
  1745. if(CTEST_RUN_MFC)
  1746. add_test(MFC ${CMAKE_CTEST_COMMAND}
  1747. --build-and-test
  1748. "${CMake_SOURCE_DIR}/Tests/MFC"
  1749. "${CMake_BINARY_DIR}/Tests/MFC"
  1750. --build-two-config
  1751. ${build_generator_args}
  1752. --build-project mfc_driver
  1753. --build-options ${build_options}
  1754. --test-command ${CMAKE_CTEST_COMMAND}
  1755. -C \${CTEST_CONFIGURATION_TYPE} -VV)
  1756. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/MFC")
  1757. endif()
  1758. if(MSVC AND NOT MSVC_VERSION LESS 1310
  1759. AND (NOT CMAKE_GENERATOR MATCHES "Visual Studio [89]( |$)"
  1760. OR CMAKE_SIZEOF_VOID_P EQUAL 4)
  1761. )
  1762. ADD_TEST_MACRO(VSMASM VSMASM)
  1763. endif()
  1764. if(${CMAKE_GENERATOR} MATCHES "Visual Studio")
  1765. if(NOT MSVC60)
  1766. ADD_TEST_MACRO(SBCS SBCS)
  1767. endif()
  1768. if(NOT "${CMAKE_GENERATOR}" MATCHES "Visual Studio [89]( |$)"
  1769. AND NOT CMAKE_GENERATOR_TOOLSET)
  1770. ADD_TEST_MACRO(VSWindowsFormsResx VSWindowsFormsResx)
  1771. endif()
  1772. add_test(VSExternalInclude ${CMAKE_CTEST_COMMAND}
  1773. --build-and-test
  1774. "${CMake_SOURCE_DIR}/Tests/VSExternalInclude"
  1775. "${CMake_BINARY_DIR}/Tests/VSExternalInclude"
  1776. --build-two-config
  1777. ${build_generator_args}
  1778. --build-project VSExternalInclude
  1779. --build-options ${build_options}
  1780. --test-command VSExternalInclude)
  1781. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSExternalInclude")
  1782. add_test(VSMidl ${CMAKE_CTEST_COMMAND}
  1783. --build-and-test
  1784. "${CMake_SOURCE_DIR}/Tests/VSMidl"
  1785. "${CMake_BINARY_DIR}/Tests/VSMidl"
  1786. --build-two-config
  1787. ${build_generator_args}
  1788. --build-project VSMidl
  1789. --build-options ${build_options}
  1790. --test-command VSMidl)
  1791. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSMidl")
  1792. if(CMake_TEST_DEVENV)
  1793. # The test (and tested property) works with .sln files, so it's skipped when:
  1794. # * cmake --build is set up to use MSBuild, since the MSBuild invocation does not use the .sln file
  1795. set(_last_test "")
  1796. foreach(config ${CMAKE_CONFIGURATION_TYPES})
  1797. add_test(NAME VSExcludeFromDefaultBuild-${config} COMMAND ${CMAKE_CTEST_COMMAND}
  1798. --build-and-test
  1799. "${CMake_SOURCE_DIR}/Tests/VSExcludeFromDefaultBuild"
  1800. "${CMake_BINARY_DIR}/Tests/VSExcludeFromDefaultBuild"
  1801. --build-config ${config}
  1802. --build-two-config
  1803. --build-generator ${CMAKE_GENERATOR}
  1804. --build-makeprogram ${CMake_TEST_DEVENV}
  1805. --build-generator-platform "${CMAKE_GENERATOR_PLATFORM}"
  1806. --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
  1807. --build-project VSExcludeFromDefaultBuild
  1808. --build-target install
  1809. --test-command ${CMAKE_COMMAND}
  1810. -D "activeConfig=${config}"
  1811. -D "allConfigs=${CMAKE_CONFIGURATION_TYPES}"
  1812. -D "dir=${CMake_BINARY_DIR}/Tests/VSExcludeFromDefaultBuild"
  1813. -P "${CMake_SOURCE_DIR}/Tests/VSExcludeFromDefaultBuild/ResultTest.cmake")
  1814. if(_last_test)
  1815. set_property(TEST VSExcludeFromDefaultBuild-${config} PROPERTY DEPENDS ${_last_test})
  1816. endif()
  1817. set(_last_test "VSExcludeFromDefaultBuild-${config}")
  1818. endforeach()
  1819. unset(_last_test)
  1820. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSExcludeFromDefaultBuild")
  1821. endif()
  1822. if(CMAKE_GENERATOR MATCHES "Visual Studio ([0-5]|[6-9][0-9])")
  1823. # This is Visual Studio 10 or above, so the default build tool is MSBuild.
  1824. add_test(NAME VSProjectInSubdir COMMAND ${CMAKE_CTEST_COMMAND}
  1825. --build-and-test
  1826. "${CMake_SOURCE_DIR}/Tests/VSProjectInSubdir"
  1827. "${CMake_BINARY_DIR}/Tests/VSProjectInSubdir"
  1828. --build-two-config
  1829. --build-generator ${CMAKE_GENERATOR}
  1830. --build-generator-platform "${CMAKE_GENERATOR_PLATFORM}"
  1831. --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
  1832. --build-project VSProjectInSubdir
  1833. --build-target test)
  1834. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSProjectInSubdir")
  1835. endif()
  1836. endif()
  1837. if(WIN32)
  1838. # Macro to search for available Windows CE SDKs in the windows Registry
  1839. macro(select_wince_sdk selected_reg selected_sdk)
  1840. if(CMAKE_HOST_WIN32)
  1841. execute_process(COMMAND reg QUERY "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows CE Tools\\SDKs"
  1842. OUTPUT_VARIABLE sdk_reg
  1843. ERROR_VARIABLE my_err)
  1844. string(REGEX REPLACE "HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Wow6432Node\\\\Microsoft\\\\Windows CE Tools\\\\SDKs\\\\" ";" sdk_list "${sdk_reg}")
  1845. list(LENGTH sdk_list sdk_list_len)
  1846. if (${sdk_list_len} GREATER 1)
  1847. list(GET sdk_list 1 _sdk) # The first entry is always empty due to the regex replace above
  1848. string(STRIP ${_sdk} _sdk) # Make sure there is no newline in the SDK name
  1849. endif()
  1850. # Build a key to be used by get_filename_component that is pointing to the SDK directory
  1851. set(_reg "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows CE Tools\\SDKs\\${_sdk}]")
  1852. # Set return values
  1853. set(${selected_reg} ${_reg})
  1854. set(${selected_sdk} ${_sdk})
  1855. endif(CMAKE_HOST_WIN32)
  1856. endmacro(select_wince_sdk)
  1857. set(reg_vs10 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0;InstallDir]")
  1858. set(reg_vs11 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0;InstallDir]")
  1859. set(reg_vs12 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\12.0;InstallDir]")
  1860. set(reg_vs14 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot10]")
  1861. set(reg_ws80 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.0;InstallationFolder]")
  1862. set(reg_ws81 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.1;InstallationFolder]")
  1863. set(reg_ws10_0 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\14.0\\Setup\\Build Tools for Windows 10;srcPath]")
  1864. set(reg_wp80 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\WindowsPhone\\v8.0;InstallationFolder]")
  1865. set(reg_wp81 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\WindowsPhone\\v8.1;InstallationFolder]")
  1866. select_wince_sdk(reg_wince wince_sdk)
  1867. set(reg_tegra "[HKEY_LOCAL_MACHINE\\SOFTWARE\\NVIDIA Corporation\\Nsight Tegra;sdkRoot]")
  1868. set(reg_nasm "[HKEY_CURRENT_USER\\SOFTWARE\\nasm]")
  1869. foreach(reg vs10 vs11 vs12 vs14 ws80 ws81 ws10_0 wp80 wp81 wince tegra nasm)
  1870. get_filename_component(r "${reg_${reg}}" ABSOLUTE)
  1871. if(IS_DIRECTORY "${r}")
  1872. set(${reg} 1)
  1873. else()
  1874. set(${reg} 0)
  1875. endif()
  1876. endforeach()
  1877. endif()
  1878. get_filename_component(ntver "[HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion;CurrentVersion]" NAME)
  1879. if(WIN32 AND ntver VERSION_GREATER 6.1) # Windows >= 8.0
  1880. macro(add_test_VSWinStorePhone name generator systemName systemVersion)
  1881. add_test(NAME VSWinStorePhone.${name} COMMAND ${CMAKE_CTEST_COMMAND}
  1882. --build-and-test
  1883. "${CMake_SOURCE_DIR}/Tests/VSWinStorePhone"
  1884. "${CMake_BINARY_DIR}/Tests/VSWinStorePhone/${name}"
  1885. --build-generator "${generator}"
  1886. --build-project VSWinStorePhone
  1887. --build-config $<CONFIGURATION>
  1888. --build-options -DCMAKE_SYSTEM_NAME=${systemName}
  1889. -DCMAKE_SYSTEM_VERSION=${systemVersion}
  1890. )
  1891. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSWinStorePhone/${name}")
  1892. endmacro()
  1893. if(vs11 AND ws80)
  1894. add_test_VSWinStorePhone(vs11-store80-X86 "Visual Studio 11 2012" WindowsStore 8.0)
  1895. add_test_VSWinStorePhone(vs11-store80-ARM "Visual Studio 11 2012 ARM" WindowsStore 8.0)
  1896. add_test_VSWinStorePhone(vs11-store80-X64 "Visual Studio 11 2012 Win64" WindowsStore 8.0)
  1897. endif()
  1898. if(vs12 AND ws81)
  1899. add_test_VSWinStorePhone(vs12-store81-X86 "Visual Studio 12 2013" WindowsStore 8.1)
  1900. add_test_VSWinStorePhone(vs12-store81-ARM "Visual Studio 12 2013 ARM" WindowsStore 8.1)
  1901. add_test_VSWinStorePhone(vs12-store81-X64 "Visual Studio 12 2013 Win64" WindowsStore 8.1)
  1902. add_test(NAME VSXaml COMMAND ${CMAKE_CTEST_COMMAND}
  1903. --build-and-test
  1904. "${CMake_SOURCE_DIR}/Tests/VSXaml"
  1905. "${CMake_BINARY_DIR}/Tests/VSXaml"
  1906. --build-generator "Visual Studio 12 2013"
  1907. --build-project VSXaml
  1908. --build-config $<CONFIGURATION>
  1909. --build-options -DCMAKE_SYSTEM_NAME=WindowsStore
  1910. -DCMAKE_SYSTEM_VERSION=8.1
  1911. )
  1912. endif()
  1913. if(vs14 AND ws10_0)
  1914. add_test_VSWinStorePhone(vs14-store10_0-X86 "Visual Studio 14 2015" WindowsStore 10.0)
  1915. add_test_VSWinStorePhone(vs14-store10_0-ARM "Visual Studio 14 2015 ARM" WindowsStore 10.0)
  1916. add_test_VSWinStorePhone(vs14-store10_0-X64 "Visual Studio 14 2015 Win64" WindowsStore 10.0)
  1917. endif()
  1918. if(vs11 AND wp80)
  1919. add_test_VSWinStorePhone(vs11-phone80-X86 "Visual Studio 11 2012" WindowsPhone 8.0)
  1920. add_test_VSWinStorePhone(vs11-phone80-ARM "Visual Studio 11 2012 ARM" WindowsPhone 8.0)
  1921. endif()
  1922. if(vs12 AND wp81)
  1923. add_test_VSWinStorePhone(vs12-phone81-X86 "Visual Studio 12 2013" WindowsPhone 8.1)
  1924. add_test_VSWinStorePhone(vs12-phone81-ARM "Visual Studio 12 2013 ARM" WindowsPhone 8.1)
  1925. endif()
  1926. endif()
  1927. if(WIN32 AND wince)
  1928. macro(add_test_VSWinCE name generator systemName systemVersion generatorPlatform)
  1929. # TODO: Fix the tutorial to make it work in cross compile
  1930. # currently the MakeTable is build for target and can not be used on the host
  1931. # This happens in part 5 so we build only part 1-4 of the tutorial
  1932. foreach(STP RANGE 1 4)
  1933. add_test(NAME "TutorialStep${STP}.${name}" COMMAND ${CMAKE_CTEST_COMMAND}
  1934. --build-and-test
  1935. "${CMake_SOURCE_DIR}/Tests/Tutorial/Step${STP}"
  1936. "${CMake_BINARY_DIR}/Tests/Tutorial/Step${STP}_${name}"
  1937. --build-generator "${generator}"
  1938. --build-project Tutorial
  1939. --build-config $<CONFIGURATION>
  1940. --build-options -DCMAKE_SYSTEM_NAME=${systemName}
  1941. -DCMAKE_SYSTEM_VERSION=${systemVersion}
  1942. -DCMAKE_GENERATOR_PLATFORM=${generatorPlatform})
  1943. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Tutorial/Step${STP}_${name}")
  1944. endforeach()
  1945. endmacro()
  1946. if(vs11)
  1947. add_test_VSWinCE(vs11-ce80-ARM "Visual Studio 11 2012" WindowsCE 8.0 ${wince_sdk})
  1948. endif()
  1949. if(vs12)
  1950. add_test_VSWinCE(vs12-ce80-ARM "Visual Studio 12 2013" WindowsCE 8.0 ${wince_sdk})
  1951. endif()
  1952. endif()
  1953. if(CMAKE_GENERATOR MATCHES "Visual Studio ([^89]|[89][0-9])" AND nasm)
  1954. ADD_TEST_MACRO(VSNASM VSNASM)
  1955. endif()
  1956. if (CMake_TEST_GreenHillsMULTI)
  1957. macro(add_test_GhsMulti name primaryTarget bspName)
  1958. add_test(NAME GhsMulti.${name} COMMAND ${CMAKE_CTEST_COMMAND}
  1959. --build-and-test
  1960. "${CMake_SOURCE_DIR}/Tests/GhsMulti"
  1961. "${CMake_BINARY_DIR}/Tests/GhsMulti/${name}"
  1962. --build-generator "Green Hills MULTI"
  1963. --build-project ReturnNum
  1964. --build-config $<CONFIGURATION>
  1965. --build-options -DGHS_PRIMARY_TARGET=${primaryTarget}
  1966. -DGHS_BSP_NAME=${bspName}
  1967. )
  1968. endmacro ()
  1969. add_test_GhsMulti("arm_integrity_simarm" "arm_integrity.tgt" "simarm")
  1970. add_test_GhsMulti("arm64_integrity_simarm" "arm64_integrity.tgt" "simarm")
  1971. add_test(NAME GhsMulti.duplicate_source_filenames
  1972. COMMAND ${CMAKE_CTEST_COMMAND}
  1973. --build-and-test
  1974. "${CMake_SOURCE_DIR}/Tests/GhsMultiDuplicateSourceFilenames"
  1975. "${CMake_BINARY_DIR}/Tests/GhsMultiDuplicateSourceFilenames"
  1976. --build-generator "Green Hills MULTI"
  1977. --build-project ReturnNum
  1978. --build-config $<CONFIGURATION>
  1979. --build-options -DGHS_PRIMARY_TARGET="arm_integrity.tgt"
  1980. -DGHS_BSP_NAME="simarm"
  1981. )
  1982. endif ()
  1983. if(tegra AND NOT "${CMake_SOURCE_DIR};${CMake_BINARY_DIR}" MATCHES " ")
  1984. macro(add_test_VSNsightTegra name generator)
  1985. add_test(NAME VSNsightTegra.${name} COMMAND ${CMAKE_CTEST_COMMAND}
  1986. --build-and-test
  1987. "${CMake_SOURCE_DIR}/Tests/VSNsightTegra"
  1988. "${CMake_BINARY_DIR}/Tests/VSNsightTegra/${name}"
  1989. --build-generator "${generator}"
  1990. --build-project VSNsightTegra
  1991. --build-config $<CONFIGURATION>
  1992. --build-options -DCMAKE_SYSTEM_NAME=Android
  1993. )
  1994. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSNsightTegra/${name}")
  1995. endmacro()
  1996. if(vs10)
  1997. add_test_VSNsightTegra(vs10 "Visual Studio 10 2010")
  1998. endif()
  1999. if(vs11)
  2000. add_test_VSNsightTegra(vs11 "Visual Studio 11 2012")
  2001. endif()
  2002. if(vs12)
  2003. add_test_VSNsightTegra(vs12 "Visual Studio 12 2013")
  2004. endif()
  2005. if(vs14)
  2006. add_test_VSNsightTegra(vs14 "Visual Studio 14 2015")
  2007. endif()
  2008. endif()
  2009. if (APPLE)
  2010. if (CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
  2011. set(BundleTestInstallDir
  2012. "${CMake_BINARY_DIR}/Tests/BundleTest/InstallDirectory")
  2013. add_test(BundleTest ${CMAKE_CTEST_COMMAND}
  2014. --build-and-test
  2015. "${CMake_SOURCE_DIR}/Tests/BundleTest"
  2016. "${CMake_BINARY_DIR}/Tests/BundleTest"
  2017. --build-two-config
  2018. ${build_generator_args}
  2019. --build-project BundleTest
  2020. --build-target install
  2021. # --build-target package
  2022. --build-options ${build_options}
  2023. "-DCMAKE_INSTALL_PREFIX:PATH=${BundleTestInstallDir}"
  2024. "-DCMake_SOURCE_DIR:PATH=${CMake_SOURCE_DIR}"
  2025. --test-command
  2026. ${BundleTestInstallDir}/Applications/SecondBundleExe.app/Contents/MacOS/SecondBundleExe)
  2027. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BundleTest")
  2028. add_test(NAME CFBundleTest COMMAND ${CMAKE_CTEST_COMMAND}
  2029. --build-and-test
  2030. "${CMake_SOURCE_DIR}/Tests/CFBundleTest"
  2031. "${CMake_BINARY_DIR}/Tests/CFBundleTest"
  2032. --build-two-config
  2033. ${build_generator_args}
  2034. --build-project CFBundleTest
  2035. --build-config $<CONFIGURATION>
  2036. --build-options ${build_options}
  2037. --test-command
  2038. ${CMAKE_CMAKE_COMMAND} -DCTEST_CONFIGURATION_TYPE=$<CONFIGURATION>
  2039. -Ddir=${CMake_BINARY_DIR}/Tests/CFBundleTest
  2040. -Dgen=${CMAKE_GENERATOR}
  2041. -P ${CMake_SOURCE_DIR}/Tests/CFBundleTest/VerifyResult.cmake)
  2042. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CFBundleTest")
  2043. ADD_TEST_MACRO(ObjC++ ObjC++)
  2044. endif ()
  2045. endif ()
  2046. if(APPLE AND CTEST_TEST_CPACK)
  2047. add_test(BundleGeneratorTest ${CMAKE_CTEST_COMMAND}
  2048. --build-and-test
  2049. "${CMake_SOURCE_DIR}/Tests/BundleGeneratorTest"
  2050. "${CMake_BINARY_DIR}/Tests/BundleGeneratorTest"
  2051. --build-two-config
  2052. ${build_generator_args}
  2053. --build-project BundleGeneratorTest
  2054. --build-target package
  2055. --build-options ${build_options}
  2056. "-DCMAKE_INSTALL_PREFIX:PATH=${CMake_BINARY_DIR}/Tests/BundleGeneratorTest/InstallDirectory"
  2057. )
  2058. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BundleGeneratorTest")
  2059. endif()
  2060. add_test(WarnUnusedUnusedViaSet ${CMAKE_CTEST_COMMAND}
  2061. --build-and-test
  2062. "${CMake_SOURCE_DIR}/Tests/VariableUnusedViaSet"
  2063. "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaSet"
  2064. ${build_generator_args}
  2065. --build-noclean
  2066. --build-project WarnUnusedUnusedViaSet
  2067. --build-options ${build_options}
  2068. "--warn-unused-vars")
  2069. set_tests_properties(WarnUnusedUnusedViaSet PROPERTIES
  2070. PASS_REGULAR_EXPRESSION "unused variable \\(changing definition\\) 'UNUSED_VARIABLE'")
  2071. set_tests_properties(WarnUnusedUnusedViaSet PROPERTIES
  2072. FAIL_REGULAR_EXPRESSION "unused variable \\(unsetting\\) 'UNUSED_VARIABLE'")
  2073. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaSet")
  2074. add_test(WarnUnusedUnusedViaUnset ${CMAKE_CTEST_COMMAND}
  2075. --build-and-test
  2076. "${CMake_SOURCE_DIR}/Tests/VariableUnusedViaUnset"
  2077. "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaUnset"
  2078. ${build_generator_args}
  2079. --build-noclean
  2080. --build-project WarnUnusedUnusedViaUnset
  2081. --build-options ${build_options}
  2082. "--warn-unused-vars")
  2083. set_tests_properties(WarnUnusedUnusedViaUnset PROPERTIES
  2084. PASS_REGULAR_EXPRESSION "CMake Warning \\(dev\\) at CMakeLists.txt:7 \\(set\\):")
  2085. set_tests_properties(WarnUnusedUnusedViaUnset PROPERTIES
  2086. FAIL_REGULAR_EXPRESSION "CMakeLists.txt:5 \\(set\\):")
  2087. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaUnset")
  2088. if("${CMAKE_GENERATOR}" MATCHES "Makefile" AND NOT WIN32)
  2089. # Ninja does not support ADDITIONAL_MAKE_CLEAN_FILES and therefore fails
  2090. # this test. (See #13371)
  2091. # Apparently Visual Studio does not support it either. As the MakeClean
  2092. # test above is only run with the Makefiles generator, only run this
  2093. # test with the Makefiles generator also.
  2094. add_test(WarnUnusedCliUnused ${CMAKE_CTEST_COMMAND}
  2095. --build-and-test
  2096. "${CMake_SOURCE_DIR}/Tests/WarnUnusedCliUnused"
  2097. "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused"
  2098. ${build_generator_args}
  2099. --build-project WarnUnusedCliUnused
  2100. --build-options ${build_options}
  2101. "-DUNUSED_CLI_VARIABLE=Unused")
  2102. set_tests_properties(WarnUnusedCliUnused PROPERTIES
  2103. PASS_REGULAR_EXPRESSION "CMake Warning:.*Manually-specified variables were not used by the project:.* UNUSED_CLI_VARIABLE")
  2104. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused")
  2105. endif()
  2106. add_test(WarnUnusedCliUsed ${CMAKE_CTEST_COMMAND}
  2107. --build-and-test
  2108. "${CMake_SOURCE_DIR}/Tests/VariableUsage"
  2109. "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUsed"
  2110. ${build_generator_args}
  2111. --build-noclean
  2112. --build-project WarnUnusedCliUsed
  2113. --build-options ${build_options}
  2114. "-DUSED_VARIABLE=Usage proven")
  2115. set_tests_properties(WarnUnusedCliUsed PROPERTIES
  2116. PASS_REGULAR_EXPRESSION "Usage proven")
  2117. set_tests_properties(WarnUnusedCliUsed PROPERTIES
  2118. FAIL_REGULAR_EXPRESSION "CMake Warning: The variable, 'USED_VARIABLE'")
  2119. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUsed")
  2120. add_test(WarnUninitialized ${CMAKE_CTEST_COMMAND}
  2121. --build-and-test
  2122. "${CMake_SOURCE_DIR}/Tests/VariableUsage"
  2123. "${CMake_BINARY_DIR}/Tests/WarnUninitialized"
  2124. ${build_generator_args}
  2125. --build-noclean
  2126. --build-project WarnUninitialized
  2127. --build-options ${build_options}
  2128. "--warn-uninitialized")
  2129. set_tests_properties(WarnUninitialized PROPERTIES
  2130. PASS_REGULAR_EXPRESSION "uninitialized variable 'USED_VARIABLE'")
  2131. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUninitialized")
  2132. add_test(TestsWorkingDirectory
  2133. ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE}
  2134. --build-and-test
  2135. "${CMake_SOURCE_DIR}/Tests/TestsWorkingDirectory"
  2136. "${CMake_BINARY_DIR}/Tests/TestsWorkingDirectory"
  2137. ${build_generator_args}
  2138. --build-project TestsWorkingDirectoryProj
  2139. --build-exe-dir "${CMake_BINARY_DIR}/Tests/TestsWorkingDirectory"
  2140. --force-new-ctest-process
  2141. --build-options ${build_options}
  2142. --test-command ${CMAKE_CTEST_COMMAND} -V -C \${CTEST_CONFIGURATION_TYPE}
  2143. )
  2144. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/TestsWorkingDirectory")
  2145. # Make sure CTest can handle a test with no newline in output.
  2146. add_test(CTest.NoNewline
  2147. ${CMAKE_CMAKE_COMMAND} -E echo_append "This line has no newline!")
  2148. # A simple test for ctest in script mode
  2149. configure_file("${CMake_SOURCE_DIR}/Tests/CTestScriptMode/CTestTestScriptMode.cmake.in"
  2150. "${CMake_BINARY_DIR}/Tests/CTestScriptMode/CTestTestScriptMode.cmake" @ONLY)
  2151. # add_test(CTest.ScriptMode ${CMAKE_CTEST_COMMAND}
  2152. # -S "${CMake_BINARY_DIR}/Tests/CTestScriptMode/CTestTestScriptMode.cmake"
  2153. # )
  2154. # A test for ctest_build() with targets in subdirectories
  2155. set(ctest_configure_options)
  2156. if(CMAKE_GENERATOR_PLATFORM)
  2157. list(APPEND ctest_configure_options -A ${CMAKE_GENERATOR_PLATFORM})
  2158. endif()
  2159. if(CMAKE_GENERATOR_TOOLSET)
  2160. list(APPEND ctest_configure_options -T ${CMAKE_GENERATOR_TOOLSET})
  2161. endif()
  2162. if(CMake_TEST_EXPLICIT_MAKE_PROGRAM)
  2163. list(APPEND ctest_configure_options -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM})
  2164. endif()
  2165. configure_file("${CMake_SOURCE_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in"
  2166. "${CMake_BINARY_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake" @ONLY)
  2167. unset(ctest_configure_options)
  2168. add_test(CTest.BuildCommand.ProjectInSubdir
  2169. ${CMAKE_CTEST_COMMAND} -S "${CMake_BINARY_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake")
  2170. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CTestBuildCommandProjectInSubdir/Nested")
  2171. set(CTEST_TEST_UPDATE 1)
  2172. if(CTEST_TEST_UPDATE)
  2173. # Test CTest Update with Subversion
  2174. find_package(Subversion QUIET)
  2175. if(Subversion_FOUND)
  2176. get_filename_component(_Subversion_BIN_DIR
  2177. ${Subversion_SVN_EXECUTABLE} PATH)
  2178. find_program(Subversion_SVNADMIN_EXECUTABLE svnadmin
  2179. HINTS ${_Subversion_BIN_DIR}
  2180. )
  2181. mark_as_advanced(Subversion_SVNADMIN_EXECUTABLE)
  2182. if(NOT Subversion_SVNADMIN_EXECUTABLE)
  2183. set(Subversion_FOUND FALSE)
  2184. endif()
  2185. endif()
  2186. if(Subversion_FOUND)
  2187. set(CTestUpdateSVN_DIR "CTest UpdateSVN")
  2188. configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateSVN.cmake.in"
  2189. "${CMake_BINARY_DIR}/Tests/CTestUpdateSVN.cmake" @ONLY)
  2190. add_test(CTest.UpdateSVN ${CMAKE_CMAKE_COMMAND}
  2191. -P "${CMake_BINARY_DIR}/Tests/CTestUpdateSVN.cmake"
  2192. )
  2193. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateSVN_DIR}")
  2194. endif()
  2195. # Test CTest Update with CVS
  2196. if(EXISTS ${CMAKE_ROOT}/Modules/FindCVS.cmake)
  2197. find_package(CVS QUIET)
  2198. else()
  2199. find_program(CVS_EXECUTABLE NAMES cvs)
  2200. set(CVS_FOUND ${CVS_EXECUTABLE})
  2201. endif()
  2202. set(CTEST_TEST_UPDATE_CVS ${CVS_FOUND})
  2203. if(CTEST_TEST_UPDATE_CVS AND NOT UNIX)
  2204. if("${CVS_EXECUTABLE}" MATCHES "cygwin")
  2205. message(STATUS "No CTest.UpdateCVS test with cygwin cvs.exe outside cygwin!")
  2206. set(CTEST_TEST_UPDATE_CVS 0)
  2207. endif()
  2208. endif()
  2209. if(CTEST_TEST_UPDATE_CVS)
  2210. set(CTestUpdateCVS_DIR "CTest UpdateCVS")
  2211. configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateCVS.cmake.in"
  2212. "${CMake_BINARY_DIR}/Tests/CTestUpdateCVS.cmake" @ONLY)
  2213. add_test(CTest.UpdateCVS ${CMAKE_CMAKE_COMMAND}
  2214. -P "${CMake_BINARY_DIR}/Tests/CTestUpdateCVS.cmake"
  2215. )
  2216. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateCVS_DIR}")
  2217. endif()
  2218. # Test CTest Update with BZR
  2219. find_program(BZR_EXECUTABLE NAMES bzr)
  2220. mark_as_advanced(BZR_EXECUTABLE)
  2221. set(CTEST_TEST_UPDATE_BZR 0)
  2222. if(BZR_EXECUTABLE)
  2223. if(NOT "${BZR_EXECUTABLE}" MATCHES "cygwin" OR UNIX)
  2224. set(CTEST_TEST_UPDATE_BZR 1)
  2225. endif()
  2226. endif()
  2227. if(CTEST_TEST_UPDATE_BZR)
  2228. # Check if xmloutput plugin is there
  2229. execute_process(COMMAND ${BZR_EXECUTABLE} xmlplugins RESULT_VARIABLE xmlplugres
  2230. OUTPUT_QUIET ERROR_QUIET)
  2231. if( NOT ${xmlplugres} )
  2232. set(CTestUpdateBZR_DIR "CTest UpdateBZR")
  2233. configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateBZR.cmake.in"
  2234. "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR.cmake" @ONLY)
  2235. add_test(CTest.UpdateBZR ${CMAKE_CMAKE_COMMAND}
  2236. -P "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR.cmake"
  2237. )
  2238. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateBZR_DIR}")
  2239. set(CTestUpdateBZR_DIR "CTest UpdateBZR_CLocale")
  2240. configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateBZR.cmake.in"
  2241. "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR_CLocale.cmake" @ONLY)
  2242. add_test(CTest.UpdateBZR.CLocale ${CMAKE_CMAKE_COMMAND}
  2243. -P "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR_CLocale.cmake"
  2244. )
  2245. set_tests_properties(CTest.UpdateBZR.CLocale PROPERTIES ENVIRONMENT LC_ALL=C)
  2246. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateBZR_DIR}")
  2247. endif()
  2248. endif()
  2249. # Test CTest Update with GIT
  2250. find_program(GIT_EXECUTABLE NAMES git)
  2251. mark_as_advanced(GIT_EXECUTABLE)
  2252. set(CTEST_TEST_UPDATE_GIT 0)
  2253. if(GIT_EXECUTABLE)
  2254. if(NOT "${GIT_EXECUTABLE}" MATCHES "cygwin" OR UNIX)
  2255. set(CTEST_TEST_UPDATE_GIT 1)
  2256. endif()
  2257. endif()
  2258. if(CTEST_TEST_UPDATE_GIT)
  2259. set(CTestUpdateGIT_DIR "CTest UpdateGIT")
  2260. configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateGIT.cmake.in"
  2261. "${CMake_BINARY_DIR}/Tests/CTestUpdateGIT.cmake" @ONLY)
  2262. add_test(CTest.UpdateGIT ${CMAKE_CMAKE_COMMAND}
  2263. -P "${CMake_BINARY_DIR}/Tests/CTestUpdateGIT.cmake"
  2264. )
  2265. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateGIT_DIR}")
  2266. endif()
  2267. # Test CTest Update with HG
  2268. find_program(HG_EXECUTABLE NAMES hg)
  2269. mark_as_advanced(HG_EXECUTABLE)
  2270. set(CTEST_TEST_UPDATE_HG 0)
  2271. if(HG_EXECUTABLE)
  2272. if(NOT "${HG_EXECUTABLE}" MATCHES "cygwin" OR UNIX)
  2273. set(CTEST_TEST_UPDATE_HG 1)
  2274. endif()
  2275. endif()
  2276. if(CTEST_TEST_UPDATE_HG)
  2277. set(CTestUpdateHG_DIR "CTest UpdateHG")
  2278. configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateHG.cmake.in"
  2279. "${CMake_BINARY_DIR}/Tests/CTestUpdateHG.cmake" @ONLY)
  2280. add_test(CTest.UpdateHG ${CMAKE_CMAKE_COMMAND}
  2281. -P "${CMake_BINARY_DIR}/Tests/CTestUpdateHG.cmake"
  2282. )
  2283. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateHG_DIR}")
  2284. endif()
  2285. # Test CTest Update with P4
  2286. find_program(P4_EXECUTABLE NAMES p4)
  2287. find_program(P4D_EXECUTABLE NAMES p4d)
  2288. mark_as_advanced(P4_EXECUTABLE P4D_EXECUTABLE)
  2289. set(CTEST_TEST_UPDATE_P4 0)
  2290. if(P4_EXECUTABLE AND P4D_EXECUTABLE)
  2291. if(NOT "${P4_EXECUTABLE};${P4D_EXECUTABLE}" MATCHES "cygwin" OR UNIX)
  2292. set(CTEST_TEST_UPDATE_P4 1)
  2293. endif()
  2294. endif()
  2295. if(CTEST_TEST_UPDATE_P4)
  2296. set(CTestUpdateP4_DIR "CTest UpdateP4")
  2297. configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateP4.cmake.in"
  2298. "${CMake_BINARY_DIR}/Tests/CTestUpdateP4.cmake" @ONLY)
  2299. add_test(CTest.UpdateP4 ${CMAKE_CMAKE_COMMAND}
  2300. -P "${CMake_BINARY_DIR}/Tests/CTestUpdateP4.cmake"
  2301. )
  2302. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateP4_DIR}")
  2303. endif()
  2304. endif()
  2305. configure_file(
  2306. "${CMake_SOURCE_DIR}/Tests/CTestTestFailure/testNoBuild.cmake.in"
  2307. "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testNoBuild.cmake"
  2308. @ONLY ESCAPE_QUOTES)
  2309. add_test(CTestTestNoBuild ${CMAKE_CTEST_COMMAND}
  2310. -S "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testNoBuild.cmake" -V
  2311. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testOut1.log"
  2312. )
  2313. set_tests_properties(CTestTestNoBuild PROPERTIES
  2314. FAIL_REGULAR_EXPRESSION "Error" WILL_FAIL true)
  2315. configure_file(
  2316. "${CMake_SOURCE_DIR}/Tests/CTestTestFailure/testNoExe.cmake.in"
  2317. "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testNoExe.cmake"
  2318. @ONLY ESCAPE_QUOTES)
  2319. add_test(CTestTestNoExe ${CMAKE_CTEST_COMMAND}
  2320. -S "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testNoExe.cmake" -V
  2321. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testOut2.log"
  2322. )
  2323. set_tests_properties(CTestTestNoExe PROPERTIES DEPENDS CTestTestNoBuild
  2324. PASS_REGULAR_EXPRESSION "Could not find executable"
  2325. FAIL_REGULAR_EXPRESSION "SegFault")
  2326. configure_file(
  2327. "${CMake_SOURCE_DIR}/Tests/CTestTestUpload/test.cmake.in"
  2328. "${CMake_BINARY_DIR}/Tests/CTestTestUpload/test.cmake"
  2329. @ONLY ESCAPE_QUOTES)
  2330. add_test(CTestTestUpload ${CMAKE_CTEST_COMMAND}
  2331. -S "${CMake_BINARY_DIR}/Tests/CTestTestUpload/test.cmake" -V
  2332. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestUpload/testOut.log"
  2333. )
  2334. set_tests_properties(CTestTestUpload PROPERTIES
  2335. PASS_REGULAR_EXPRESSION "Upload\\.xml")
  2336. configure_file(
  2337. "${CMake_SOURCE_DIR}/Tests/CTestCoverageCollectGCOV/test.cmake.in"
  2338. "${CMake_BINARY_DIR}/Tests/CTestCoverageCollectGCOV/test.cmake"
  2339. @ONLY ESCAPE_QUOTES)
  2340. add_test(CTestCoverageCollectGCOV ${CMAKE_CTEST_COMMAND}
  2341. -C \${CTEST_CONFIGURATION_TYPE}
  2342. -S "${CMake_BINARY_DIR}/Tests/CTestCoverageCollectGCOV/test.cmake" -VV
  2343. --output-log "${CMake_BINARY_DIR}/Tests/CTestCoverageCollectGCOV/testOut.log"
  2344. )
  2345. set_tests_properties(CTestCoverageCollectGCOV PROPERTIES
  2346. PASS_REGULAR_EXPRESSION
  2347. "PASSED with correct output.*Testing/CoverageInfo/main.cpp.gcov")
  2348. set_property(TEST CTestCoverageCollectGCOV PROPERTY ENVIRONMENT CTEST_PARALLEL_LEVEL=)
  2349. configure_file(
  2350. "${CMake_SOURCE_DIR}/Tests/CTestTestEmptyBinaryDirectory/test.cmake.in"
  2351. "${CMake_BINARY_DIR}/Tests/CTestTestEmptyBinaryDirectory/test.cmake"
  2352. @ONLY ESCAPE_QUOTES)
  2353. add_test(CTestTestEmptyBinaryDirectory ${CMAKE_CTEST_COMMAND}
  2354. -S "${CMake_BINARY_DIR}/Tests/CTestTestEmptyBinaryDirectory/test.cmake" -V
  2355. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestEmptyBinaryDirectory/testOut.log"
  2356. )
  2357. set_tests_properties(CTestTestEmptyBinaryDirectory PROPERTIES
  2358. PASS_REGULAR_EXPRESSION "TEST_SUCCESS")
  2359. # test coverage for mumps
  2360. # create a MumpsCoverage dir in the binary tree under Testing to
  2361. # avoid the .NoDartCoverage files in the cmake testing tree
  2362. configure_file(
  2363. "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/DartConfiguration.tcl.in"
  2364. "${CMake_BINARY_DIR}/Testing/MumpsCoverage/DartConfiguration.tcl")
  2365. configure_file(
  2366. "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/gtm_coverage.mcov.in"
  2367. "${CMake_BINARY_DIR}/Testing/MumpsCoverage/gtm_coverage.mcov")
  2368. file(REMOVE_RECURSE "${CMake_BINARY_DIR}/Testing/MumpsCoverage/VistA-FOIA")
  2369. file(COPY "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/VistA-FOIA"
  2370. DESTINATION "${CMake_BINARY_DIR}/Testing/MumpsCoverage")
  2371. add_test(NAME CTestGTMCoverage
  2372. COMMAND cmake -E chdir
  2373. ${CMake_BINARY_DIR}/Testing/MumpsCoverage
  2374. $<TARGET_FILE:ctest> -T Coverage --debug)
  2375. set_tests_properties(CTestGTMCoverage PROPERTIES
  2376. PASS_REGULAR_EXPRESSION
  2377. "Process file.*ZZCOVTST.m.*Total LOC:.*30.*Percentage Coverage: 80.00*"
  2378. ENVIRONMENT COVFILE=)
  2379. configure_file(
  2380. "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/DartConfiguration.cache.tcl.in"
  2381. "${CMake_BINARY_DIR}/Testing/MumpsCacheCoverage/DartConfiguration.tcl")
  2382. configure_file(
  2383. "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/cache_coverage.cmcov.in"
  2384. "${CMake_BINARY_DIR}/Testing/MumpsCacheCoverage/cache_coverage.cmcov")
  2385. file(REMOVE_RECURSE "${CMake_BINARY_DIR}/Testing/MumpsCacheCoverage/VistA-FOIA")
  2386. file(COPY "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/VistA-FOIA"
  2387. DESTINATION "${CMake_BINARY_DIR}/Testing/MumpsCacheCoverage")
  2388. add_test(NAME CTestCacheCoverage
  2389. COMMAND cmake -E chdir
  2390. ${CMake_BINARY_DIR}/Testing/MumpsCacheCoverage
  2391. $<TARGET_FILE:ctest> -T Coverage --debug)
  2392. set_tests_properties(CTestCacheCoverage PROPERTIES
  2393. PASS_REGULAR_EXPRESSION
  2394. "Process file.*ZZCOVTST.m.*Total LOC:.*29.*Percentage Coverage: 86.21.*"
  2395. ENVIRONMENT COVFILE=)
  2396. # Adding a test case for Python Coverage
  2397. configure_file(
  2398. "${CMake_SOURCE_DIR}/Tests/PythonCoverage/coverage.xml.in"
  2399. "${CMake_BINARY_DIR}/Testing/PythonCoverage/coverage.xml")
  2400. configure_file(
  2401. "${CMake_SOURCE_DIR}/Tests/PythonCoverage/DartConfiguration.tcl.in"
  2402. "${CMake_BINARY_DIR}/Testing/PythonCoverage/DartConfiguration.tcl")
  2403. file(COPY "${CMake_SOURCE_DIR}/Tests/PythonCoverage/coveragetest"
  2404. DESTINATION "${CMake_BINARY_DIR}/Testing/PythonCoverage")
  2405. add_test(NAME CTestPythonCoverage
  2406. COMMAND cmake -E chdir
  2407. ${CMake_BINARY_DIR}/Testing/PythonCoverage
  2408. $<TARGET_FILE:ctest> -T Coverage --debug)
  2409. set_tests_properties(CTestPythonCoverage PROPERTIES
  2410. PASS_REGULAR_EXPRESSION
  2411. "Process file.*foo.py.*Total LOC:.*13.*Percentage Coverage: 84.62.*"
  2412. ENVIRONMENT COVFILE=)
  2413. # Adding a test case for non-python Cobertura Coverage
  2414. configure_file(
  2415. "${CMake_SOURCE_DIR}/Tests/CoberturaCoverage/DartConfiguration.tcl.in"
  2416. "${CMake_BINARY_DIR}/Testing/CoberturaCoverage/DartConfiguration.tcl")
  2417. configure_file(
  2418. "${CMake_SOURCE_DIR}/Tests/CoberturaCoverage/coverage.xml.in"
  2419. "${CMake_BINARY_DIR}/Testing/CoberturaCoverage/coverage.xml")
  2420. file(COPY "${CMake_SOURCE_DIR}/Tests/CoberturaCoverage/src"
  2421. DESTINATION "${CMake_BINARY_DIR}/Testing/CoberturaCoverage")
  2422. add_test(NAME CTestCoberturaCoverage
  2423. COMMAND cmake -E chdir
  2424. ${CMake_BINARY_DIR}/Testing/CoberturaCoverage
  2425. $<TARGET_FILE:ctest> -T Coverage --debug)
  2426. set_tests_properties(CTestCoberturaCoverage PROPERTIES
  2427. PASS_REGULAR_EXPRESSION
  2428. "Process file.*CoverageTest.java.*Total LOC:.*18.*Percentage Coverage: 72.22.*"
  2429. ENVIRONMENT COBERTURADIR=${CMake_BINARY_DIR}/Testing/CoberturaCoverage
  2430. ENVIRONMENT COVFILE=)
  2431. # Adding a test case for JaCoCo Coverage
  2432. configure_file(
  2433. "${CMake_SOURCE_DIR}/Tests/JacocoCoverage/DartConfiguration.tcl.in"
  2434. "${CMake_BINARY_DIR}/Testing/JacocoCoverage/DartConfiguration.tcl")
  2435. file(COPY "${CMake_SOURCE_DIR}/Tests/JacocoCoverage/Coverage"
  2436. DESTINATION "${CMake_BINARY_DIR}/Testing/JacocoCoverage")
  2437. configure_file("${CMake_BINARY_DIR}/Testing/JacocoCoverage/Coverage/target/site/jacoco.xml.in"
  2438. "${CMake_BINARY_DIR}/Testing/JacocoCoverage/Coverage/target/site/jacoco.xml")
  2439. add_test(NAME CTestJacocoCoverage
  2440. COMMAND cmake -E chdir
  2441. ${CMake_BINARY_DIR}/Testing/JacocoCoverage
  2442. $<TARGET_FILE:ctest> -T Coverage --debug)
  2443. set_tests_properties(CTestJacocoCoverage PROPERTIES
  2444. PASS_REGULAR_EXPRESSION
  2445. "Process file.*CoverageTest.java.*Total LOC:.*17.*Percentage Coverage: 76.47*"
  2446. ENVIRONMENT COVFILE=)
  2447. # Adding a test case for Javascript Coverage
  2448. configure_file(
  2449. "${CMake_SOURCE_DIR}/Tests/JavascriptCoverage/DartConfiguration.tcl.in"
  2450. "${CMake_BINARY_DIR}/Testing/JavascriptCoverage/DartConfiguration.tcl")
  2451. configure_file(
  2452. "${CMake_SOURCE_DIR}/Tests/JavascriptCoverage/output.json.in"
  2453. "${CMake_BINARY_DIR}/Testing/JavascriptCoverage/output.json")
  2454. file(COPY "${CMake_SOURCE_DIR}/Tests/JavascriptCoverage/"
  2455. DESTINATION "${CMake_BINARY_DIR}/Testing/JavascriptCoverage"
  2456. FILES_MATCHING PATTERN "*.js")
  2457. add_test(NAME CTestJavascriptCoverage
  2458. COMMAND cmake -E chdir
  2459. ${CMake_BINARY_DIR}/Testing/JavascriptCoverage
  2460. $<TARGET_FILE:ctest> -T Coverage --debug)
  2461. set_tests_properties(CTestJavascriptCoverage PROPERTIES
  2462. PASS_REGULAR_EXPRESSION
  2463. "Process file.*test3.js.*Total LOC:.*49.*Percentage Coverage: 79.59*"
  2464. ENVIRONMENT COVFILE=)
  2465. # test coverage for Delphi-code-Coverage
  2466. configure_file(
  2467. "${CMake_SOURCE_DIR}/Tests/DelphiCoverage/DartConfiguration.tcl.in"
  2468. "${CMake_BINARY_DIR}/Testing/DelphiCoverage/DartConfiguration.tcl")
  2469. file(COPY "${CMake_SOURCE_DIR}/Tests/DelphiCoverage/src"
  2470. DESTINATION "${CMake_BINARY_DIR}/Testing/DelphiCoverage")
  2471. configure_file(
  2472. "${CMake_SOURCE_DIR}/Tests/DelphiCoverage/UTCovTest(UTCovTest.pas).html.in"
  2473. "${CMake_BINARY_DIR}/Testing/DelphiCoverage/UTCovTest(UTCovTest.pas).html")
  2474. add_test(NAME CTestDelphiCoverage
  2475. COMMAND cmake -E chdir
  2476. ${CMake_BINARY_DIR}/Testing/DelphiCoverage
  2477. $<TARGET_FILE:ctest> -T Coverage --debug)
  2478. set_tests_properties(CTestDelphiCoverage PROPERTIES
  2479. PASS_REGULAR_EXPRESSION
  2480. "Process file.*UTCovTest.pas.*Total LOC:.*20.*Percentage Coverage: 95.*"
  2481. ENVIRONMENT COVFILE=)
  2482. function(add_config_tests cfg)
  2483. set(base "${CMake_BINARY_DIR}/Tests/CTestConfig")
  2484. # Test -S script with a -C config arg to ctest:
  2485. configure_file(
  2486. "${CMake_SOURCE_DIR}/Tests/CTestConfig/script.cmake.in"
  2487. "${base}/${cfg}-script.cmake"
  2488. @ONLY ESCAPE_QUOTES)
  2489. add_test(CTestConfig.Script.${cfg} ${CMAKE_CTEST_COMMAND}
  2490. -C ${cfg}
  2491. -S "${base}/${cfg}-script.cmake" -VV
  2492. --output-log "${base}/${cfg}-script.log"
  2493. )
  2494. # Test -D dashboard with a -C config arg to ctest.
  2495. # (Actual commands inside a cmake -P script because we need to be able to set
  2496. # the working directory reliably...)
  2497. configure_file(
  2498. "${CMake_SOURCE_DIR}/Tests/CTestConfig/dashboard.cmake.in"
  2499. "${base}/${cfg}-dashboard.cmake"
  2500. @ONLY ESCAPE_QUOTES)
  2501. add_test(CTestConfig.Dashboard.${cfg} ${CMAKE_CMAKE_COMMAND}
  2502. -P "${base}/${cfg}-dashboard.cmake" -VV
  2503. )
  2504. endfunction()
  2505. add_config_tests(Debug)
  2506. add_config_tests(MinSizeRel)
  2507. add_config_tests(Release)
  2508. add_config_tests(RelWithDebInfo)
  2509. # Test -S script with some -D variable definition args to ctest:
  2510. add_test(CTestConfig.ScriptWithArgs ${CMAKE_CTEST_COMMAND}
  2511. -C "Release"
  2512. -D arg1=this
  2513. -D arg2=that
  2514. -D "arg3=the other"
  2515. "-Darg4=this is the fourth"
  2516. -Darg5=the_fifth
  2517. -Darg6:STRING=value-with-type
  2518. -S "${CMake_SOURCE_DIR}/Tests/CTestConfig/ScriptWithArgs.cmake" -VV
  2519. --output-log "${CMake_BINARY_DIR}/Tests/CTestConfig/ScriptWithArgs.log"
  2520. )
  2521. ADD_TEST_MACRO(CMakeCommands.add_compile_options add_compile_options)
  2522. ADD_TEST_MACRO(CMakeCommands.target_link_libraries target_link_libraries)
  2523. ADD_TEST_MACRO(CMakeCommands.target_include_directories target_include_directories)
  2524. ADD_TEST_MACRO(CMakeCommands.target_compile_definitions target_compile_definitions)
  2525. ADD_TEST_MACRO(CMakeCommands.target_compile_options target_compile_options)
  2526. if(CMake_TEST_SERVER_MODE)
  2527. # The cmake server-mode test requires python for a simple client.
  2528. find_package(PythonInterp QUIET)
  2529. if(PYTHON_EXECUTABLE)
  2530. set(Server_BUILD_OPTIONS -DPYTHON_EXECUTABLE:FILEPATH=${PYTHON_EXECUTABLE})
  2531. ADD_TEST_MACRO(Server Server)
  2532. endif()
  2533. endif()
  2534. configure_file(
  2535. "${CMake_SOURCE_DIR}/Tests/CTestTestCrash/test.cmake.in"
  2536. "${CMake_BINARY_DIR}/Tests/CTestTestCrash/test.cmake"
  2537. @ONLY ESCAPE_QUOTES)
  2538. add_test(CTestTestCrash ${CMAKE_CTEST_COMMAND}
  2539. -S "${CMake_BINARY_DIR}/Tests/CTestTestCrash/test.cmake" -V
  2540. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestCrash/testOutput.log"
  2541. )
  2542. # with watcom the SEGFAULT is not found, it just fails
  2543. if(CMAKE_GENERATOR MATCHES "Watcom WMake")
  2544. set_tests_properties(CTestTestCrash PROPERTIES
  2545. PASS_REGULAR_EXPRESSION "Failed")
  2546. else()
  2547. set_tests_properties(CTestTestCrash PROPERTIES
  2548. PASS_REGULAR_EXPRESSION "(Illegal|SegFault)")
  2549. endif()
  2550. configure_file(
  2551. "${CMake_SOURCE_DIR}/Tests/CTestTestBadExe/test.cmake.in"
  2552. "${CMake_BINARY_DIR}/Tests/CTestTestBadExe/test.cmake"
  2553. @ONLY ESCAPE_QUOTES)
  2554. add_test(CTestTestBadExe ${CMAKE_CTEST_COMMAND}
  2555. -S "${CMake_BINARY_DIR}/Tests/CTestTestBadExe/test.cmake" -V
  2556. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestBadExe/testOutput.log"
  2557. )
  2558. set(CTestTestBadExe_REGEX "BAD_COMMAND")
  2559. # some cygwin can not be made to produce a BAD_COMMAND error
  2560. # the best we can get from it is a failed test
  2561. if(CYGWIN)
  2562. set(CTestTestBadExe_REGEX "(\\*\\*\\*Failed)|BAD_COMMAND")
  2563. endif()
  2564. set_tests_properties(CTestTestBadExe PROPERTIES
  2565. PASS_REGULAR_EXPRESSION "${CTestTestBadExe_REGEX}")
  2566. configure_file(
  2567. "${CMake_SOURCE_DIR}/Tests/CTestTestBadGenerator/test.cmake.in"
  2568. "${CMake_BINARY_DIR}/Tests/CTestTestBadGenerator/test.cmake"
  2569. @ONLY ESCAPE_QUOTES)
  2570. add_test(CTestTestBadGenerator ${CMAKE_CTEST_COMMAND}
  2571. -C "\${CTestTest_CONFIG}"
  2572. -S "${CMake_BINARY_DIR}/Tests/CTestTestBadGenerator/test.cmake" -V
  2573. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestBadGenerator/testOutput.log"
  2574. )
  2575. set_property(TEST CTestTestBadGenerator PROPERTY
  2576. PASS_REGULAR_EXPRESSION "could not create generator named \"Bad Generator\"")
  2577. configure_file(
  2578. "${CMake_SOURCE_DIR}/Tests/CTestTestParallel/test.cmake.in"
  2579. "${CMake_BINARY_DIR}/Tests/CTestTestParallel/test.cmake"
  2580. @ONLY ESCAPE_QUOTES)
  2581. add_test(CTestTestParallel ${CMAKE_CTEST_COMMAND}
  2582. -S "${CMake_BINARY_DIR}/Tests/CTestTestParallel/test.cmake" -V
  2583. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestParallel/testOutput.log"
  2584. )
  2585. configure_file("${CMake_SOURCE_DIR}/Tests/CTestTestVerboseOutput/test.cmake.in"
  2586. "${CMake_BINARY_DIR}/Tests/CTestTestVerboseOutput/test.cmake" @ONLY ESCAPE_QUOTES)
  2587. add_test(CTestTestVerboseOutput ${CMAKE_CTEST_COMMAND}
  2588. -S "${CMake_BINARY_DIR}/Tests/CTestTestVerboseOutput/test.cmake" -VV
  2589. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestVerboseOutput/testOutput.log"
  2590. -C "\${CTestTest_CONFIG}"
  2591. )
  2592. set_property(TEST CTestTestVerboseOutput PROPERTY PASS_REGULAR_EXPRESSION
  2593. "Environment variables:.*foo=bar.*this=that"
  2594. )
  2595. configure_file(
  2596. "${CMake_SOURCE_DIR}/Tests/CTestTestSkipReturnCode/test.cmake.in"
  2597. "${CMake_BINARY_DIR}/Tests/CTestTestSkipReturnCode/test.cmake"
  2598. @ONLY ESCAPE_QUOTES)
  2599. add_test(CTestTestSkipReturnCode ${CMAKE_CTEST_COMMAND}
  2600. -S "${CMake_BINARY_DIR}/Tests/CTestTestSkipReturnCode/test.cmake" -V
  2601. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestSkipReturnCode/testOutput.log"
  2602. -C \${CTEST_CONFIGURATION_TYPE}
  2603. )
  2604. set_tests_properties(CTestTestSkipReturnCode PROPERTIES
  2605. PASS_REGULAR_EXPRESSION "CMakeV1 \\.* +Passed.*CMakeV2 \\.+\\*+Skipped")
  2606. set_property(TEST CTestTestSkipReturnCode PROPERTY ENVIRONMENT CTEST_PARALLEL_LEVEL=)
  2607. ADD_TEST_MACRO(CTestTestSerialInDepends ${CMAKE_CTEST_COMMAND} -j 4
  2608. --output-on-failure -C "\${CTestTest_CONFIG}")
  2609. ADD_TEST_MACRO(CTestTestMissingDependsExe ${CMAKE_CTEST_COMMAND}
  2610. --output-on-failure -C "\${CTestTest_CONFIG}")
  2611. set_tests_properties(CTestTestMissingDependsExe PROPERTIES
  2612. PASS_REGULAR_EXPRESSION "\\*\\*\\*Not Run"
  2613. )
  2614. ADD_TEST_MACRO(CTestTestSerialOrder ${CMAKE_CTEST_COMMAND}
  2615. --output-on-failure -C "\${CTestTest_CONFIG}")
  2616. set_property(TEST CTestTestSerialOrder PROPERTY ENVIRONMENT CTEST_PARALLEL_LEVEL=)
  2617. if(NOT BORLAND)
  2618. set(CTestLimitDashJ_CTEST_OPTIONS --force-new-ctest-process)
  2619. add_test_macro(CTestLimitDashJ ${CMAKE_CTEST_COMMAND} -j 4
  2620. --output-on-failure -C "\${CTestTest_CONFIG}")
  2621. endif()
  2622. add_test(CTestTestPrintLabels ${CMAKE_CTEST_COMMAND} --print-labels)
  2623. set_tests_properties(CTestTestPrintLabels PROPERTIES LABELS "Label1;Label2")
  2624. set_tests_properties(CTestTestPrintLabels PROPERTIES PASS_REGULAR_EXPRESSION
  2625. "All Labels:.* Label1.* Label2")
  2626. configure_file(
  2627. "${CMake_SOURCE_DIR}/Tests/CTestTestLabelRegExp/test.cmake.in"
  2628. "${CMake_BINARY_DIR}/Tests/CTestTestLabelRegExp/test.cmake"
  2629. @ONLY ESCAPE_QUOTES)
  2630. add_test(NAME CTestTestLabelRegExp
  2631. COMMAND ${CMAKE_CMAKE_COMMAND}
  2632. -DSOURCE_DIR=${CMAKE_SOURCE_DIR}/Tests/CTestTestLabelRegExp
  2633. -P ${CMAKE_BINARY_DIR}/Tests/CTestTestLabelRegExp/test.cmake
  2634. WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/Tests/CTestTestLabelRegExp
  2635. )
  2636. configure_file(
  2637. "${CMake_SOURCE_DIR}/Tests/CTestTestResourceLock/test.cmake.in"
  2638. "${CMake_BINARY_DIR}/Tests/CTestTestResourceLock/test.cmake"
  2639. @ONLY ESCAPE_QUOTES)
  2640. add_test(CTestTestResourceLock ${CMAKE_CTEST_COMMAND}
  2641. -S "${CMake_BINARY_DIR}/Tests/CTestTestResourceLock/test.cmake" -V
  2642. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestResourceLock/output.log"
  2643. )
  2644. configure_file(
  2645. "${CMake_SOURCE_DIR}/Tests/CTestTestScheduler/test.cmake.in"
  2646. "${CMake_BINARY_DIR}/Tests/CTestTestScheduler/test.cmake"
  2647. @ONLY ESCAPE_QUOTES)
  2648. add_test(CTestTestScheduler ${CMAKE_CTEST_COMMAND}
  2649. -S "${CMake_BINARY_DIR}/Tests/CTestTestScheduler/test.cmake" -V
  2650. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestScheduler/testOutput.log"
  2651. )
  2652. set_tests_properties(CTestTestScheduler PROPERTIES
  2653. PASS_REGULAR_EXPRESSION "Start 1.*Start 2.*Start 3.*Start 4.*Start 4.*Start 3.*Start 2.*Start 1"
  2654. RESOURCE_LOCK "CostData")
  2655. configure_file(
  2656. "${CMake_SOURCE_DIR}/Tests/CTestTestCostSerial/test.cmake.in"
  2657. "${CMake_BINARY_DIR}/Tests/CTestTestCostSerial/test.cmake"
  2658. @ONLY ESCAPE_QUOTES)
  2659. add_test(CTestTestCostSerial ${CMAKE_CTEST_COMMAND}
  2660. -S "${CMake_BINARY_DIR}/Tests/CTestTestCostSerial/test.cmake" -V
  2661. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestCostSerial/testOutput.log"
  2662. )
  2663. set_tests_properties(CTestTestCostSerial PROPERTIES
  2664. PASS_REGULAR_EXPRESSION "Start 2.*Start 3.*Start 1.*Start 2.*Start 3.*Start 1"
  2665. RESOURCE_LOCK "CostData")
  2666. configure_file(
  2667. "${CMake_SOURCE_DIR}/Tests/CTestTestStopTime/test.cmake.in"
  2668. "${CMake_BINARY_DIR}/Tests/CTestTestStopTime/test.cmake"
  2669. @ONLY ESCAPE_QUOTES)
  2670. configure_file(
  2671. "${CMake_SOURCE_DIR}/Tests/CTestTestStopTime/GetDate.cmake"
  2672. "${CMake_BINARY_DIR}/Tests/CTestTestStopTime/GetDate.cmake"
  2673. COPYONLY)
  2674. add_test(CTestTestStopTime ${CMAKE_CTEST_COMMAND}
  2675. -S "${CMake_BINARY_DIR}/Tests/CTestTestStopTime/test.cmake" -V
  2676. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestStopTime/testOutput.log"
  2677. )
  2678. set_tests_properties(CTestTestStopTime PROPERTIES
  2679. PASS_REGULAR_EXPRESSION "The stop time has been passed")
  2680. configure_file(
  2681. "${CMake_SOURCE_DIR}/Tests/CTestTestSubdir/test.cmake.in"
  2682. "${CMake_BINARY_DIR}/Tests/CTestTestSubdir/test.cmake"
  2683. @ONLY ESCAPE_QUOTES)
  2684. add_test(CTestTestSubdir ${CMAKE_CTEST_COMMAND}
  2685. -S "${CMake_BINARY_DIR}/Tests/CTestTestSubdir/test.cmake" -V
  2686. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestSubdir/testOutput.log"
  2687. )
  2688. #make sure all 3 subdirs were added
  2689. set_tests_properties(CTestTestSubdir PROPERTIES
  2690. PASS_REGULAR_EXPRESSION "0 tests failed out of 3")
  2691. configure_file(
  2692. "${CMake_SOURCE_DIR}/Tests/CTestTestTimeout/test.cmake.in"
  2693. "${CMake_BINARY_DIR}/Tests/CTestTestTimeout/test.cmake"
  2694. @ONLY ESCAPE_QUOTES)
  2695. add_test(CTestTestTimeout ${CMAKE_CTEST_COMMAND}
  2696. -C "\${CTestTest_CONFIG}"
  2697. -S "${CMake_BINARY_DIR}/Tests/CTestTestTimeout/test.cmake" -V
  2698. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestTimeout/testOutput.log"
  2699. )
  2700. set_tests_properties(CTestTestTimeout PROPERTIES
  2701. PASS_REGULAR_EXPRESSION "TestTimeout *\\.+ *\\*\\*\\*Timeout.*TestSleep *\\.+ *Passed.*timeout correctly killed child")
  2702. add_test(
  2703. NAME CTestTestRerunFailed
  2704. COMMAND ${CMAKE_CTEST_COMMAND} --rerun-failed)
  2705. set_tests_properties(CTestTestRerunFailed PROPERTIES
  2706. PASS_REGULAR_EXPRESSION "1/1 Test #1: TestTimeout" DEPENDS CTestTestTimeout
  2707. WORKING_DIRECTORY ${CMake_BINARY_DIR}/Tests/CTestTestTimeout)
  2708. configure_file(
  2709. "${CMake_SOURCE_DIR}/Tests/CTestTestZeroTimeout/test.cmake.in"
  2710. "${CMake_BINARY_DIR}/Tests/CTestTestZeroTimeout/test.cmake"
  2711. @ONLY ESCAPE_QUOTES)
  2712. add_test(CTestTestZeroTimeout ${CMAKE_CTEST_COMMAND}
  2713. -S "${CMake_BINARY_DIR}/Tests/CTestTestZeroTimeout/test.cmake" -V
  2714. --output-log
  2715. "${CMake_BINARY_DIR}/Tests/CTestTestZeroTimeout/testOutput.log")
  2716. set_tests_properties(CTestTestZeroTimeout PROPERTIES
  2717. FAIL_REGULAR_EXPRESSION "\\*\\*\\*Timeout")
  2718. configure_file(
  2719. "${CMake_SOURCE_DIR}/Tests/CTestTestDepends/test.cmake.in"
  2720. "${CMake_BINARY_DIR}/Tests/CTestTestDepends/test.cmake"
  2721. @ONLY ESCAPE_QUOTES)
  2722. add_test(CTestTestDepends ${CMAKE_CTEST_COMMAND}
  2723. -C "\${CTestTest_CONFIG}"
  2724. -S "${CMake_BINARY_DIR}/Tests/CTestTestDepends/test.cmake" -V
  2725. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestDepends/testOutput.log"
  2726. )
  2727. configure_file(
  2728. "${CMake_SOURCE_DIR}/Tests/CTestTestCycle/test.cmake.in"
  2729. "${CMake_BINARY_DIR}/Tests/CTestTestCycle/test.cmake"
  2730. @ONLY ESCAPE_QUOTES)
  2731. add_test(CTestTestCycle ${CMAKE_CTEST_COMMAND}
  2732. -C "\${CTestTest_CONFIG}"
  2733. -S "${CMake_BINARY_DIR}/Tests/CTestTestCycle/test.cmake" -V
  2734. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestCycle/testOutput.log"
  2735. )
  2736. set_tests_properties(CTestTestCycle PROPERTIES
  2737. PASS_REGULAR_EXPRESSION "a cycle exists in the test dependency graph")
  2738. configure_file(
  2739. "${CMake_SOURCE_DIR}/Tests/CTestTestRunScript/test.cmake.in"
  2740. "${CMake_BINARY_DIR}/Tests/CTestTestRunScript/test.cmake"
  2741. @ONLY ESCAPE_QUOTES)
  2742. configure_file(
  2743. "${CMake_SOURCE_DIR}/Tests/CTestTestRunScript/hello.cmake.in"
  2744. "${CMake_BINARY_DIR}/Tests/CTestTestRunScript/hello.cmake"
  2745. @ONLY ESCAPE_QUOTES)
  2746. add_test(CTestTestRunScript ${CMAKE_CTEST_COMMAND}
  2747. -S "${CMake_BINARY_DIR}/Tests/CTestTestRunScript/test.cmake" -V
  2748. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestRunScript/testOutput.log"
  2749. )
  2750. add_test(CTestTestShowOnly ${CMAKE_CTEST_COMMAND} -N)
  2751. add_test(CTestBatchTest ${CMAKE_CTEST_COMMAND} -B)
  2752. configure_file(
  2753. "${CMake_SOURCE_DIR}/Tests/CTestTestFdSetSize/test.cmake.in"
  2754. "${CMake_BINARY_DIR}/Tests/CTestTestFdSetSize/test.cmake"
  2755. @ONLY ESCAPE_QUOTES)
  2756. add_test(CTestTestFdSetSize ${CMAKE_CTEST_COMMAND}
  2757. -S "${CMake_BINARY_DIR}/Tests/CTestTestFdSetSize/test.cmake" -j20 -V --timeout 120
  2758. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestFdSetSize/testOutput.log"
  2759. )
  2760. if (CMAKE_TESTS_CDASH_SERVER)
  2761. set(regex "^([^:]+)://([^/]+)(.*)$")
  2762. if ("${CMAKE_TESTS_CDASH_SERVER}" MATCHES "${regex}")
  2763. set(protocol "${CMAKE_MATCH_1}")
  2764. set(server "${CMAKE_MATCH_2}")
  2765. set(path "${CMAKE_MATCH_3}")
  2766. else ()
  2767. set(protocol "http")
  2768. set(server "open.cdash.org")
  2769. set(path "")
  2770. message("warning: CMAKE_TESTS_CDASH_SERVER does not match expected regex...")
  2771. message(" ...using default url='${protocol}://${server}${path}' for CTestTest[23]")
  2772. endif ()
  2773. endif ()
  2774. if (CTEST_TEST_CTEST AND CMAKE_RUN_LONG_TESTS AND CMAKE_TESTS_CDASH_SERVER)
  2775. configure_file("${CMake_SOURCE_DIR}/Tests/CTestTest/test.cmake.in"
  2776. "${CMake_BINARY_DIR}/Tests/CTestTest/test.cmake" @ONLY ESCAPE_QUOTES)
  2777. add_test(CTestTest ${CMAKE_CTEST_COMMAND}
  2778. -S "${CMake_BINARY_DIR}/Tests/CTestTest/test.cmake" -V
  2779. --output-log "${CMake_BINARY_DIR}/Tests/CTestTest/testOutput.log"
  2780. )
  2781. configure_file("${CMake_SOURCE_DIR}/Tests/CTestTest2/test.cmake.in"
  2782. "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" @ONLY ESCAPE_QUOTES)
  2783. add_test(CTestTest2 ${CMAKE_CTEST_COMMAND}
  2784. -S "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" -V
  2785. --output-log "${CMake_BINARY_DIR}/Tests/CTestTest2/testOutput.log"
  2786. )
  2787. if("${CMAKE_GENERATOR}" MATCHES "Makefiles" OR "${CMAKE_GENERATOR}" MATCHES "Ninja")
  2788. configure_file("${CMake_SOURCE_DIR}/Tests/CTestTestLaunchers/test.cmake.in"
  2789. "${CMake_BINARY_DIR}/Tests/CTestTestLaunchers/test.cmake" @ONLY ESCAPE_QUOTES)
  2790. add_test(CTestTestLaunchers ${CMAKE_CTEST_COMMAND}
  2791. -S "${CMake_BINARY_DIR}/Tests/CTestTestLaunchers/test.cmake" -V
  2792. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestLaunchers/testOutput.log"
  2793. )
  2794. set_tests_properties(CTestTestLaunchers PROPERTIES
  2795. PASS_REGULAR_EXPRESSION "CTEST_TEST_LAUNCHER_SUCCESS")
  2796. endif()
  2797. configure_file("${CMake_SOURCE_DIR}/Tests/CTestTestChecksum/test.cmake.in"
  2798. "${CMake_BINARY_DIR}/Tests/CTestTestChecksum/test.cmake" @ONLY
  2799. ESCAPE_QUOTES)
  2800. add_test(CTestTestChecksum ${CMAKE_CTEST_COMMAND}
  2801. -S "${CMake_BINARY_DIR}/Tests/CTestTestChecksum/test.cmake" -V
  2802. --output-log
  2803. "${CMake_BINARY_DIR}/Tests/CTestTestChecksum/testOutput.log"
  2804. )
  2805. set_tests_properties(CTestTestChecksum PROPERTIES PASS_REGULAR_EXPRESSION
  2806. "Submission failed: Checksum failed for file")
  2807. # these tests take a long time, make sure they have it
  2808. # if timeouts have not already been set
  2809. get_test_property(CTestTest TIMEOUT PREVIOUS_TIMEOUT)
  2810. if ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND)
  2811. set_tests_properties ( CTestTest
  2812. PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT})
  2813. endif ()
  2814. get_test_property(CTestTest2 TIMEOUT PREVIOUS_TIMEOUT)
  2815. if ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND)
  2816. set_tests_properties ( CTestTest2
  2817. PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT})
  2818. endif ()
  2819. endif ()
  2820. if("${CMAKE_GENERATOR}" MATCHES Xcode)
  2821. set(CMAKE_SKIP_BOOTSTRAP_TEST 1)
  2822. endif()
  2823. if(EXISTS "${CMake_BINARY_DIR}/CMakeLists.txt")
  2824. # If there is CMakeLists.txt in the binary tree, assume in-source build
  2825. set(CMAKE_SKIP_BOOTSTRAP_TEST 1)
  2826. endif()
  2827. set(bootstrap "")
  2828. if(CMAKE_RUN_LONG_TESTS AND NOT CMAKE_SKIP_BOOTSTRAP_TEST)
  2829. if(UNIX)
  2830. set(bootstrap ${CMake_SOURCE_DIR}/bootstrap)
  2831. elseif(MSYS)
  2832. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/bootstrap.bat.in
  2833. ${CMAKE_CURRENT_BINARY_DIR}/bootstrap.bat @ONLY)
  2834. set(bootstrap ${CMAKE_CURRENT_BINARY_DIR}/bootstrap.bat)
  2835. endif()
  2836. endif()
  2837. if(bootstrap)
  2838. add_test(NAME BootstrapTest
  2839. COMMAND ${CMAKE_CMAKE_COMMAND}
  2840. -D "bootstrap=${bootstrap}"
  2841. -D "bin_dir=${CMake_BINARY_DIR}/Tests/BootstrapTest"
  2842. -P ${CMAKE_CURRENT_SOURCE_DIR}/BootstrapTest.cmake
  2843. )
  2844. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BootstrapTest")
  2845. # This test will use all processors.
  2846. set_tests_properties(BootstrapTest PROPERTIES RUN_SERIAL 1)
  2847. # provide more time for the bootstrap test
  2848. get_test_property(BootstrapTest TIMEOUT PREVIOUS_TIMEOUT)
  2849. if ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND)
  2850. set_tests_properties ( BootstrapTest
  2851. PROPERTIES TIMEOUT 5400)
  2852. endif ()
  2853. endif()
  2854. if(CMAKE_Fortran_COMPILER)
  2855. add_test(Fortran ${CMAKE_CTEST_COMMAND}
  2856. --build-and-test
  2857. "${CMake_SOURCE_DIR}/Tests/Fortran"
  2858. "${CMake_BINARY_DIR}/Tests/Fortran"
  2859. ${build_generator_args}
  2860. --build-project testf
  2861. --build-two-config
  2862. --build-options ${build_options}
  2863. --test-command testf)
  2864. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Fortran")
  2865. if(CMAKE_Fortran_COMPILER_SUPPORTS_F90)
  2866. add_test(FortranModules ${CMAKE_CTEST_COMMAND}
  2867. --build-and-test
  2868. "${CMake_SOURCE_DIR}/Tests/FortranModules"
  2869. "${CMake_BINARY_DIR}/Tests/FortranModules"
  2870. ${build_generator_args}
  2871. --build-project FortranModules
  2872. --build-options ${build_options}
  2873. -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM}
  2874. -DCMake_TEST_Fortran_SUBMODULES:BOOL=${CMake_TEST_Fortran_SUBMODULES}
  2875. )
  2876. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/FortranModules")
  2877. endif()
  2878. # FortranCInterface tests.
  2879. if(UNIX)
  2880. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/FortranC/Flags.cmake.in
  2881. ${CMAKE_CURRENT_BINARY_DIR}/FortranC/Flags.cmake @ONLY)
  2882. add_test(FortranC.Flags ${CMAKE_CMAKE_COMMAND} -P
  2883. ${CMAKE_CURRENT_BINARY_DIR}/FortranC/Flags.cmake)
  2884. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/FortranC/Flags")
  2885. else()
  2886. add_test(FortranC ${CMAKE_CTEST_COMMAND}
  2887. --build-and-test
  2888. "${CMake_SOURCE_DIR}/Tests/FortranC"
  2889. "${CMake_BINARY_DIR}/Tests/FortranC"
  2890. ${build_generator_args}
  2891. --build-project FortranC
  2892. --build-two-config
  2893. --build-options ${build_options}
  2894. --test-command CMakeFiles/FortranCInterface/FortranCInterface)
  2895. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/FortranC")
  2896. endif()
  2897. endif()
  2898. find_package(Java COMPONENTS Development QUIET)
  2899. if(Java_JAVA_EXECUTABLE AND Java_JAVAC_EXECUTABLE AND Java_JAR_EXECUTABLE AND NOT MINGW
  2900. AND NOT "${CMAKE_GENERATOR}" MATCHES "Xcode")
  2901. set(JavaExportImport_BUILD_OPTIONS -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM})
  2902. ADD_TEST_MACRO(JavaExportImport JavaExportImport)
  2903. get_filename_component(JNIPATH ${JAVA_COMPILE} PATH)
  2904. find_file(JNI_H jni.h
  2905. "${JNIPATH}/../include"
  2906. "${JNIPATH}/../java/include")
  2907. if(JNI_H AND EXISTS "${JNI_H}") # in case jni.h is a broken symlink
  2908. file(READ "${JNI_H}" JNI_FILE)
  2909. if("${JNI_FILE}" MATCHES "JDK1_2")
  2910. add_test(Java.Jar ${CMAKE_CTEST_COMMAND}
  2911. --build-and-test
  2912. "${CMake_SOURCE_DIR}/Tests/Java"
  2913. "${CMake_BINARY_DIR}/Tests/JavaJar"
  2914. ${build_generator_args}
  2915. --build-project hello
  2916. --build-target hello
  2917. --build-two-config
  2918. --build-run-dir "${CMake_BINARY_DIR}/Tests/JavaJar/"
  2919. --build-options ${build_options}
  2920. --test-command ${JAVA_RUNTIME} -classpath hello.jar HelloWorld)
  2921. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJar")
  2922. add_test(Java.JarSourceList ${CMAKE_CTEST_COMMAND}
  2923. --build-and-test
  2924. "${CMake_SOURCE_DIR}/Tests/Java"
  2925. "${CMake_BINARY_DIR}/Tests/JavaJarSourceList"
  2926. ${build_generator_args}
  2927. --build-project hello
  2928. --build-target hello2
  2929. --build-two-config
  2930. --build-run-dir "${CMake_BINARY_DIR}/Tests/JavaJarSourceList/"
  2931. --build-options ${build_options}
  2932. --test-command ${JAVA_RUNTIME} -classpath hello2.jar HelloWorld)
  2933. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJarSourceList")
  2934. # For next test, java tool must have same architecture as toolchain
  2935. math(EXPR _object_mode "${CMAKE_SIZEOF_VOID_P} * 8")
  2936. execute_process(
  2937. COMMAND "${Java_JAVA_EXECUTABLE}" -d${_object_mode} -version
  2938. OUTPUT_QUIET ERROR_QUIET RESULT_VARIABLE _result
  2939. )
  2940. if(_result EQUAL 0)
  2941. if(CMAKE_CONFIGURATION_TYPES)
  2942. set (JAVAH_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaJavah/$<CONFIGURATION>)
  2943. else()
  2944. set (JAVAH_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaJavah)
  2945. endif()
  2946. add_test(NAME Java.Javah COMMAND ${CMAKE_CTEST_COMMAND}
  2947. --build-and-test
  2948. "${CMake_SOURCE_DIR}/Tests/JavaJavah"
  2949. "${CMake_BINARY_DIR}/Tests/JavaJavah"
  2950. ${build_generator_args}
  2951. --build-project helloJavah
  2952. --build-two-config
  2953. --build-run-dir "${CMake_BINARY_DIR}/Tests/JavaJavah/"
  2954. --build-options ${build_options}
  2955. --test-command ${JAVA_RUNTIME} -Djava.library.path=${JAVAH_LIBRARY_PATH} -classpath hello3.jar HelloWorld2)
  2956. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJavah")
  2957. endif()
  2958. endif()
  2959. endif()
  2960. endif()
  2961. # add some cross compiler tests, for now only with makefile based generators
  2962. if(CMAKE_GENERATOR MATCHES "Makefiles" OR CMAKE_GENERATOR MATCHES "KDevelop")
  2963. # if sdcc is found, build the SimpleCOnly project with sdcc
  2964. find_program(SDCC_EXECUTABLE sdcc)
  2965. mark_as_advanced(SDCC_EXECUTABLE)
  2966. if(SDCC_EXECUTABLE)
  2967. add_test(SimpleCOnly_sdcc ${CMAKE_CTEST_COMMAND}
  2968. --build-and-test
  2969. "${CMake_SOURCE_DIR}/Tests/SimpleCOnly"
  2970. "${CMake_BINARY_DIR}/Tests/SimpleCOnly_sdcc"
  2971. ${build_generator_args}
  2972. --build-project SimpleC
  2973. --build-options ${build_options}
  2974. "-DCMAKE_SYSTEM_NAME=Generic"
  2975. "-DCMAKE_C_COMPILER=${SDCC_EXECUTABLE}")
  2976. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SimpleCOnly_sdcc")
  2977. endif()
  2978. # If a Linux -> MinGW cross compiler is found then try it
  2979. find_program(MINGW_CC_LINUX2WIN_EXECUTABLE i586-mingw32msvc-gcc)
  2980. find_program(MINGW_CXX_LINUX2WIN_EXECUTABLE i586-mingw32msvc-g++)
  2981. find_program(MINGW_RC_LINUX2WIN_EXECUTABLE i586-mingw32msvc-windres)
  2982. mark_as_advanced(MINGW_CC_LINUX2WIN_EXECUTABLE MINGW_CXX_LINUX2WIN_EXECUTABLE MINGW_RC_LINUX2WIN_EXECUTABLE)
  2983. if(MINGW_CC_LINUX2WIN_EXECUTABLE AND MINGW_CXX_LINUX2WIN_EXECUTABLE AND MINGW_RC_LINUX2WIN_EXECUTABLE)
  2984. add_test(Simple_Mingw_Linux2Win ${CMAKE_CTEST_COMMAND}
  2985. --build-and-test
  2986. "${CMake_SOURCE_DIR}/Tests/Simple"
  2987. "${CMake_BINARY_DIR}/Tests/Simple_Mingw_Linux2Win"
  2988. ${build_generator_args}
  2989. --build-project Simple
  2990. --build-options ${build_options}
  2991. "-DCMAKE_SYSTEM_NAME=Windows"
  2992. "-DCMAKE_C_COMPILER=${MINGW_CC_LINUX2WIN_EXECUTABLE}"
  2993. "-DCMAKE_CXX_COMPILER=${MINGW_CXX_LINUX2WIN_EXECUTABLE}"
  2994. "-DCMAKE_RC_COMPILER=${MINGW_RC_LINUX2WIN_EXECUTABLE}"
  2995. )
  2996. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Simple_Mingw_Linux2Win")
  2997. endif()
  2998. endif()
  2999. if(CMAKE_TEST_PROJECT_CSE_DIR)
  3000. set(script "${CMAKE_TEST_PROJECT_CSE_DIR}/BuildProjectCSE.cmake")
  3001. if(NOT EXISTS "${script}")
  3002. set(script "${CMAKE_TEST_PROJECT_CSE_DIR}/cse_build.cmake")
  3003. endif()
  3004. if(NOT EXISTS "${script}")
  3005. message("warning: CMAKE_TEST_PROJECT_CSE_DIR set, but no build script found...")
  3006. endif()
  3007. add_test(BuildCSE ${CMAKE_CTEST_COMMAND} -V -S "${script}")
  3008. set_tests_properties(BuildCSE PROPERTIES TIMEOUT 5400)
  3009. endif()
  3010. if(CMAKE_TEST_PLPLOT_DIR)
  3011. add_test(plplot ${CMAKE_CTEST_COMMAND} -V -S ${CMAKE_TEST_PLPLOT_DIR}/../../EasyDashboardScripts/plplot.cmake )
  3012. set_tests_properties ( plplot PROPERTIES TIMEOUT 5400)
  3013. endif()
  3014. if(CMAKE_TEST_CHICKEN_DIR)
  3015. add_test(Chicken ${CMAKE_CTEST_COMMAND} -V -S ${CMAKE_TEST_CHICKEN_DIR}/../../EasyDashboardScripts/Chicken.cmake )
  3016. set_tests_properties ( Chicken PROPERTIES TIMEOUT 5400)
  3017. endif()
  3018. if(CMAKE_TEST_KDELIBS_ALPHA_1_DIR)
  3019. add_test(KDELibsAlpha1 ${CMAKE_CTEST_COMMAND} -V -S ${CMAKE_TEST_KDELIBS_ALPHA_1_DIR}/../../EasyDashboardScripts/kdelibs.cmake )
  3020. set_tests_properties ( KDELibsAlpha1 PROPERTIES TIMEOUT 5400)
  3021. endif()
  3022. # If this is not an in-source build, provide a target to wipe out
  3023. # all the test build directories.
  3024. if(NOT EXISTS "${CMake_BINARY_DIR}/CMakeLists.txt")
  3025. configure_file(${CMake_SOURCE_DIR}/Tests/test_clean.cmake.in
  3026. ${CMake_BINARY_DIR}/Tests/test_clean.cmake @ONLY)
  3027. add_custom_target(test_clean
  3028. COMMAND ${CMAKE_COMMAND} -P ${CMake_BINARY_DIR}/Tests/test_clean.cmake
  3029. COMMENT "Removing test build directories."
  3030. )
  3031. endif()
  3032. add_test(NAME CMakeWizardTest COMMAND cmake -i)
  3033. set_property(TEST CMakeWizardTest PROPERTY PASS_REGULAR_EXPRESSION
  3034. "The \"cmake -i\" wizard mode is no longer supported.")
  3035. # If the cache variable CMAKE_CONTRACT_PROJECTS is set
  3036. # then the dashboard will run a contract with CMake test of that
  3037. # name. For example CMAKE_CONTRACT_PROJECTS = vtk542 would run
  3038. # the vtk542 contract test.
  3039. # For each Contract test, the project should provide a directory
  3040. # with at least one CMakeLists.txt file that uses ExternalProject
  3041. # to download and configure the project. The directory should also
  3042. # contain a RunTest.cmake file that has a single set of the format:
  3043. # set(project_RUN_TEST testToRun)
  3044. # The testToRun should be a test executable that can be run to
  3045. # smoke test the build.
  3046. foreach(project ${CMAKE_CONTRACT_PROJECTS})
  3047. include(Contracts/${project}/RunTest.cmake)
  3048. ADD_TEST_MACRO(Contracts.${project}
  3049. ${${project}_RUN_TEST})
  3050. # Contract test timeout in seconds.
  3051. # Default to 6 hours.
  3052. if(DEFINED ${project}_TEST_TIMEOUT)
  3053. set(timeout ${${project}_TEST_TIMEOUT})
  3054. elseif(CMAKE_CONTRACT_TEST_TIMEOUT_DEFAULT)
  3055. set(timeout ${CMAKE_CONTRACT_TEST_TIMEOUT_DEFAULT})
  3056. else()
  3057. set(timeout 21600)
  3058. endif()
  3059. set_tests_properties(Contracts.${project} PROPERTIES TIMEOUT ${timeout})
  3060. endforeach()
  3061. if(TEST_CompileCommandOutput)
  3062. set(CompileCommandOutput_BUILD_OPTIONS
  3063. -DMAKE_SUPPORTS_SPACES=${MAKE_SUPPORTS_SPACES})
  3064. ADD_TEST_MACRO(CompileCommandOutput
  3065. "${CMake_BINARY_DIR}/Tests/CMakeLib/runcompilecommands")
  3066. endif()
  3067. add_test(IncludeDirectories ${CMAKE_CTEST_COMMAND}
  3068. --build-and-test
  3069. "${CMake_SOURCE_DIR}/Tests/IncludeDirectories"
  3070. "${CMake_BINARY_DIR}/Tests/IncludeDirectories"
  3071. --build-two-config
  3072. ${build_generator_args}
  3073. --build-project IncludeDirectories
  3074. --build-options ${build_options}
  3075. --test-command IncludeDirectories)
  3076. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/IncludeDirectories")
  3077. add_test(InterfaceLinkLibraries ${CMAKE_CTEST_COMMAND}
  3078. --build-and-test
  3079. "${CMake_SOURCE_DIR}/Tests/InterfaceLinkLibraries"
  3080. "${CMake_BINARY_DIR}/Tests/InterfaceLinkLibraries"
  3081. --build-two-config
  3082. ${build_generator_args}
  3083. --build-project InterfaceLinkLibraries
  3084. --build-options ${build_options}
  3085. --test-command InterfaceLinkLibraries)
  3086. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/InterfaceLinkLibraries")
  3087. if(NOT CMake_TEST_EXTERNAL_CMAKE)
  3088. add_subdirectory(CMakeTests)
  3089. endif()
  3090. endif()