CMakeLists.txt 131 KB

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