CMakeLists.txt 130 KB

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