CMakeLists.txt 132 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370
  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. # assume no resources building to test
  77. set(CMake_TEST_RESOURCES FALSE)
  78. # for windows and cygwin assume we have resources
  79. if(WIN32 OR CYGWIN)
  80. set(CMake_TEST_RESOURCES TRUE)
  81. endif()
  82. # for borland and watcom there is no resource support
  83. if(WATCOM OR BORLAND)
  84. set(CMake_TEST_RESOURCES FALSE)
  85. endif()
  86. set(build_generator_args
  87. --build-generator ${CMAKE_GENERATOR}
  88. )
  89. if(CMAKE_GENERATOR_PLATFORM)
  90. list(APPEND build_generator_args
  91. --build-generator-platform ${CMAKE_GENERATOR_PLATFORM}
  92. )
  93. endif()
  94. if(CMAKE_GENERATOR_TOOLSET)
  95. list(APPEND build_generator_args
  96. --build-generator-toolset ${CMAKE_GENERATOR_TOOLSET}
  97. )
  98. endif()
  99. set(build_options)
  100. if(CMake_TEST_EXPLICIT_MAKE_PROGRAM)
  101. list(APPEND build_options -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM})
  102. endif()
  103. # Look for rpmbuild to use for tests.
  104. # The tool does not work with spaces in the path.
  105. if(NOT CMAKE_CURRENT_BINARY_DIR MATCHES " ")
  106. find_program(RPMBUILD_EXECUTABLE NAMES rpmbuild)
  107. else()
  108. set(RPMBUILD_EXECUTABLE "RPMBUILD_EXECUTABLE-NOTFOUND")
  109. endif()
  110. if(RPMBUILD_EXECUTABLE)
  111. set(CPACK_BINARY_RPM ON)
  112. else()
  113. set(CPACK_BINARY_RPM OFF)
  114. endif()
  115. # Look for rpmbuild to use for tests.
  116. # The tool does not work with spaces in the path.
  117. find_program(DPKG_EXECUTABLE NAMES dpkg)
  118. if(DPKG_EXECUTABLE)
  119. set(CPACK_BINARY_DEB ON)
  120. else()
  121. set(CPACK_BINARY_DEB OFF)
  122. endif()
  123. #---------------------------------------------------------------------------
  124. # Add tests below here.
  125. if(NOT CMake_TEST_EXTERNAL_CMAKE)
  126. add_subdirectory(CMakeLib)
  127. endif()
  128. add_subdirectory(CMakeOnly)
  129. add_subdirectory(RunCMake)
  130. add_subdirectory(FindPackageModeMakefileTest)
  131. # Collect a list of all test build directories.
  132. set(TEST_BUILD_DIRS)
  133. # Should the long tests be run?
  134. option(CMAKE_RUN_LONG_TESTS
  135. "Should the long tests be run (such as Bootstrap)." ON)
  136. mark_as_advanced(CMAKE_RUN_LONG_TESTS)
  137. if (CMAKE_RUN_LONG_TESTS)
  138. option(CTEST_TEST_CTEST
  139. "Should the tests that run a full sub ctest process be run?"
  140. OFF)
  141. mark_as_advanced(CTEST_TEST_CTEST)
  142. endif ()
  143. # Should tests that use CVS be run?
  144. #
  145. set(do_cvs_tests 0)
  146. if(EXISTS ${CMAKE_ROOT}/Modules/FindCVS.cmake)
  147. find_package(CVS QUIET)
  148. else()
  149. find_program(CVS_EXECUTABLE NAMES cvs)
  150. endif()
  151. if(CVS_EXECUTABLE)
  152. set(do_cvs_tests 1)
  153. endif()
  154. if(do_cvs_tests AND NOT UNIX)
  155. if("${CVS_EXECUTABLE}" MATCHES "cygwin")
  156. set(do_cvs_tests 0)
  157. endif()
  158. endif()
  159. # Should CPack tests be run? By default, yes, but...
  160. #
  161. # Disable packaging test on Apple 10.3 and below. PackageMaker starts
  162. # DiskManagementTool as root and disowns it
  163. # (http://lists.apple.com/archives/installer-dev/2005/Jul/msg00005.html).
  164. # It is left holding open pipe handles and preventing ProcessUNIX from
  165. # detecting end-of-data even after its immediate child exits. Then
  166. # the test hangs until it times out and is killed. This is a
  167. # well-known bug in kwsys process execution that I would love to get
  168. # time to fix.
  169. #
  170. option(CTEST_TEST_CPACK
  171. "Should the tests that use '--build-target package' be run?"
  172. ON)
  173. mark_as_advanced(CTEST_TEST_CPACK)
  174. set(CTEST_TEST_OSX_ARCH 0)
  175. set(CMake_TEST_XCODE_VERSION 0)
  176. if(APPLE)
  177. execute_process(
  178. COMMAND sw_vers -productVersion
  179. OUTPUT_VARIABLE OSX_VERSION
  180. OUTPUT_STRIP_TRAILING_WHITESPACE
  181. )
  182. if(OSX_VERSION VERSION_LESS 10.4)
  183. message(STATUS "Forcing CTEST_TEST_CPACK=OFF on OSX < 10.4")
  184. message(STATUS "OSX_VERSION='${OSX_VERSION}'")
  185. set(CTEST_TEST_CPACK OFF)
  186. else()
  187. set(CTEST_TEST_OSX_ARCH 1)
  188. endif()
  189. if(XCODE_VERSION)
  190. set(CMake_TEST_XCODE_VERSION "${XCODE_VERSION}")
  191. else()
  192. execute_process(
  193. COMMAND xcodebuild -version
  194. OUTPUT_VARIABLE _version ERROR_VARIABLE _version
  195. )
  196. if(_version MATCHES "^Xcode ([0-9]+(\\.[0-9]+)*)")
  197. set(CMake_TEST_XCODE_VERSION "${CMAKE_MATCH_1}")
  198. endif()
  199. endif()
  200. if(CMAKE_OSX_SYSROOT)
  201. execute_process(
  202. COMMAND xcodebuild -sdk ${CMAKE_OSX_SYSROOT} -version ProductName
  203. OUTPUT_VARIABLE _stdout
  204. OUTPUT_STRIP_TRAILING_WHITESPACE
  205. ERROR_VARIABLE _stderr
  206. RESULT_VARIABLE _failed
  207. )
  208. if(NOT _failed)
  209. set(CMAKE_OSX_SDKPRODUCT "${_stdout}")
  210. endif()
  211. execute_process(
  212. COMMAND xcodebuild -sdk ${CMAKE_OSX_SYSROOT} -version SDKVersion
  213. OUTPUT_VARIABLE _stdout
  214. OUTPUT_STRIP_TRAILING_WHITESPACE
  215. ERROR_VARIABLE _stderr
  216. RESULT_VARIABLE _failed
  217. )
  218. if(NOT _failed)
  219. set(CMAKE_OSX_SDKVERSION "${_stdout}")
  220. endif()
  221. endif()
  222. endif()
  223. # Use 1500 or CTEST_TEST_TIMEOUT for long test timeout value,
  224. # whichever is greater.
  225. set(CMAKE_LONG_TEST_TIMEOUT 1500)
  226. if(CTEST_TEST_TIMEOUT)
  227. set(CMAKE_LONG_TEST_TIMEOUT ${CTEST_TEST_TIMEOUT})
  228. endif()
  229. if(CMAKE_LONG_TEST_TIMEOUT LESS 1500)
  230. set(CMAKE_LONG_TEST_TIMEOUT 1500)
  231. endif()
  232. add_test(NAME CMake.Copyright
  233. COMMAND cmake -P ${CMAKE_CURRENT_SOURCE_DIR}/CMakeCopyright.cmake)
  234. # add a bunch of standard build-and-test style tests
  235. ADD_TEST_MACRO(CommandLineTest CommandLineTest)
  236. ADD_TEST_MACRO(FindPackageTest FindPackageTest)
  237. ADD_TEST_MACRO(FindModulesExecuteAll FindModulesExecuteAll)
  238. ADD_TEST_MACRO(StringFileTest StringFileTest)
  239. ADD_TEST_MACRO(TryCompile TryCompile)
  240. ADD_TEST_MACRO(SystemInformation SystemInformation)
  241. ADD_TEST_MACRO(MathTest MathTest)
  242. ADD_TEST_MACRO(CompileFeatures CompileFeatures)
  243. ADD_TEST_MACRO(CMakeCommands.target_compile_features target_compile_features)
  244. if(CMake_TEST_RESOURCES)
  245. ADD_TEST_MACRO(VSResource VSResource)
  246. if (CMAKE_GENERATOR MATCHES "Ninja")
  247. add_test_macro(VSResourceNinjaForceRSP VSResourceNinjaForceRSP)
  248. endif ()
  249. endif()
  250. ADD_TEST_MACRO(MSManifest MSManifest)
  251. ADD_TEST_MACRO(Simple Simple)
  252. ADD_TEST_MACRO(PreOrder PreOrder)
  253. ADD_TEST_MACRO(MissingSourceFile MissingSourceFile)
  254. set_tests_properties(MissingSourceFile PROPERTIES
  255. PASS_REGULAR_EXPRESSION "CMake Error at CMakeLists.txt:3 \\(add_executable\\):[ \r\n]*Cannot find source file:[ \r\n]*DoesNotExist/MissingSourceFile.c")
  256. if(CMake_TEST_XCODE_VERSION AND CMAKE_OSX_SDKVERSION AND CMAKE_OSX_SDKPRODUCT)
  257. if((NOT CMake_TEST_XCODE_VERSION VERSION_LESS 6.1) AND
  258. ((NOT CMAKE_OSX_SDKPRODUCT STREQUAL "Mac OS X") OR
  259. (NOT CMAKE_OSX_SDKVERSION VERSION_LESS 10.10)))
  260. if(CMAKE_GENERATOR STREQUAL "Xcode")
  261. ADD_TEST_MACRO(SwiftMix SwiftMix)
  262. ADD_TEST_MACRO(SwiftOnly SwiftOnly)
  263. endif()
  264. endif()
  265. endif()
  266. if(CMAKE_Fortran_COMPILER)
  267. ADD_TEST_MACRO(FortranOnly FortranOnly)
  268. endif()
  269. # test Visual Studio GNU Fortran mixing with cmake_add_fortran_subdirectory
  270. # run this project if we have a working fortran compiler or
  271. # the test is enabled with CMAKE_TEST_CMAKE_ADD_FORTRAN cache variable.
  272. # If you enable the test, CMake should find the MinGW fortran install,
  273. # or in some cases you might need to set the PATH so that cmake can find
  274. # the gfortran from mingw.
  275. if(CMAKE_Fortran_COMPILER OR CMAKE_TEST_CMAKE_ADD_FORTRAN)
  276. set(CMAKE_SKIP_VSGNUFortran FALSE)
  277. # disable test for apple builds using ifort if they are building
  278. # more than one architecture, as ifort does not support that.
  279. if(APPLE AND (CMAKE_Fortran_COMPILER MATCHES ifort))
  280. list(LENGTH CMAKE_OSX_ARCHITECTURES len)
  281. if("${len}" GREATER 1)
  282. message(STATUS "Skip VSGNUFortran for ifort dual cpu mac build")
  283. set(CMAKE_SKIP_VSGNUFortran TRUE)
  284. endif()
  285. endif()
  286. if((CMAKE_C_COMPILER MATCHES lsb)
  287. AND (CMAKE_Fortran_COMPILER MATCHES ifort))
  288. message(STATUS "Skip VSGNUFortran for ifort and lsb compilers")
  289. set(CMAKE_SKIP_VSGNUFortran TRUE)
  290. endif()
  291. if(NOT CMAKE_SKIP_VSGNUFortran)
  292. ADD_TEST_MACRO(VSGNUFortran ${CMAKE_COMMAND} -P runtest.cmake)
  293. endif()
  294. endif()
  295. 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_FindLibRHash)
  1258. add_subdirectory(FindLibRHash)
  1259. endif()
  1260. if(CMake_TEST_FindLibUV)
  1261. add_subdirectory(FindLibUV)
  1262. endif()
  1263. if(CMake_TEST_FindLTTngUST)
  1264. add_subdirectory(FindLTTngUST)
  1265. endif()
  1266. if(CMake_TEST_FindOpenCL)
  1267. add_subdirectory(FindOpenCL)
  1268. endif()
  1269. if(CMake_TEST_FindOpenSSL)
  1270. add_subdirectory(FindOpenSSL)
  1271. endif()
  1272. if(CMake_TEST_FindPNG)
  1273. add_subdirectory(FindPNG)
  1274. endif()
  1275. if(CMake_TEST_FindTIFF)
  1276. add_subdirectory(FindTIFF)
  1277. endif()
  1278. if(CMake_TEST_FindVulkan)
  1279. add_subdirectory(FindVulkan)
  1280. endif()
  1281. if(CMake_TEST_FindXalanC)
  1282. add_subdirectory(FindXalanC)
  1283. endif()
  1284. if(CMake_TEST_FindXercesC)
  1285. add_subdirectory(FindXercesC)
  1286. endif()
  1287. add_subdirectory(FindThreads)
  1288. # Matlab module
  1289. if(CMake_TEST_FindMatlab)
  1290. ADD_TEST_MACRO(FindMatlab.basic_checks ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>)
  1291. ADD_TEST_MACRO(FindMatlab.versions_checks ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>)
  1292. ADD_TEST_MACRO(FindMatlab.components_checks ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>)
  1293. endif()
  1294. find_package(GTK2 QUIET)
  1295. if(GTK2_FOUND)
  1296. add_subdirectory(FindGTK2)
  1297. endif()
  1298. add_test(ExternalProject ${CMAKE_CTEST_COMMAND}
  1299. --build-and-test
  1300. "${CMake_SOURCE_DIR}/Tests/ExternalProject"
  1301. "${CMake_BINARY_DIR}/Tests/ExternalProject"
  1302. ${build_generator_args}
  1303. --build-project ExternalProjectTest
  1304. --build-exe-dir "${CMake_BINARY_DIR}/Tests/ExternalProject"
  1305. --force-new-ctest-process
  1306. --build-options ${build_options}
  1307. --test-command ${CMAKE_CTEST_COMMAND} -V
  1308. )
  1309. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProject")
  1310. set_tests_properties(ExternalProject PROPERTIES
  1311. TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT})
  1312. add_test(NAME ExternalProjectSubdir
  1313. COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
  1314. --build-and-test
  1315. "${CMake_SOURCE_DIR}/Tests/ExternalProjectSubdir"
  1316. "${CMake_BINARY_DIR}/Tests/ExternalProjectSubdir"
  1317. ${build_generator_args}
  1318. --build-project ExternalProjectSubdir
  1319. --force-new-ctest-process
  1320. --build-options ${build_options}
  1321. )
  1322. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProjectSubdir")
  1323. add_test(NAME ExternalProjectSourceSubdir
  1324. COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
  1325. --build-and-test
  1326. "${CMake_SOURCE_DIR}/Tests/ExternalProjectSourceSubdir"
  1327. "${CMake_BINARY_DIR}/Tests/ExternalProjectSourceSubdir"
  1328. ${build_generator_args}
  1329. --build-project ExternalProjectSourceSubdir
  1330. --force-new-ctest-process
  1331. --build-options ${build_options}
  1332. )
  1333. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProjectSourceSubdir")
  1334. add_test(ExternalProjectLocal ${CMAKE_CTEST_COMMAND}
  1335. --build-and-test
  1336. "${CMake_SOURCE_DIR}/Tests/ExternalProjectLocal"
  1337. "${CMake_BINARY_DIR}/Tests/ExternalProjectLocal"
  1338. ${build_generator_args}
  1339. --build-project ExternalProjectLocalTest
  1340. --build-exe-dir "${CMake_BINARY_DIR}/Tests/ExternalProjectLocal"
  1341. --force-new-ctest-process
  1342. --build-options ${build_options}
  1343. --test-command ${CMAKE_CTEST_COMMAND} -V
  1344. )
  1345. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProjectLocal")
  1346. set_tests_properties(ExternalProjectLocal PROPERTIES
  1347. TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT})
  1348. add_test(ExternalProjectUpdateSetup ${CMAKE_CTEST_COMMAND}
  1349. --build-and-test
  1350. "${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate"
  1351. "${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate"
  1352. ${build_generator_args}
  1353. --build-project ExternalProjectUpdateTest
  1354. --build-exe-dir "${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate"
  1355. --force-new-ctest-process
  1356. --build-options ${build_options}
  1357. --test-command ${CMAKE_CTEST_COMMAND} -V
  1358. )
  1359. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate")
  1360. set_tests_properties(ExternalProjectUpdateSetup PROPERTIES
  1361. TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT})
  1362. add_test(NAME ExternalProjectUpdate
  1363. COMMAND ${CMAKE_CMAKE_COMMAND}
  1364. -DExternalProjectUpdate_SOURCE_DIR:PATH=${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate
  1365. -DExternalProjectUpdate_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate
  1366. -DCMAKE_GENERATOR=${CMAKE_GENERATOR}
  1367. -DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
  1368. -DCMAKE_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET}
  1369. -DCMAKE_CTEST_COMMAND=${CMAKE_CTEST_COMMAND}
  1370. -P ${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake
  1371. )
  1372. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate")
  1373. set_tests_properties(ExternalProjectUpdate PROPERTIES
  1374. TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}
  1375. WORKING_DIRECTORY ${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate
  1376. DEPENDS ExternalProjectUpdateSetup )
  1377. # do each of the tutorial steps
  1378. foreach(STP RANGE 1 7)
  1379. add_test(TutorialStep${STP} ${CMAKE_CTEST_COMMAND}
  1380. --build-and-test
  1381. "${CMake_SOURCE_DIR}/Tests/Tutorial/Step${STP}"
  1382. "${CMake_BINARY_DIR}/Tests/Tutorial/Step${STP}"
  1383. --build-two-config
  1384. ${build_generator_args}
  1385. --build-project Tutorial
  1386. --build-options ${build_options}
  1387. --test-command Tutorial 25.0)
  1388. endforeach()
  1389. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Tutorial")
  1390. add_test(testing ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE}
  1391. --build-and-test
  1392. "${CMake_SOURCE_DIR}/Tests/Testing"
  1393. "${CMake_BINARY_DIR}/Tests/Testing"
  1394. ${build_generator_args}
  1395. --build-project Testing
  1396. --build-options ${build_options}
  1397. --test-command ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE}
  1398. )
  1399. set_tests_properties(testing PROPERTIES PASS_REGULAR_EXPRESSION "Passed")
  1400. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Testing")
  1401. add_test(wrapping ${CMAKE_CTEST_COMMAND}
  1402. --build-and-test
  1403. "${CMake_SOURCE_DIR}/Tests/Wrapping"
  1404. "${CMake_BINARY_DIR}/Tests/Wrapping"
  1405. ${build_generator_args}
  1406. --build-project Wrapping
  1407. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin"
  1408. --build-options ${build_options}
  1409. --test-command wrapping
  1410. )
  1411. add_test(qtwrapping ${CMAKE_CTEST_COMMAND}
  1412. --build-and-test
  1413. "${CMake_SOURCE_DIR}/Tests/Wrapping"
  1414. "${CMake_BINARY_DIR}/Tests/Wrapping"
  1415. ${build_generator_args}
  1416. --build-project Wrapping
  1417. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin"
  1418. --build-options ${build_options}
  1419. --test-command qtwrapping
  1420. )
  1421. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Wrapping")
  1422. add_test(testdriver1 ${CMAKE_CTEST_COMMAND}
  1423. --build-and-test
  1424. "${CMake_SOURCE_DIR}/Tests/TestDriver"
  1425. "${CMake_BINARY_DIR}/Tests/TestDriver"
  1426. ${build_generator_args}
  1427. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin"
  1428. --build-project TestDriverTest
  1429. --build-options ${build_options}
  1430. --test-command TestDriverTest test1
  1431. )
  1432. add_test(testdriver2 ${CMAKE_CTEST_COMMAND}
  1433. --build-and-test
  1434. "${CMake_SOURCE_DIR}/Tests/TestDriver"
  1435. "${CMake_BINARY_DIR}/Tests/TestDriver"
  1436. ${build_generator_args}
  1437. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin"
  1438. --build-project TestDriverTest
  1439. --build-options ${build_options}
  1440. --test-command TestDriverTest test2
  1441. )
  1442. add_test(testdriver3 ${CMAKE_CTEST_COMMAND}
  1443. --build-and-test
  1444. "${CMake_SOURCE_DIR}/Tests/TestDriver"
  1445. "${CMake_BINARY_DIR}/Tests/TestDriver"
  1446. ${build_generator_args}
  1447. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin"
  1448. --build-project TestDriverTest
  1449. --build-options ${build_options}
  1450. --test-command TestDriverTest subdir/test3
  1451. )
  1452. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/TestDriver")
  1453. add_test(Dependency ${CMAKE_CTEST_COMMAND}
  1454. --build-and-test
  1455. "${CMake_SOURCE_DIR}/Tests/Dependency"
  1456. "${CMake_BINARY_DIR}/Tests/Dependency"
  1457. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Dependency/Exec"
  1458. ${build_generator_args}
  1459. --build-project Dependency
  1460. --build-options ${build_options}
  1461. --test-command exec
  1462. )
  1463. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Dependency")
  1464. if(CMAKE_SYSTEM_NAME MATCHES syllable)
  1465. # RPATH isn't supported under Syllable, so the tests don't
  1466. # find their libraries. In order to fix that LIBRARY_OUTPUT_DIR
  1467. # in the tests would have to be adjusted to ${EXECUTABLE_OUTPUT_DIR}/lib .
  1468. # For now we just require on Syllable that the user adjusts the DLL_PATH
  1469. # environment variable, so except the two tests below all other tests will succeed.
  1470. set(_DLL_PATH "$ENV{DLL_PATH}")
  1471. if(NOT "${_DLL_PATH}" MATCHES "^(.*:)?\\@bindir\\@/\\.(:.*)?$")
  1472. 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")
  1473. endif()
  1474. if(NOT "${_DLL_PATH}" MATCHES "^(.*:)?\\@bindir\\@/\\.\\./lib(:.*)?$")
  1475. 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")
  1476. endif()
  1477. else()
  1478. add_test(JumpWithLibOut ${CMAKE_CTEST_COMMAND}
  1479. --build-and-test
  1480. "${CMake_SOURCE_DIR}/Tests/Jump"
  1481. "${CMake_BINARY_DIR}/Tests/Jump/WithLibOut"
  1482. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Jump/WithLibOut/Executable"
  1483. --build-project Jump
  1484. ${build_generator_args}
  1485. --build-options ${build_options}
  1486. -DLIBRARY_OUTPUT_PATH:PATH=${CMake_BINARY_DIR}/Tests/Jump/WithLibOut/Lib
  1487. --test-command jumpExecutable
  1488. )
  1489. add_test(JumpNoLibOut ${CMAKE_CTEST_COMMAND}
  1490. --build-and-test
  1491. "${CMake_SOURCE_DIR}/Tests/Jump"
  1492. "${CMake_BINARY_DIR}/Tests/Jump/NoLibOut"
  1493. --build-exe-dir "${CMake_BINARY_DIR}/Tests/Jump/NoLibOut/Executable"
  1494. --build-run-dir "${CMake_BINARY_DIR}/Tests/Jump/NoLibOut/Executable"
  1495. --build-project Jump
  1496. ${build_generator_args}
  1497. --build-options ${build_options}
  1498. --test-command jumpExecutable
  1499. )
  1500. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Jump")
  1501. add_test(Plugin ${CMAKE_CTEST_COMMAND}
  1502. --build-and-test
  1503. "${CMake_SOURCE_DIR}/Tests/Plugin"
  1504. "${CMake_BINARY_DIR}/Tests/Plugin"
  1505. ${build_generator_args}
  1506. --build-project Plugin
  1507. --build-two-config
  1508. --build-options ${build_options}
  1509. --test-command bin/example)
  1510. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Plugin")
  1511. if(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG)
  1512. ADD_TEST_MACRO(RuntimePath RuntimePath)
  1513. endif()
  1514. endif()
  1515. if(APPLE AND "${DARWIN_MAJOR_VERSION}" GREATER 9)
  1516. add_test(MacRuntimePath ${CMAKE_CTEST_COMMAND}
  1517. --build-and-test
  1518. "${CMake_SOURCE_DIR}/Tests/MacRuntimePath"
  1519. "${CMake_BINARY_DIR}/Tests/MacRuntimePath"
  1520. ${build_generator_args}
  1521. --build-project MacRuntimePath
  1522. --build-options ${build_options}
  1523. -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM}
  1524. )
  1525. endif()
  1526. if(CMake_TEST_XCODE_VERSION AND NOT CMake_TEST_XCODE_VERSION VERSION_LESS 5
  1527. AND OSX_VERSION MATCHES "^([0-9]+\\.[0-9]+)")
  1528. set(XCTest_BUILD_OPTIONS -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_MATCH_1} -DCMAKE_OSX_SYSROOT=macosx)
  1529. ADD_TEST_MACRO(XCTest ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> -V)
  1530. endif()
  1531. add_test(linkorder1 ${CMAKE_CTEST_COMMAND}
  1532. --build-and-test
  1533. "${CMake_SOURCE_DIR}/Tests/LinkLineOrder"
  1534. "${CMake_BINARY_DIR}/Tests/LinkLineOrder"
  1535. ${build_generator_args}
  1536. --build-project LinkLineOrder
  1537. --build-options ${build_options}
  1538. --test-command Exec1
  1539. )
  1540. add_test(linkorder2 ${CMAKE_CTEST_COMMAND}
  1541. --build-and-test
  1542. "${CMake_SOURCE_DIR}/Tests/LinkLineOrder"
  1543. "${CMake_BINARY_DIR}/Tests/LinkLineOrder"
  1544. ${build_generator_args}
  1545. --build-project LinkLineOrder
  1546. --build-options ${build_options}
  1547. --test-command Exec2
  1548. )
  1549. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LinkLineOrder")
  1550. set_tests_properties ( qtwrapping PROPERTIES DEPENDS wrapping)
  1551. set_tests_properties ( testdriver1 PROPERTIES DEPENDS qtwrapping)
  1552. set_tests_properties ( testdriver2 PROPERTIES DEPENDS testdriver1)
  1553. set_tests_properties ( testdriver3 PROPERTIES DEPENDS testdriver2)
  1554. set_tests_properties ( linkorder2 PROPERTIES DEPENDS linkorder1)
  1555. set_tests_properties ( SimpleInstall-Stage2 PROPERTIES DEPENDS SimpleInstall)
  1556. # Test static linking on toolchains known to support it.
  1557. if(CMAKE_C_COMPILER_ID STREQUAL "GNU"
  1558. AND NOT APPLE AND NOT WIN32 AND NOT CYGWIN
  1559. AND EXISTS "/usr/lib/libm.a")
  1560. add_test(LinkStatic ${CMAKE_CTEST_COMMAND}
  1561. --build-and-test
  1562. "${CMake_SOURCE_DIR}/Tests/LinkStatic"
  1563. "${CMake_BINARY_DIR}/Tests/LinkStatic"
  1564. ${build_generator_args}
  1565. --build-project LinkStatic
  1566. --build-options ${build_options}
  1567. -DMATH_LIBRARY:FILEPATH=/usr/lib/libm.a
  1568. --test-command LinkStatic
  1569. )
  1570. endif()
  1571. if(MAKE_SUPPORTS_SPACES AND NOT CMAKE_GENERATOR STREQUAL "Xcode")
  1572. add_test(SubDirSpaces ${CMAKE_CTEST_COMMAND}
  1573. --build-and-test
  1574. "${CMake_SOURCE_DIR}/Tests/SubDirSpaces"
  1575. "${CMake_BINARY_DIR}/Tests/SubDirSpaces"
  1576. --build-exe-dir
  1577. "${CMake_BINARY_DIR}/Tests/SubDirSpaces/Executable Sources"
  1578. ${build_generator_args}
  1579. --build-project SUBDIR
  1580. --build-options ${build_options}
  1581. --test-command test
  1582. "${CMake_BINARY_DIR}/Tests/SubDirSpaces/ShouldBeHere"
  1583. "${CMake_BINARY_DIR}/Tests/SubDirSpaces/testfromsubdir.obj"
  1584. )
  1585. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SubDirSpaces")
  1586. endif ()
  1587. if (WIN32)
  1588. add_test(SubDir ${CMAKE_CTEST_COMMAND}
  1589. --build-and-test
  1590. "${CMake_SOURCE_DIR}/Tests/SubDir"
  1591. "${CMake_BINARY_DIR}/Tests/SubDir"
  1592. --build-exe-dir "${CMake_BINARY_DIR}/Tests/SubDir/Executable"
  1593. ${build_generator_args}
  1594. --build-project SUBDIR
  1595. --build-options ${build_options}
  1596. --test-command test
  1597. "${CMake_BINARY_DIR}/Tests/SubDir/ShouldBeHere"
  1598. "${CMake_BINARY_DIR}/Tests/SubDir/testfromsubdir.obj"
  1599. )
  1600. else ()
  1601. add_test(SubDir ${CMAKE_CTEST_COMMAND}
  1602. --build-and-test
  1603. "${CMake_SOURCE_DIR}/Tests/SubDir"
  1604. "${CMake_BINARY_DIR}/Tests/SubDir"
  1605. --build-exe-dir "${CMake_BINARY_DIR}/Tests/SubDir/Executable"
  1606. ${build_generator_args}
  1607. --build-project SUBDIR
  1608. --build-options ${build_options}
  1609. --test-command test
  1610. "${CMake_BINARY_DIR}/Tests/SubDir/ShouldBeHere"
  1611. "${CMake_BINARY_DIR}/Tests/SubDir/testfromsubdir.o"
  1612. )
  1613. endif ()
  1614. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SubDir")
  1615. if(MSVC)
  1616. ADD_TEST_MACRO(ForceInclude foo)
  1617. ADD_TEST_MACRO(PDBDirectoryAndName myexe)
  1618. if(NOT CMAKE_C_COMPILER_ID STREQUAL "Clang")
  1619. ADD_TEST_MACRO(PrecompiledHeader foo)
  1620. endif()
  1621. endif()
  1622. if(MSVC OR
  1623. "${CMAKE_GENERATOR}" MATCHES "(MSYS|MinGW) Makefiles")
  1624. ADD_TEST_MACRO(ModuleDefinition example_exe)
  1625. endif()
  1626. ADD_TEST_MACRO(CheckCompilerRelatedVariables CheckCompilerRelatedVariables)
  1627. if("${CMAKE_GENERATOR}" MATCHES "Makefile")
  1628. add_test(MakeClean ${CMAKE_CTEST_COMMAND}
  1629. --build-and-test
  1630. "${CMake_SOURCE_DIR}/Tests/MakeClean"
  1631. "${CMake_BINARY_DIR}/Tests/MakeClean"
  1632. ${build_generator_args}
  1633. --build-project MakeClean
  1634. --build-exe-dir "${CMake_BINARY_DIR}/MakeClean"
  1635. --build-options ${build_options}
  1636. --test-command check_clean
  1637. )
  1638. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/MakeClean")
  1639. endif()
  1640. if(NOT DEFINED CTEST_RUN_MFC)
  1641. set(CTEST_RUN_MFC OFF)
  1642. if(MSVC)
  1643. set(CTEST_RUN_MFC ON)
  1644. # Look for evidence that this is a VCExpress build. If so, avoid
  1645. # the MFC test by default.
  1646. string(TOLOWER "${CMAKE_MAKE_PROGRAM}" mkprog)
  1647. if(mkprog MATCHES "vcexpress")
  1648. message(STATUS
  1649. "CMAKE_MAKE_PROGRAM indicates vcexpress, avoiding MFC test")
  1650. set(CTEST_RUN_MFC OFF)
  1651. endif()
  1652. # Since MSBuild might also be the "makeprogram" for a VCExpress
  1653. # build tree, use one more heuristic, too. The string representing
  1654. # the .vcproj file type contains "VCExpress" on machines where an
  1655. # express edition of VS was installed last:
  1656. if(CTEST_RUN_MFC)
  1657. execute_process(COMMAND cmd /c assoc .vcproj
  1658. OUTPUT_STRIP_TRAILING_WHITESPACE
  1659. OUTPUT_VARIABLE ov)
  1660. if(ov MATCHES "VCExpress")
  1661. message(STATUS
  1662. ".vcproj file association indicates VCExpress, avoiding MFC test")
  1663. set(CTEST_RUN_MFC OFF)
  1664. endif()
  1665. endif()
  1666. # For the Watcom WMake generator, avoid the MFC test by default.
  1667. if(CTEST_RUN_MFC)
  1668. if("${CMAKE_GENERATOR}" MATCHES "WMake")
  1669. message(STATUS
  1670. "using the Watcom WMake generator, avoiding MFC test")
  1671. set(CTEST_RUN_MFC OFF)
  1672. endif()
  1673. endif()
  1674. # Last resort, after quick checks are done. Do a try_compile, and avoid
  1675. # the MFC test if the simplest possible MFC app cannot be compiled.
  1676. if(CTEST_RUN_MFC AND NOT DEFINED HAVE_MFC)
  1677. configure_file(
  1678. ${CMAKE_CURRENT_SOURCE_DIR}/MFC/try_compile/CMakeLists.txt
  1679. ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile/CMakeLists.txt
  1680. COPYONLY
  1681. )
  1682. configure_file(
  1683. ${CMAKE_CURRENT_SOURCE_DIR}/MFC/mfc1/stdafx.cpp
  1684. ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile/stdafx.cpp
  1685. COPYONLY
  1686. )
  1687. configure_file(
  1688. ${CMAKE_CURRENT_SOURCE_DIR}/MFC/mfc1/stdafx.h
  1689. ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile/stdafx.h
  1690. COPYONLY
  1691. )
  1692. message(STATUS "Looking for MFC")
  1693. try_compile(HAVE_MFC
  1694. ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile/build
  1695. ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile
  1696. try_compile_mfc
  1697. OUTPUT_VARIABLE HAVE_MFC_OUTPUT)
  1698. if(HAVE_MFC)
  1699. message(STATUS "Looking for MFC - found")
  1700. set(HAVE_MFC 1 CACHE INTERNAL "Have MFC")
  1701. file(APPEND
  1702. ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
  1703. "Determining if MFC exists passed with the following output:\n"
  1704. "${HAVE_MFC_OUTPUT}\n\n")
  1705. else()
  1706. message(STATUS "Looking for MFC - not found")
  1707. set(HAVE_MFC "" CACHE INTERNAL "Have MFC")
  1708. file(APPEND
  1709. ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
  1710. "Determining if MFC exists failed with the following output:\n"
  1711. "${HAVE_MFC_OUTPUT}\n\n")
  1712. endif()
  1713. endif()
  1714. if(CTEST_RUN_MFC AND NOT HAVE_MFC)
  1715. message(STATUS
  1716. "cannot compile simplest ever MFC app, avoiding MFC test")
  1717. set(CTEST_RUN_MFC OFF)
  1718. endif()
  1719. endif()
  1720. endif()
  1721. if(CTEST_RUN_MFC)
  1722. add_test(MFC ${CMAKE_CTEST_COMMAND}
  1723. --build-and-test
  1724. "${CMake_SOURCE_DIR}/Tests/MFC"
  1725. "${CMake_BINARY_DIR}/Tests/MFC"
  1726. --build-two-config
  1727. ${build_generator_args}
  1728. --build-project mfc_driver
  1729. --build-options ${build_options}
  1730. --test-command ${CMAKE_CTEST_COMMAND}
  1731. -C \${CTEST_CONFIGURATION_TYPE} -VV)
  1732. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/MFC")
  1733. endif()
  1734. if(MSVC AND NOT MSVC_VERSION LESS 1310
  1735. AND NOT CMAKE_GENERATOR MATCHES "Visual Studio 7( |$)"
  1736. AND (NOT CMAKE_GENERATOR MATCHES "Visual Studio [89]( |$)"
  1737. OR CMAKE_SIZEOF_VOID_P EQUAL 4)
  1738. )
  1739. ADD_TEST_MACRO(VSMASM VSMASM)
  1740. endif()
  1741. if(${CMAKE_GENERATOR} MATCHES "Visual Studio")
  1742. if(NOT MSVC60)
  1743. ADD_TEST_MACRO(SBCS SBCS)
  1744. endif()
  1745. if(NOT "${CMAKE_GENERATOR}" MATCHES "Visual Studio [789]( |$)"
  1746. AND NOT CMAKE_GENERATOR_TOOLSET)
  1747. ADD_TEST_MACRO(VSWindowsFormsResx VSWindowsFormsResx)
  1748. endif()
  1749. add_test(VSExternalInclude ${CMAKE_CTEST_COMMAND}
  1750. --build-and-test
  1751. "${CMake_SOURCE_DIR}/Tests/VSExternalInclude"
  1752. "${CMake_BINARY_DIR}/Tests/VSExternalInclude"
  1753. --build-two-config
  1754. ${build_generator_args}
  1755. --build-project VSExternalInclude
  1756. --build-options ${build_options}
  1757. --test-command VSExternalInclude)
  1758. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSExternalInclude")
  1759. add_test(VSMidl ${CMAKE_CTEST_COMMAND}
  1760. --build-and-test
  1761. "${CMake_SOURCE_DIR}/Tests/VSMidl"
  1762. "${CMake_BINARY_DIR}/Tests/VSMidl"
  1763. --build-two-config
  1764. ${build_generator_args}
  1765. --build-project VSMidl
  1766. --build-options ${build_options}
  1767. --test-command VSMidl)
  1768. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSMidl")
  1769. if(CMake_TEST_DEVENV)
  1770. # The test (and tested property) works with .sln files, so it's skipped when:
  1771. # * cmake --build is set up to use MSBuild, since the MSBuild invocation does not use the .sln file
  1772. set(_last_test "")
  1773. foreach(config ${CMAKE_CONFIGURATION_TYPES})
  1774. add_test(NAME VSExcludeFromDefaultBuild-${config} COMMAND ${CMAKE_CTEST_COMMAND}
  1775. --build-and-test
  1776. "${CMake_SOURCE_DIR}/Tests/VSExcludeFromDefaultBuild"
  1777. "${CMake_BINARY_DIR}/Tests/VSExcludeFromDefaultBuild"
  1778. --build-config ${config}
  1779. --build-two-config
  1780. --build-generator ${CMAKE_GENERATOR}
  1781. --build-makeprogram ${CMake_TEST_DEVENV}
  1782. --build-generator-platform "${CMAKE_GENERATOR_PLATFORM}"
  1783. --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
  1784. --build-project VSExcludeFromDefaultBuild
  1785. --build-target install
  1786. --test-command ${CMAKE_COMMAND}
  1787. -D "activeConfig=${config}"
  1788. -D "allConfigs=${CMAKE_CONFIGURATION_TYPES}"
  1789. -D "dir=${CMake_BINARY_DIR}/Tests/VSExcludeFromDefaultBuild"
  1790. -P "${CMake_SOURCE_DIR}/Tests/VSExcludeFromDefaultBuild/ResultTest.cmake")
  1791. if(_last_test)
  1792. set_property(TEST VSExcludeFromDefaultBuild-${config} PROPERTY DEPENDS ${_last_test})
  1793. endif()
  1794. set(_last_test "VSExcludeFromDefaultBuild-${config}")
  1795. endforeach()
  1796. unset(_last_test)
  1797. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSExcludeFromDefaultBuild")
  1798. endif()
  1799. if(CMAKE_GENERATOR MATCHES "Visual Studio ([0-5]|[6-9][0-9])")
  1800. # This is Visual Studio 10 or above, so the default build tool is MSBuild.
  1801. add_test(NAME VSProjectInSubdir COMMAND ${CMAKE_CTEST_COMMAND}
  1802. --build-and-test
  1803. "${CMake_SOURCE_DIR}/Tests/VSProjectInSubdir"
  1804. "${CMake_BINARY_DIR}/Tests/VSProjectInSubdir"
  1805. --build-two-config
  1806. --build-generator ${CMAKE_GENERATOR}
  1807. --build-generator-platform "${CMAKE_GENERATOR_PLATFORM}"
  1808. --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
  1809. --build-project VSProjectInSubdir
  1810. --build-target test)
  1811. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSProjectInSubdir")
  1812. endif()
  1813. endif()
  1814. if(WIN32)
  1815. # Macro to search for available Windows CE SDKs in the windows Registry
  1816. macro(select_wince_sdk selected_reg selected_sdk)
  1817. if(CMAKE_HOST_WIN32)
  1818. execute_process(COMMAND reg QUERY "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows CE Tools\\SDKs"
  1819. OUTPUT_VARIABLE sdk_reg
  1820. ERROR_VARIABLE my_err)
  1821. string(REGEX REPLACE "HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Wow6432Node\\\\Microsoft\\\\Windows CE Tools\\\\SDKs\\\\" ";" sdk_list "${sdk_reg}")
  1822. list(LENGTH sdk_list sdk_list_len)
  1823. if (${sdk_list_len} GREATER 1)
  1824. list(GET sdk_list 1 _sdk) # The first entry is always empty due to the regex replace above
  1825. string(STRIP ${_sdk} _sdk) # Make sure there is no newline in the SDK name
  1826. endif()
  1827. # Build a key to be used by get_filename_component that is pointing to the SDK directory
  1828. set(_reg "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows CE Tools\\SDKs\\${_sdk}]")
  1829. # Set return values
  1830. set(${selected_reg} ${_reg})
  1831. set(${selected_sdk} ${_sdk})
  1832. endif(CMAKE_HOST_WIN32)
  1833. endmacro(select_wince_sdk)
  1834. set(reg_vs10 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0;InstallDir]")
  1835. set(reg_vs11 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0;InstallDir]")
  1836. set(reg_vs12 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\12.0;InstallDir]")
  1837. set(reg_vs14 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot10]")
  1838. set(reg_ws80 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.0;InstallationFolder]")
  1839. set(reg_ws81 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.1;InstallationFolder]")
  1840. set(reg_ws10_0 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\14.0\\Setup\\Build Tools for Windows 10;srcPath]")
  1841. set(reg_wp80 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\WindowsPhone\\v8.0;InstallationFolder]")
  1842. set(reg_wp81 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\WindowsPhone\\v8.1;InstallationFolder]")
  1843. select_wince_sdk(reg_wince wince_sdk)
  1844. set(reg_tegra "[HKEY_LOCAL_MACHINE\\SOFTWARE\\NVIDIA Corporation\\Nsight Tegra;sdkRoot]")
  1845. foreach(reg vs10 vs11 vs12 vs14 ws80 ws81 ws10_0 wp80 wp81 wince tegra)
  1846. get_filename_component(r "${reg_${reg}}" ABSOLUTE)
  1847. if(IS_DIRECTORY "${r}")
  1848. set(${reg} 1)
  1849. else()
  1850. set(${reg} 0)
  1851. endif()
  1852. endforeach()
  1853. endif()
  1854. get_filename_component(ntver "[HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion;CurrentVersion]" NAME)
  1855. if(WIN32 AND ntver VERSION_GREATER 6.1) # Windows >= 8.0
  1856. macro(add_test_VSWinStorePhone name generator systemName systemVersion)
  1857. add_test(NAME VSWinStorePhone.${name} COMMAND ${CMAKE_CTEST_COMMAND}
  1858. --build-and-test
  1859. "${CMake_SOURCE_DIR}/Tests/VSWinStorePhone"
  1860. "${CMake_BINARY_DIR}/Tests/VSWinStorePhone/${name}"
  1861. --build-generator "${generator}"
  1862. --build-project VSWinStorePhone
  1863. --build-config $<CONFIGURATION>
  1864. --build-options -DCMAKE_SYSTEM_NAME=${systemName}
  1865. -DCMAKE_SYSTEM_VERSION=${systemVersion}
  1866. )
  1867. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSWinStorePhone/${name}")
  1868. endmacro()
  1869. if(vs11 AND ws80)
  1870. add_test_VSWinStorePhone(vs11-store80-X86 "Visual Studio 11 2012" WindowsStore 8.0)
  1871. add_test_VSWinStorePhone(vs11-store80-ARM "Visual Studio 11 2012 ARM" WindowsStore 8.0)
  1872. add_test_VSWinStorePhone(vs11-store80-X64 "Visual Studio 11 2012 Win64" WindowsStore 8.0)
  1873. endif()
  1874. if(vs12 AND ws81)
  1875. add_test_VSWinStorePhone(vs12-store81-X86 "Visual Studio 12 2013" WindowsStore 8.1)
  1876. add_test_VSWinStorePhone(vs12-store81-ARM "Visual Studio 12 2013 ARM" WindowsStore 8.1)
  1877. add_test_VSWinStorePhone(vs12-store81-X64 "Visual Studio 12 2013 Win64" WindowsStore 8.1)
  1878. add_test(NAME VSXaml COMMAND ${CMAKE_CTEST_COMMAND}
  1879. --build-and-test
  1880. "${CMake_SOURCE_DIR}/Tests/VSXaml"
  1881. "${CMake_BINARY_DIR}/Tests/VSXaml"
  1882. --build-generator "Visual Studio 12 2013"
  1883. --build-project VSXaml
  1884. --build-config $<CONFIGURATION>
  1885. --build-options -DCMAKE_SYSTEM_NAME=WindowsStore
  1886. -DCMAKE_SYSTEM_VERSION=8.1
  1887. )
  1888. endif()
  1889. if(vs14 AND ws10_0)
  1890. add_test_VSWinStorePhone(vs14-store10_0-X86 "Visual Studio 14 2015" WindowsStore 10.0)
  1891. add_test_VSWinStorePhone(vs14-store10_0-ARM "Visual Studio 14 2015 ARM" WindowsStore 10.0)
  1892. add_test_VSWinStorePhone(vs14-store10_0-X64 "Visual Studio 14 2015 Win64" WindowsStore 10.0)
  1893. endif()
  1894. if(vs11 AND wp80)
  1895. add_test_VSWinStorePhone(vs11-phone80-X86 "Visual Studio 11 2012" WindowsPhone 8.0)
  1896. add_test_VSWinStorePhone(vs11-phone80-ARM "Visual Studio 11 2012 ARM" WindowsPhone 8.0)
  1897. endif()
  1898. if(vs12 AND wp81)
  1899. add_test_VSWinStorePhone(vs12-phone81-X86 "Visual Studio 12 2013" WindowsPhone 8.1)
  1900. add_test_VSWinStorePhone(vs12-phone81-ARM "Visual Studio 12 2013 ARM" WindowsPhone 8.1)
  1901. endif()
  1902. endif()
  1903. if(WIN32 AND wince)
  1904. macro(add_test_VSWinCE name generator systemName systemVersion generatorPlatform)
  1905. # TODO: Fix the tutorial to make it work in cross compile
  1906. # currently the MakeTable is build for target and can not be used on the host
  1907. # This happens in part 5 so we build only part 1-4 of the tutorial
  1908. foreach(STP RANGE 1 4)
  1909. add_test(NAME "TutorialStep${STP}.${name}" COMMAND ${CMAKE_CTEST_COMMAND}
  1910. --build-and-test
  1911. "${CMake_SOURCE_DIR}/Tests/Tutorial/Step${STP}"
  1912. "${CMake_BINARY_DIR}/Tests/Tutorial/Step${STP}_${name}"
  1913. --build-generator "${generator}"
  1914. --build-project Tutorial
  1915. --build-config $<CONFIGURATION>
  1916. --build-options -DCMAKE_SYSTEM_NAME=${systemName}
  1917. -DCMAKE_SYSTEM_VERSION=${systemVersion}
  1918. -DCMAKE_GENERATOR_PLATFORM=${generatorPlatform})
  1919. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Tutorial/Step${STP}_${name}")
  1920. endforeach()
  1921. endmacro()
  1922. if(vs11)
  1923. add_test_VSWinCE(vs11-ce80-ARM "Visual Studio 11 2012" WindowsCE 8.0 ${wince_sdk})
  1924. endif()
  1925. if(vs12)
  1926. add_test_VSWinCE(vs12-ce80-ARM "Visual Studio 12 2013" WindowsCE 8.0 ${wince_sdk})
  1927. endif()
  1928. endif()
  1929. if (CMake_TEST_GreenHillsMULTI)
  1930. macro(add_test_GhsMulti name primaryTarget bspName)
  1931. add_test(NAME GhsMulti.${name} COMMAND ${CMAKE_CTEST_COMMAND}
  1932. --build-and-test
  1933. "${CMake_SOURCE_DIR}/Tests/GhsMulti"
  1934. "${CMake_BINARY_DIR}/Tests/GhsMulti/${name}"
  1935. --build-generator "Green Hills MULTI"
  1936. --build-project ReturnNum
  1937. --build-config $<CONFIGURATION>
  1938. --build-options -DGHS_PRIMARY_TARGET=${primaryTarget}
  1939. -DGHS_BSP_NAME=${bspName}
  1940. )
  1941. endmacro ()
  1942. add_test_GhsMulti("arm_integrity_simarm" "arm_integrity.tgt" "simarm")
  1943. add_test_GhsMulti("arm64_integrity_simarm" "arm64_integrity.tgt" "simarm")
  1944. add_test(NAME GhsMulti.duplicate_source_filenames
  1945. COMMAND ${CMAKE_CTEST_COMMAND}
  1946. --build-and-test
  1947. "${CMake_SOURCE_DIR}/Tests/GhsMultiDuplicateSourceFilenames"
  1948. "${CMake_BINARY_DIR}/Tests/GhsMultiDuplicateSourceFilenames"
  1949. --build-generator "Green Hills MULTI"
  1950. --build-project ReturnNum
  1951. --build-config $<CONFIGURATION>
  1952. --build-options -DGHS_PRIMARY_TARGET="arm_integrity.tgt"
  1953. -DGHS_BSP_NAME="simarm"
  1954. )
  1955. endif ()
  1956. if(tegra AND NOT "${CMake_SOURCE_DIR};${CMake_BINARY_DIR}" MATCHES " ")
  1957. macro(add_test_VSNsightTegra name generator)
  1958. add_test(NAME VSNsightTegra.${name} COMMAND ${CMAKE_CTEST_COMMAND}
  1959. --build-and-test
  1960. "${CMake_SOURCE_DIR}/Tests/VSNsightTegra"
  1961. "${CMake_BINARY_DIR}/Tests/VSNsightTegra/${name}"
  1962. --build-generator "${generator}"
  1963. --build-project VSNsightTegra
  1964. --build-config $<CONFIGURATION>
  1965. --build-options -DCMAKE_SYSTEM_NAME=Android
  1966. )
  1967. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSNsightTegra/${name}")
  1968. endmacro()
  1969. if(vs10)
  1970. add_test_VSNsightTegra(vs10 "Visual Studio 10 2010")
  1971. endif()
  1972. if(vs11)
  1973. add_test_VSNsightTegra(vs11 "Visual Studio 11 2012")
  1974. endif()
  1975. if(vs12)
  1976. add_test_VSNsightTegra(vs12 "Visual Studio 12 2013")
  1977. endif()
  1978. if(vs14)
  1979. add_test_VSNsightTegra(vs14 "Visual Studio 14 2015")
  1980. endif()
  1981. endif()
  1982. if (APPLE)
  1983. if (CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
  1984. set(BundleTestInstallDir
  1985. "${CMake_BINARY_DIR}/Tests/BundleTest/InstallDirectory")
  1986. add_test(BundleTest ${CMAKE_CTEST_COMMAND}
  1987. --build-and-test
  1988. "${CMake_SOURCE_DIR}/Tests/BundleTest"
  1989. "${CMake_BINARY_DIR}/Tests/BundleTest"
  1990. --build-two-config
  1991. ${build_generator_args}
  1992. --build-project BundleTest
  1993. --build-target install
  1994. # --build-target package
  1995. --build-options ${build_options}
  1996. "-DCMAKE_INSTALL_PREFIX:PATH=${BundleTestInstallDir}"
  1997. "-DCMake_SOURCE_DIR:PATH=${CMake_SOURCE_DIR}"
  1998. --test-command
  1999. ${BundleTestInstallDir}/Applications/SecondBundleExe.app/Contents/MacOS/SecondBundleExe)
  2000. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BundleTest")
  2001. add_test(NAME CFBundleTest COMMAND ${CMAKE_CTEST_COMMAND}
  2002. --build-and-test
  2003. "${CMake_SOURCE_DIR}/Tests/CFBundleTest"
  2004. "${CMake_BINARY_DIR}/Tests/CFBundleTest"
  2005. --build-two-config
  2006. ${build_generator_args}
  2007. --build-project CFBundleTest
  2008. --build-config $<CONFIGURATION>
  2009. --build-options ${build_options}
  2010. --test-command
  2011. ${CMAKE_CMAKE_COMMAND} -DCTEST_CONFIGURATION_TYPE=$<CONFIGURATION>
  2012. -Ddir=${CMake_BINARY_DIR}/Tests/CFBundleTest
  2013. -Dgen=${CMAKE_GENERATOR}
  2014. -P ${CMake_SOURCE_DIR}/Tests/CFBundleTest/VerifyResult.cmake)
  2015. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CFBundleTest")
  2016. ADD_TEST_MACRO(ObjC++ ObjC++)
  2017. endif ()
  2018. endif ()
  2019. if(APPLE AND CTEST_TEST_CPACK)
  2020. add_test(BundleGeneratorTest ${CMAKE_CTEST_COMMAND}
  2021. --build-and-test
  2022. "${CMake_SOURCE_DIR}/Tests/BundleGeneratorTest"
  2023. "${CMake_BINARY_DIR}/Tests/BundleGeneratorTest"
  2024. --build-two-config
  2025. ${build_generator_args}
  2026. --build-project BundleGeneratorTest
  2027. --build-target package
  2028. --build-options ${build_options}
  2029. "-DCMAKE_INSTALL_PREFIX:PATH=${CMake_BINARY_DIR}/Tests/BundleGeneratorTest/InstallDirectory"
  2030. )
  2031. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BundleGeneratorTest")
  2032. endif()
  2033. add_test(WarnUnusedUnusedViaSet ${CMAKE_CTEST_COMMAND}
  2034. --build-and-test
  2035. "${CMake_SOURCE_DIR}/Tests/VariableUnusedViaSet"
  2036. "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaSet"
  2037. ${build_generator_args}
  2038. --build-noclean
  2039. --build-project WarnUnusedUnusedViaSet
  2040. --build-options ${build_options}
  2041. "--warn-unused-vars")
  2042. set_tests_properties(WarnUnusedUnusedViaSet PROPERTIES
  2043. PASS_REGULAR_EXPRESSION "unused variable \\(changing definition\\) 'UNUSED_VARIABLE'")
  2044. set_tests_properties(WarnUnusedUnusedViaSet PROPERTIES
  2045. FAIL_REGULAR_EXPRESSION "unused variable \\(unsetting\\) 'UNUSED_VARIABLE'")
  2046. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaSet")
  2047. add_test(WarnUnusedUnusedViaUnset ${CMAKE_CTEST_COMMAND}
  2048. --build-and-test
  2049. "${CMake_SOURCE_DIR}/Tests/VariableUnusedViaUnset"
  2050. "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaUnset"
  2051. ${build_generator_args}
  2052. --build-noclean
  2053. --build-project WarnUnusedUnusedViaUnset
  2054. --build-options ${build_options}
  2055. "--warn-unused-vars")
  2056. set_tests_properties(WarnUnusedUnusedViaUnset PROPERTIES
  2057. PASS_REGULAR_EXPRESSION "CMake Warning \\(dev\\) at CMakeLists.txt:7 \\(set\\):")
  2058. set_tests_properties(WarnUnusedUnusedViaUnset PROPERTIES
  2059. FAIL_REGULAR_EXPRESSION "CMakeLists.txt:5 \\(set\\):")
  2060. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaUnset")
  2061. if("${CMAKE_GENERATOR}" MATCHES "Makefile" AND NOT WIN32)
  2062. # Ninja does not support ADDITIONAL_MAKE_CLEAN_FILES and therefore fails
  2063. # this test. (See #13371)
  2064. # Apparently Visual Studio does not support it either. As the MakeClean
  2065. # test above is only run with the Makefiles generator, only run this
  2066. # test with the Makefiles generator also.
  2067. add_test(WarnUnusedCliUnused ${CMAKE_CTEST_COMMAND}
  2068. --build-and-test
  2069. "${CMake_SOURCE_DIR}/Tests/WarnUnusedCliUnused"
  2070. "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused"
  2071. ${build_generator_args}
  2072. --build-project WarnUnusedCliUnused
  2073. --build-options ${build_options}
  2074. "-DUNUSED_CLI_VARIABLE=Unused")
  2075. set_tests_properties(WarnUnusedCliUnused PROPERTIES
  2076. PASS_REGULAR_EXPRESSION "CMake Warning:.*Manually-specified variables were not used by the project:.* UNUSED_CLI_VARIABLE")
  2077. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused")
  2078. endif()
  2079. add_test(WarnUnusedCliUsed ${CMAKE_CTEST_COMMAND}
  2080. --build-and-test
  2081. "${CMake_SOURCE_DIR}/Tests/VariableUsage"
  2082. "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUsed"
  2083. ${build_generator_args}
  2084. --build-noclean
  2085. --build-project WarnUnusedCliUsed
  2086. --build-options ${build_options}
  2087. "-DUSED_VARIABLE=Usage proven")
  2088. set_tests_properties(WarnUnusedCliUsed PROPERTIES
  2089. PASS_REGULAR_EXPRESSION "Usage proven")
  2090. set_tests_properties(WarnUnusedCliUsed PROPERTIES
  2091. FAIL_REGULAR_EXPRESSION "CMake Warning: The variable, 'USED_VARIABLE'")
  2092. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUsed")
  2093. add_test(WarnUninitialized ${CMAKE_CTEST_COMMAND}
  2094. --build-and-test
  2095. "${CMake_SOURCE_DIR}/Tests/VariableUsage"
  2096. "${CMake_BINARY_DIR}/Tests/WarnUninitialized"
  2097. ${build_generator_args}
  2098. --build-noclean
  2099. --build-project WarnUninitialized
  2100. --build-options ${build_options}
  2101. "--warn-uninitialized")
  2102. set_tests_properties(WarnUninitialized PROPERTIES
  2103. PASS_REGULAR_EXPRESSION "uninitialized variable 'USED_VARIABLE'")
  2104. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUninitialized")
  2105. add_test(TestsWorkingDirectory
  2106. ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE}
  2107. --build-and-test
  2108. "${CMake_SOURCE_DIR}/Tests/TestsWorkingDirectory"
  2109. "${CMake_BINARY_DIR}/Tests/TestsWorkingDirectory"
  2110. ${build_generator_args}
  2111. --build-project TestsWorkingDirectoryProj
  2112. --build-exe-dir "${CMake_BINARY_DIR}/Tests/TestsWorkingDirectory"
  2113. --force-new-ctest-process
  2114. --build-options ${build_options}
  2115. --test-command ${CMAKE_CTEST_COMMAND} -V -C \${CTEST_CONFIGURATION_TYPE}
  2116. )
  2117. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/TestsWorkingDirectory")
  2118. # Make sure CTest can handle a test with no newline in output.
  2119. add_test(CTest.NoNewline
  2120. ${CMAKE_CMAKE_COMMAND} -E echo_append "This line has no newline!")
  2121. # A simple test for ctest in script mode
  2122. configure_file("${CMake_SOURCE_DIR}/Tests/CTestScriptMode/CTestTestScriptMode.cmake.in"
  2123. "${CMake_BINARY_DIR}/Tests/CTestScriptMode/CTestTestScriptMode.cmake" @ONLY)
  2124. # add_test(CTest.ScriptMode ${CMAKE_CTEST_COMMAND}
  2125. # -S "${CMake_BINARY_DIR}/Tests/CTestScriptMode/CTestTestScriptMode.cmake"
  2126. # )
  2127. # A test for ctest_build() with targets in subdirectories
  2128. set(ctest_configure_options)
  2129. if(CMAKE_GENERATOR_PLATFORM)
  2130. list(APPEND ctest_configure_options -A ${CMAKE_GENERATOR_PLATFORM})
  2131. endif()
  2132. if(CMAKE_GENERATOR_TOOLSET)
  2133. list(APPEND ctest_configure_options -T ${CMAKE_GENERATOR_TOOLSET})
  2134. endif()
  2135. if(CMake_TEST_EXPLICIT_MAKE_PROGRAM)
  2136. list(APPEND ctest_configure_options -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM})
  2137. endif()
  2138. configure_file("${CMake_SOURCE_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in"
  2139. "${CMake_BINARY_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake" @ONLY)
  2140. unset(ctest_configure_options)
  2141. add_test(CTest.BuildCommand.ProjectInSubdir
  2142. ${CMAKE_CTEST_COMMAND} -S "${CMake_BINARY_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake")
  2143. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CTestBuildCommandProjectInSubdir/Nested")
  2144. set(CTEST_TEST_UPDATE 1)
  2145. if(CTEST_TEST_UPDATE)
  2146. # Test CTest Update with Subversion
  2147. find_package(Subversion QUIET)
  2148. if(Subversion_FOUND)
  2149. get_filename_component(_Subversion_BIN_DIR
  2150. ${Subversion_SVN_EXECUTABLE} PATH)
  2151. find_program(Subversion_SVNADMIN_EXECUTABLE svnadmin
  2152. HINTS ${_Subversion_BIN_DIR}
  2153. )
  2154. mark_as_advanced(Subversion_SVNADMIN_EXECUTABLE)
  2155. if(NOT Subversion_SVNADMIN_EXECUTABLE)
  2156. set(Subversion_FOUND FALSE)
  2157. endif()
  2158. endif()
  2159. if(Subversion_FOUND)
  2160. set(CTestUpdateSVN_DIR "CTest UpdateSVN")
  2161. configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateSVN.cmake.in"
  2162. "${CMake_BINARY_DIR}/Tests/CTestUpdateSVN.cmake" @ONLY)
  2163. add_test(CTest.UpdateSVN ${CMAKE_CMAKE_COMMAND}
  2164. -P "${CMake_BINARY_DIR}/Tests/CTestUpdateSVN.cmake"
  2165. )
  2166. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateSVN_DIR}")
  2167. endif()
  2168. # Test CTest Update with CVS
  2169. if(EXISTS ${CMAKE_ROOT}/Modules/FindCVS.cmake)
  2170. find_package(CVS QUIET)
  2171. else()
  2172. find_program(CVS_EXECUTABLE NAMES cvs)
  2173. set(CVS_FOUND ${CVS_EXECUTABLE})
  2174. endif()
  2175. set(CTEST_TEST_UPDATE_CVS ${CVS_FOUND})
  2176. if(CTEST_TEST_UPDATE_CVS AND NOT UNIX)
  2177. if("${CVS_EXECUTABLE}" MATCHES "cygwin")
  2178. message(STATUS "No CTest.UpdateCVS test with cygwin cvs.exe outside cygwin!")
  2179. set(CTEST_TEST_UPDATE_CVS 0)
  2180. endif()
  2181. endif()
  2182. if(CTEST_TEST_UPDATE_CVS)
  2183. set(CTestUpdateCVS_DIR "CTest UpdateCVS")
  2184. configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateCVS.cmake.in"
  2185. "${CMake_BINARY_DIR}/Tests/CTestUpdateCVS.cmake" @ONLY)
  2186. add_test(CTest.UpdateCVS ${CMAKE_CMAKE_COMMAND}
  2187. -P "${CMake_BINARY_DIR}/Tests/CTestUpdateCVS.cmake"
  2188. )
  2189. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateCVS_DIR}")
  2190. endif()
  2191. # Test CTest Update with BZR
  2192. find_program(BZR_EXECUTABLE NAMES bzr)
  2193. mark_as_advanced(BZR_EXECUTABLE)
  2194. set(CTEST_TEST_UPDATE_BZR 0)
  2195. if(BZR_EXECUTABLE)
  2196. if(NOT "${BZR_EXECUTABLE}" MATCHES "cygwin" OR UNIX)
  2197. set(CTEST_TEST_UPDATE_BZR 1)
  2198. endif()
  2199. endif()
  2200. if(CTEST_TEST_UPDATE_BZR)
  2201. # Check if xmloutput plugin is there
  2202. execute_process(COMMAND ${BZR_EXECUTABLE} xmlplugins RESULT_VARIABLE xmlplugres
  2203. OUTPUT_QUIET ERROR_QUIET)
  2204. if( NOT ${xmlplugres} )
  2205. set(CTestUpdateBZR_DIR "CTest UpdateBZR")
  2206. configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateBZR.cmake.in"
  2207. "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR.cmake" @ONLY)
  2208. add_test(CTest.UpdateBZR ${CMAKE_CMAKE_COMMAND}
  2209. -P "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR.cmake"
  2210. )
  2211. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateBZR_DIR}")
  2212. set(CTestUpdateBZR_DIR "CTest UpdateBZR_CLocale")
  2213. configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateBZR.cmake.in"
  2214. "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR_CLocale.cmake" @ONLY)
  2215. add_test(CTest.UpdateBZR.CLocale ${CMAKE_CMAKE_COMMAND}
  2216. -P "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR_CLocale.cmake"
  2217. )
  2218. set_tests_properties(CTest.UpdateBZR.CLocale PROPERTIES ENVIRONMENT LC_ALL=C)
  2219. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateBZR_DIR}")
  2220. endif()
  2221. endif()
  2222. # Test CTest Update with GIT
  2223. find_program(GIT_EXECUTABLE NAMES git)
  2224. mark_as_advanced(GIT_EXECUTABLE)
  2225. set(CTEST_TEST_UPDATE_GIT 0)
  2226. if(GIT_EXECUTABLE)
  2227. if(NOT "${GIT_EXECUTABLE}" MATCHES "cygwin" OR UNIX)
  2228. set(CTEST_TEST_UPDATE_GIT 1)
  2229. endif()
  2230. endif()
  2231. if(CTEST_TEST_UPDATE_GIT)
  2232. set(CTestUpdateGIT_DIR "CTest UpdateGIT")
  2233. configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateGIT.cmake.in"
  2234. "${CMake_BINARY_DIR}/Tests/CTestUpdateGIT.cmake" @ONLY)
  2235. add_test(CTest.UpdateGIT ${CMAKE_CMAKE_COMMAND}
  2236. -P "${CMake_BINARY_DIR}/Tests/CTestUpdateGIT.cmake"
  2237. )
  2238. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateGIT_DIR}")
  2239. endif()
  2240. # Test CTest Update with HG
  2241. find_program(HG_EXECUTABLE NAMES hg)
  2242. mark_as_advanced(HG_EXECUTABLE)
  2243. set(CTEST_TEST_UPDATE_HG 0)
  2244. if(HG_EXECUTABLE)
  2245. if(NOT "${HG_EXECUTABLE}" MATCHES "cygwin" OR UNIX)
  2246. set(CTEST_TEST_UPDATE_HG 1)
  2247. endif()
  2248. endif()
  2249. if(CTEST_TEST_UPDATE_HG)
  2250. set(CTestUpdateHG_DIR "CTest UpdateHG")
  2251. configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateHG.cmake.in"
  2252. "${CMake_BINARY_DIR}/Tests/CTestUpdateHG.cmake" @ONLY)
  2253. add_test(CTest.UpdateHG ${CMAKE_CMAKE_COMMAND}
  2254. -P "${CMake_BINARY_DIR}/Tests/CTestUpdateHG.cmake"
  2255. )
  2256. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateHG_DIR}")
  2257. endif()
  2258. # Test CTest Update with P4
  2259. find_program(P4_EXECUTABLE NAMES p4)
  2260. find_program(P4D_EXECUTABLE NAMES p4d)
  2261. mark_as_advanced(P4_EXECUTABLE P4D_EXECUTABLE)
  2262. set(CTEST_TEST_UPDATE_P4 0)
  2263. if(P4_EXECUTABLE AND P4D_EXECUTABLE)
  2264. if(NOT "${P4_EXECUTABLE};${P4D_EXECUTABLE}" MATCHES "cygwin" OR UNIX)
  2265. set(CTEST_TEST_UPDATE_P4 1)
  2266. endif()
  2267. endif()
  2268. if(CTEST_TEST_UPDATE_P4)
  2269. set(CTestUpdateP4_DIR "CTest UpdateP4")
  2270. configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateP4.cmake.in"
  2271. "${CMake_BINARY_DIR}/Tests/CTestUpdateP4.cmake" @ONLY)
  2272. add_test(CTest.UpdateP4 ${CMAKE_CMAKE_COMMAND}
  2273. -P "${CMake_BINARY_DIR}/Tests/CTestUpdateP4.cmake"
  2274. )
  2275. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateP4_DIR}")
  2276. endif()
  2277. endif()
  2278. configure_file(
  2279. "${CMake_SOURCE_DIR}/Tests/CTestTestFailure/testNoBuild.cmake.in"
  2280. "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testNoBuild.cmake"
  2281. @ONLY ESCAPE_QUOTES)
  2282. add_test(CTestTestNoBuild ${CMAKE_CTEST_COMMAND}
  2283. -S "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testNoBuild.cmake" -V
  2284. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testOut1.log"
  2285. )
  2286. set_tests_properties(CTestTestNoBuild PROPERTIES
  2287. FAIL_REGULAR_EXPRESSION "Error" WILL_FAIL true)
  2288. configure_file(
  2289. "${CMake_SOURCE_DIR}/Tests/CTestTestFailure/testNoExe.cmake.in"
  2290. "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testNoExe.cmake"
  2291. @ONLY ESCAPE_QUOTES)
  2292. add_test(CTestTestNoExe ${CMAKE_CTEST_COMMAND}
  2293. -S "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testNoExe.cmake" -V
  2294. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestFailure/testOut2.log"
  2295. )
  2296. set_tests_properties(CTestTestNoExe PROPERTIES DEPENDS CTestTestNoBuild
  2297. PASS_REGULAR_EXPRESSION "Could not find executable"
  2298. FAIL_REGULAR_EXPRESSION "SegFault")
  2299. configure_file(
  2300. "${CMake_SOURCE_DIR}/Tests/CTestTestUpload/test.cmake.in"
  2301. "${CMake_BINARY_DIR}/Tests/CTestTestUpload/test.cmake"
  2302. @ONLY ESCAPE_QUOTES)
  2303. add_test(CTestTestUpload ${CMAKE_CTEST_COMMAND}
  2304. -S "${CMake_BINARY_DIR}/Tests/CTestTestUpload/test.cmake" -V
  2305. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestUpload/testOut.log"
  2306. )
  2307. set_tests_properties(CTestTestUpload PROPERTIES
  2308. PASS_REGULAR_EXPRESSION "Upload\\.xml")
  2309. configure_file(
  2310. "${CMake_SOURCE_DIR}/Tests/CTestCoverageCollectGCOV/test.cmake.in"
  2311. "${CMake_BINARY_DIR}/Tests/CTestCoverageCollectGCOV/test.cmake"
  2312. @ONLY ESCAPE_QUOTES)
  2313. add_test(CTestCoverageCollectGCOV ${CMAKE_CTEST_COMMAND}
  2314. -C \${CTEST_CONFIGURATION_TYPE}
  2315. -S "${CMake_BINARY_DIR}/Tests/CTestCoverageCollectGCOV/test.cmake" -VV
  2316. --output-log "${CMake_BINARY_DIR}/Tests/CTestCoverageCollectGCOV/testOut.log"
  2317. )
  2318. set_tests_properties(CTestCoverageCollectGCOV PROPERTIES
  2319. PASS_REGULAR_EXPRESSION
  2320. "PASSED with correct output.*Testing/CoverageInfo/main.cpp.gcov")
  2321. set_property(TEST CTestCoverageCollectGCOV PROPERTY ENVIRONMENT CTEST_PARALLEL_LEVEL=)
  2322. configure_file(
  2323. "${CMake_SOURCE_DIR}/Tests/CTestTestEmptyBinaryDirectory/test.cmake.in"
  2324. "${CMake_BINARY_DIR}/Tests/CTestTestEmptyBinaryDirectory/test.cmake"
  2325. @ONLY ESCAPE_QUOTES)
  2326. add_test(CTestTestEmptyBinaryDirectory ${CMAKE_CTEST_COMMAND}
  2327. -S "${CMake_BINARY_DIR}/Tests/CTestTestEmptyBinaryDirectory/test.cmake" -V
  2328. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestEmptyBinaryDirectory/testOut.log"
  2329. )
  2330. set_tests_properties(CTestTestEmptyBinaryDirectory PROPERTIES
  2331. PASS_REGULAR_EXPRESSION "TEST_SUCCESS")
  2332. # test coverage for mumps
  2333. # create a MumpsCoverage dir in the binary tree under Testing to
  2334. # avoid the .NoDartCoverage files in the cmake testing tree
  2335. configure_file(
  2336. "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/DartConfiguration.tcl.in"
  2337. "${CMake_BINARY_DIR}/Testing/MumpsCoverage/DartConfiguration.tcl")
  2338. configure_file(
  2339. "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/gtm_coverage.mcov.in"
  2340. "${CMake_BINARY_DIR}/Testing/MumpsCoverage/gtm_coverage.mcov")
  2341. file(REMOVE_RECURSE "${CMake_BINARY_DIR}/Testing/MumpsCoverage/VistA-FOIA")
  2342. file(COPY "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/VistA-FOIA"
  2343. DESTINATION "${CMake_BINARY_DIR}/Testing/MumpsCoverage")
  2344. add_test(NAME CTestGTMCoverage
  2345. COMMAND cmake -E chdir
  2346. ${CMake_BINARY_DIR}/Testing/MumpsCoverage
  2347. $<TARGET_FILE:ctest> -T Coverage --debug)
  2348. set_tests_properties(CTestGTMCoverage PROPERTIES
  2349. PASS_REGULAR_EXPRESSION
  2350. "Process file.*ZZCOVTST.m.*Total LOC:.*30.*Percentage Coverage: 80.00*"
  2351. ENVIRONMENT COVFILE=)
  2352. configure_file(
  2353. "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/DartConfiguration.cache.tcl.in"
  2354. "${CMake_BINARY_DIR}/Testing/MumpsCacheCoverage/DartConfiguration.tcl")
  2355. configure_file(
  2356. "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/cache_coverage.cmcov.in"
  2357. "${CMake_BINARY_DIR}/Testing/MumpsCacheCoverage/cache_coverage.cmcov")
  2358. file(REMOVE_RECURSE "${CMake_BINARY_DIR}/Testing/MumpsCacheCoverage/VistA-FOIA")
  2359. file(COPY "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/VistA-FOIA"
  2360. DESTINATION "${CMake_BINARY_DIR}/Testing/MumpsCacheCoverage")
  2361. add_test(NAME CTestCacheCoverage
  2362. COMMAND cmake -E chdir
  2363. ${CMake_BINARY_DIR}/Testing/MumpsCacheCoverage
  2364. $<TARGET_FILE:ctest> -T Coverage --debug)
  2365. set_tests_properties(CTestCacheCoverage PROPERTIES
  2366. PASS_REGULAR_EXPRESSION
  2367. "Process file.*ZZCOVTST.m.*Total LOC:.*29.*Percentage Coverage: 86.21.*"
  2368. ENVIRONMENT COVFILE=)
  2369. # Adding a test case for Python Coverage
  2370. configure_file(
  2371. "${CMake_SOURCE_DIR}/Tests/PythonCoverage/coverage.xml.in"
  2372. "${CMake_BINARY_DIR}/Testing/PythonCoverage/coverage.xml")
  2373. configure_file(
  2374. "${CMake_SOURCE_DIR}/Tests/PythonCoverage/DartConfiguration.tcl.in"
  2375. "${CMake_BINARY_DIR}/Testing/PythonCoverage/DartConfiguration.tcl")
  2376. file(COPY "${CMake_SOURCE_DIR}/Tests/PythonCoverage/coveragetest"
  2377. DESTINATION "${CMake_BINARY_DIR}/Testing/PythonCoverage")
  2378. add_test(NAME CTestPythonCoverage
  2379. COMMAND cmake -E chdir
  2380. ${CMake_BINARY_DIR}/Testing/PythonCoverage
  2381. $<TARGET_FILE:ctest> -T Coverage --debug)
  2382. set_tests_properties(CTestPythonCoverage PROPERTIES
  2383. PASS_REGULAR_EXPRESSION
  2384. "Process file.*foo.py.*Total LOC:.*13.*Percentage Coverage: 84.62.*"
  2385. ENVIRONMENT COVFILE=)
  2386. # Adding a test case for non-python Cobertura Coverage
  2387. configure_file(
  2388. "${CMake_SOURCE_DIR}/Tests/CoberturaCoverage/DartConfiguration.tcl.in"
  2389. "${CMake_BINARY_DIR}/Testing/CoberturaCoverage/DartConfiguration.tcl")
  2390. configure_file(
  2391. "${CMake_SOURCE_DIR}/Tests/CoberturaCoverage/coverage.xml.in"
  2392. "${CMake_BINARY_DIR}/Testing/CoberturaCoverage/coverage.xml")
  2393. file(COPY "${CMake_SOURCE_DIR}/Tests/CoberturaCoverage/src"
  2394. DESTINATION "${CMake_BINARY_DIR}/Testing/CoberturaCoverage")
  2395. add_test(NAME CTestCoberturaCoverage
  2396. COMMAND cmake -E chdir
  2397. ${CMake_BINARY_DIR}/Testing/CoberturaCoverage
  2398. $<TARGET_FILE:ctest> -T Coverage --debug)
  2399. set_tests_properties(CTestCoberturaCoverage PROPERTIES
  2400. PASS_REGULAR_EXPRESSION
  2401. "Process file.*CoverageTest.java.*Total LOC:.*18.*Percentage Coverage: 72.22.*"
  2402. ENVIRONMENT COBERTURADIR=${CMake_BINARY_DIR}/Testing/CoberturaCoverage
  2403. ENVIRONMENT COVFILE=)
  2404. # Adding a test case for JaCoCo Coverage
  2405. configure_file(
  2406. "${CMake_SOURCE_DIR}/Tests/JacocoCoverage/DartConfiguration.tcl.in"
  2407. "${CMake_BINARY_DIR}/Testing/JacocoCoverage/DartConfiguration.tcl")
  2408. file(COPY "${CMake_SOURCE_DIR}/Tests/JacocoCoverage/Coverage"
  2409. DESTINATION "${CMake_BINARY_DIR}/Testing/JacocoCoverage")
  2410. configure_file("${CMake_BINARY_DIR}/Testing/JacocoCoverage/Coverage/target/site/jacoco.xml.in"
  2411. "${CMake_BINARY_DIR}/Testing/JacocoCoverage/Coverage/target/site/jacoco.xml")
  2412. add_test(NAME CTestJacocoCoverage
  2413. COMMAND cmake -E chdir
  2414. ${CMake_BINARY_DIR}/Testing/JacocoCoverage
  2415. $<TARGET_FILE:ctest> -T Coverage --debug)
  2416. set_tests_properties(CTestJacocoCoverage PROPERTIES
  2417. PASS_REGULAR_EXPRESSION
  2418. "Process file.*CoverageTest.java.*Total LOC:.*17.*Percentage Coverage: 76.47*"
  2419. ENVIRONMENT COVFILE=)
  2420. # Adding a test case for Javascript Coverage
  2421. configure_file(
  2422. "${CMake_SOURCE_DIR}/Tests/JavascriptCoverage/DartConfiguration.tcl.in"
  2423. "${CMake_BINARY_DIR}/Testing/JavascriptCoverage/DartConfiguration.tcl")
  2424. configure_file(
  2425. "${CMake_SOURCE_DIR}/Tests/JavascriptCoverage/output.json.in"
  2426. "${CMake_BINARY_DIR}/Testing/JavascriptCoverage/output.json")
  2427. file(COPY "${CMake_SOURCE_DIR}/Tests/JavascriptCoverage/"
  2428. DESTINATION "${CMake_BINARY_DIR}/Testing/JavascriptCoverage"
  2429. FILES_MATCHING PATTERN "*.js")
  2430. add_test(NAME CTestJavascriptCoverage
  2431. COMMAND cmake -E chdir
  2432. ${CMake_BINARY_DIR}/Testing/JavascriptCoverage
  2433. $<TARGET_FILE:ctest> -T Coverage --debug)
  2434. set_tests_properties(CTestJavascriptCoverage PROPERTIES
  2435. PASS_REGULAR_EXPRESSION
  2436. "Process file.*test3.js.*Total LOC:.*49.*Percentage Coverage: 79.59*"
  2437. ENVIRONMENT COVFILE=)
  2438. # test coverage for Delphi-code-Coverage
  2439. configure_file(
  2440. "${CMake_SOURCE_DIR}/Tests/DelphiCoverage/DartConfiguration.tcl.in"
  2441. "${CMake_BINARY_DIR}/Testing/DelphiCoverage/DartConfiguration.tcl")
  2442. file(COPY "${CMake_SOURCE_DIR}/Tests/DelphiCoverage/src"
  2443. DESTINATION "${CMake_BINARY_DIR}/Testing/DelphiCoverage")
  2444. configure_file(
  2445. "${CMake_SOURCE_DIR}/Tests/DelphiCoverage/UTCovTest(UTCovTest.pas).html.in"
  2446. "${CMake_BINARY_DIR}/Testing/DelphiCoverage/UTCovTest(UTCovTest.pas).html")
  2447. add_test(NAME CTestDelphiCoverage
  2448. COMMAND cmake -E chdir
  2449. ${CMake_BINARY_DIR}/Testing/DelphiCoverage
  2450. $<TARGET_FILE:ctest> -T Coverage --debug)
  2451. set_tests_properties(CTestDelphiCoverage PROPERTIES
  2452. PASS_REGULAR_EXPRESSION
  2453. "Process file.*UTCovTest.pas.*Total LOC:.*20.*Percentage Coverage: 95.*"
  2454. ENVIRONMENT COVFILE=)
  2455. function(add_config_tests cfg)
  2456. set(base "${CMake_BINARY_DIR}/Tests/CTestConfig")
  2457. # Test -S script with a -C config arg to ctest:
  2458. configure_file(
  2459. "${CMake_SOURCE_DIR}/Tests/CTestConfig/script.cmake.in"
  2460. "${base}/${cfg}-script.cmake"
  2461. @ONLY ESCAPE_QUOTES)
  2462. add_test(CTestConfig.Script.${cfg} ${CMAKE_CTEST_COMMAND}
  2463. -C ${cfg}
  2464. -S "${base}/${cfg}-script.cmake" -VV
  2465. --output-log "${base}/${cfg}-script.log"
  2466. )
  2467. # Test -D dashboard with a -C config arg to ctest.
  2468. # (Actual commands inside a cmake -P script because we need to be able to set
  2469. # the working directory reliably...)
  2470. configure_file(
  2471. "${CMake_SOURCE_DIR}/Tests/CTestConfig/dashboard.cmake.in"
  2472. "${base}/${cfg}-dashboard.cmake"
  2473. @ONLY ESCAPE_QUOTES)
  2474. add_test(CTestConfig.Dashboard.${cfg} ${CMAKE_CMAKE_COMMAND}
  2475. -P "${base}/${cfg}-dashboard.cmake" -VV
  2476. )
  2477. endfunction()
  2478. add_config_tests(Debug)
  2479. add_config_tests(MinSizeRel)
  2480. add_config_tests(Release)
  2481. add_config_tests(RelWithDebInfo)
  2482. # Test -S script with some -D variable definition args to ctest:
  2483. add_test(CTestConfig.ScriptWithArgs ${CMAKE_CTEST_COMMAND}
  2484. -C "Release"
  2485. -D arg1=this
  2486. -D arg2=that
  2487. -D "arg3=the other"
  2488. "-Darg4=this is the fourth"
  2489. -Darg5=the_fifth
  2490. -Darg6:STRING=value-with-type
  2491. -S "${CMake_SOURCE_DIR}/Tests/CTestConfig/ScriptWithArgs.cmake" -VV
  2492. --output-log "${CMake_BINARY_DIR}/Tests/CTestConfig/ScriptWithArgs.log"
  2493. )
  2494. ADD_TEST_MACRO(CMakeCommands.add_compile_options add_compile_options)
  2495. ADD_TEST_MACRO(CMakeCommands.target_link_libraries target_link_libraries)
  2496. ADD_TEST_MACRO(CMakeCommands.target_include_directories target_include_directories)
  2497. ADD_TEST_MACRO(CMakeCommands.target_compile_definitions target_compile_definitions)
  2498. ADD_TEST_MACRO(CMakeCommands.target_compile_options target_compile_options)
  2499. if(CMake_TEST_SERVER_MODE)
  2500. # The cmake server-mode test requires python for a simple client.
  2501. find_package(PythonInterp QUIET)
  2502. if(PYTHON_EXECUTABLE)
  2503. set(Server_BUILD_OPTIONS -DPYTHON_EXECUTABLE:FILEPATH=${PYTHON_EXECUTABLE})
  2504. ADD_TEST_MACRO(Server Server)
  2505. endif()
  2506. endif()
  2507. configure_file(
  2508. "${CMake_SOURCE_DIR}/Tests/CTestTestCrash/test.cmake.in"
  2509. "${CMake_BINARY_DIR}/Tests/CTestTestCrash/test.cmake"
  2510. @ONLY ESCAPE_QUOTES)
  2511. add_test(CTestTestCrash ${CMAKE_CTEST_COMMAND}
  2512. -S "${CMake_BINARY_DIR}/Tests/CTestTestCrash/test.cmake" -V
  2513. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestCrash/testOutput.log"
  2514. )
  2515. # with watcom the SEGFAULT is not found, it just fails
  2516. if(CMAKE_GENERATOR MATCHES "Watcom WMake")
  2517. set_tests_properties(CTestTestCrash PROPERTIES
  2518. PASS_REGULAR_EXPRESSION "Failed")
  2519. else()
  2520. set_tests_properties(CTestTestCrash PROPERTIES
  2521. PASS_REGULAR_EXPRESSION "(Illegal|SegFault)")
  2522. endif()
  2523. configure_file(
  2524. "${CMake_SOURCE_DIR}/Tests/CTestTestBadExe/test.cmake.in"
  2525. "${CMake_BINARY_DIR}/Tests/CTestTestBadExe/test.cmake"
  2526. @ONLY ESCAPE_QUOTES)
  2527. add_test(CTestTestBadExe ${CMAKE_CTEST_COMMAND}
  2528. -S "${CMake_BINARY_DIR}/Tests/CTestTestBadExe/test.cmake" -V
  2529. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestBadExe/testOutput.log"
  2530. )
  2531. set(CTestTestBadExe_REGEX "BAD_COMMAND")
  2532. # some cygwin can not be made to produce a BAD_COMMAND error
  2533. # the best we can get from it is a failed test
  2534. if(CYGWIN)
  2535. set(CTestTestBadExe_REGEX "(\\*\\*\\*Failed)|BAD_COMMAND")
  2536. endif()
  2537. set_tests_properties(CTestTestBadExe PROPERTIES
  2538. PASS_REGULAR_EXPRESSION "${CTestTestBadExe_REGEX}")
  2539. configure_file(
  2540. "${CMake_SOURCE_DIR}/Tests/CTestTestBadGenerator/test.cmake.in"
  2541. "${CMake_BINARY_DIR}/Tests/CTestTestBadGenerator/test.cmake"
  2542. @ONLY ESCAPE_QUOTES)
  2543. add_test(CTestTestBadGenerator ${CMAKE_CTEST_COMMAND}
  2544. -C "\${CTestTest_CONFIG}"
  2545. -S "${CMake_BINARY_DIR}/Tests/CTestTestBadGenerator/test.cmake" -V
  2546. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestBadGenerator/testOutput.log"
  2547. )
  2548. set_property(TEST CTestTestBadGenerator PROPERTY
  2549. PASS_REGULAR_EXPRESSION "could not create generator named \"Bad Generator\"")
  2550. configure_file(
  2551. "${CMake_SOURCE_DIR}/Tests/CTestTestParallel/test.cmake.in"
  2552. "${CMake_BINARY_DIR}/Tests/CTestTestParallel/test.cmake"
  2553. @ONLY ESCAPE_QUOTES)
  2554. add_test(CTestTestParallel ${CMAKE_CTEST_COMMAND}
  2555. -S "${CMake_BINARY_DIR}/Tests/CTestTestParallel/test.cmake" -V
  2556. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestParallel/testOutput.log"
  2557. )
  2558. configure_file("${CMake_SOURCE_DIR}/Tests/CTestTestVerboseOutput/test.cmake.in"
  2559. "${CMake_BINARY_DIR}/Tests/CTestTestVerboseOutput/test.cmake" @ONLY ESCAPE_QUOTES)
  2560. add_test(CTestTestVerboseOutput ${CMAKE_CTEST_COMMAND}
  2561. -S "${CMake_BINARY_DIR}/Tests/CTestTestVerboseOutput/test.cmake" -VV
  2562. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestVerboseOutput/testOutput.log"
  2563. -C "\${CTestTest_CONFIG}"
  2564. )
  2565. set_property(TEST CTestTestVerboseOutput PROPERTY PASS_REGULAR_EXPRESSION
  2566. "Environment variables:.*foo=bar.*this=that"
  2567. )
  2568. configure_file(
  2569. "${CMake_SOURCE_DIR}/Tests/CTestTestSkipReturnCode/test.cmake.in"
  2570. "${CMake_BINARY_DIR}/Tests/CTestTestSkipReturnCode/test.cmake"
  2571. @ONLY ESCAPE_QUOTES)
  2572. add_test(CTestTestSkipReturnCode ${CMAKE_CTEST_COMMAND}
  2573. -S "${CMake_BINARY_DIR}/Tests/CTestTestSkipReturnCode/test.cmake" -V
  2574. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestSkipReturnCode/testOutput.log"
  2575. -C \${CTEST_CONFIGURATION_TYPE}
  2576. )
  2577. set_tests_properties(CTestTestSkipReturnCode PROPERTIES
  2578. PASS_REGULAR_EXPRESSION "CMakeV1 \\.* +Passed.*CMakeV2 \\.+\\*+Skipped")
  2579. set_property(TEST CTestTestSkipReturnCode PROPERTY ENVIRONMENT CTEST_PARALLEL_LEVEL=)
  2580. ADD_TEST_MACRO(CTestTestSerialInDepends ${CMAKE_CTEST_COMMAND} -j 4
  2581. --output-on-failure -C "\${CTestTest_CONFIG}")
  2582. ADD_TEST_MACRO(CTestTestMissingDependsExe ${CMAKE_CTEST_COMMAND}
  2583. --output-on-failure -C "\${CTestTest_CONFIG}")
  2584. set_tests_properties(CTestTestMissingDependsExe PROPERTIES
  2585. PASS_REGULAR_EXPRESSION "\\*\\*\\*Not Run"
  2586. )
  2587. ADD_TEST_MACRO(CTestTestSerialOrder ${CMAKE_CTEST_COMMAND}
  2588. --output-on-failure -C "\${CTestTest_CONFIG}")
  2589. set_property(TEST CTestTestSerialOrder PROPERTY ENVIRONMENT CTEST_PARALLEL_LEVEL=)
  2590. if(NOT BORLAND)
  2591. set(CTestLimitDashJ_CTEST_OPTIONS --force-new-ctest-process)
  2592. add_test_macro(CTestLimitDashJ ${CMAKE_CTEST_COMMAND} -j 4
  2593. --output-on-failure -C "\${CTestTest_CONFIG}")
  2594. endif()
  2595. add_test(CTestTestPrintLabels ${CMAKE_CTEST_COMMAND} --print-labels)
  2596. set_tests_properties(CTestTestPrintLabels PROPERTIES LABELS "Label1;Label2")
  2597. set_tests_properties(CTestTestPrintLabels PROPERTIES PASS_REGULAR_EXPRESSION
  2598. "All Labels:.* Label1.* Label2")
  2599. configure_file(
  2600. "${CMake_SOURCE_DIR}/Tests/CTestTestLabelRegExp/test.cmake.in"
  2601. "${CMake_BINARY_DIR}/Tests/CTestTestLabelRegExp/test.cmake"
  2602. @ONLY ESCAPE_QUOTES)
  2603. add_test(NAME CTestTestLabelRegExp
  2604. COMMAND ${CMAKE_CMAKE_COMMAND}
  2605. -DSOURCE_DIR=${CMAKE_SOURCE_DIR}/Tests/CTestTestLabelRegExp
  2606. -P ${CMAKE_BINARY_DIR}/Tests/CTestTestLabelRegExp/test.cmake
  2607. WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/Tests/CTestTestLabelRegExp
  2608. )
  2609. configure_file(
  2610. "${CMake_SOURCE_DIR}/Tests/CTestTestResourceLock/test.cmake.in"
  2611. "${CMake_BINARY_DIR}/Tests/CTestTestResourceLock/test.cmake"
  2612. @ONLY ESCAPE_QUOTES)
  2613. add_test(CTestTestResourceLock ${CMAKE_CTEST_COMMAND}
  2614. -S "${CMake_BINARY_DIR}/Tests/CTestTestResourceLock/test.cmake" -V
  2615. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestResourceLock/output.log"
  2616. )
  2617. configure_file(
  2618. "${CMake_SOURCE_DIR}/Tests/CTestTestScheduler/test.cmake.in"
  2619. "${CMake_BINARY_DIR}/Tests/CTestTestScheduler/test.cmake"
  2620. @ONLY ESCAPE_QUOTES)
  2621. add_test(CTestTestScheduler ${CMAKE_CTEST_COMMAND}
  2622. -S "${CMake_BINARY_DIR}/Tests/CTestTestScheduler/test.cmake" -V
  2623. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestScheduler/testOutput.log"
  2624. )
  2625. set_tests_properties(CTestTestScheduler PROPERTIES
  2626. PASS_REGULAR_EXPRESSION "Start 1.*Start 2.*Start 3.*Start 4.*Start 4.*Start 3.*Start 2.*Start 1"
  2627. RESOURCE_LOCK "CostData")
  2628. configure_file(
  2629. "${CMake_SOURCE_DIR}/Tests/CTestTestCostSerial/test.cmake.in"
  2630. "${CMake_BINARY_DIR}/Tests/CTestTestCostSerial/test.cmake"
  2631. @ONLY ESCAPE_QUOTES)
  2632. add_test(CTestTestCostSerial ${CMAKE_CTEST_COMMAND}
  2633. -S "${CMake_BINARY_DIR}/Tests/CTestTestCostSerial/test.cmake" -V
  2634. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestCostSerial/testOutput.log"
  2635. )
  2636. set_tests_properties(CTestTestCostSerial PROPERTIES
  2637. PASS_REGULAR_EXPRESSION "Start 2.*Start 3.*Start 1.*Start 2.*Start 3.*Start 1"
  2638. RESOURCE_LOCK "CostData")
  2639. configure_file(
  2640. "${CMake_SOURCE_DIR}/Tests/CTestTestStopTime/test.cmake.in"
  2641. "${CMake_BINARY_DIR}/Tests/CTestTestStopTime/test.cmake"
  2642. @ONLY ESCAPE_QUOTES)
  2643. configure_file(
  2644. "${CMake_SOURCE_DIR}/Tests/CTestTestStopTime/GetDate.cmake"
  2645. "${CMake_BINARY_DIR}/Tests/CTestTestStopTime/GetDate.cmake"
  2646. COPYONLY)
  2647. add_test(CTestTestStopTime ${CMAKE_CTEST_COMMAND}
  2648. -S "${CMake_BINARY_DIR}/Tests/CTestTestStopTime/test.cmake" -V
  2649. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestStopTime/testOutput.log"
  2650. )
  2651. set_tests_properties(CTestTestStopTime PROPERTIES
  2652. PASS_REGULAR_EXPRESSION "The stop time has been passed")
  2653. configure_file(
  2654. "${CMake_SOURCE_DIR}/Tests/CTestTestSubdir/test.cmake.in"
  2655. "${CMake_BINARY_DIR}/Tests/CTestTestSubdir/test.cmake"
  2656. @ONLY ESCAPE_QUOTES)
  2657. add_test(CTestTestSubdir ${CMAKE_CTEST_COMMAND}
  2658. -S "${CMake_BINARY_DIR}/Tests/CTestTestSubdir/test.cmake" -V
  2659. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestSubdir/testOutput.log"
  2660. )
  2661. #make sure all 3 subdirs were added
  2662. set_tests_properties(CTestTestSubdir PROPERTIES
  2663. PASS_REGULAR_EXPRESSION "0 tests failed out of 3")
  2664. configure_file(
  2665. "${CMake_SOURCE_DIR}/Tests/CTestTestTimeout/test.cmake.in"
  2666. "${CMake_BINARY_DIR}/Tests/CTestTestTimeout/test.cmake"
  2667. @ONLY ESCAPE_QUOTES)
  2668. add_test(CTestTestTimeout ${CMAKE_CTEST_COMMAND}
  2669. -C "\${CTestTest_CONFIG}"
  2670. -S "${CMake_BINARY_DIR}/Tests/CTestTestTimeout/test.cmake" -V
  2671. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestTimeout/testOutput.log"
  2672. )
  2673. set_tests_properties(CTestTestTimeout PROPERTIES
  2674. PASS_REGULAR_EXPRESSION "TestTimeout *\\.+ *\\*\\*\\*Timeout.*TestSleep *\\.+ *Passed.*timeout correctly killed child")
  2675. add_test(
  2676. NAME CTestTestRerunFailed
  2677. COMMAND ${CMAKE_CTEST_COMMAND} --rerun-failed)
  2678. set_tests_properties(CTestTestRerunFailed PROPERTIES
  2679. PASS_REGULAR_EXPRESSION "1/1 Test #1: TestTimeout" DEPENDS CTestTestTimeout
  2680. WORKING_DIRECTORY ${CMake_BINARY_DIR}/Tests/CTestTestTimeout)
  2681. configure_file(
  2682. "${CMake_SOURCE_DIR}/Tests/CTestTestZeroTimeout/test.cmake.in"
  2683. "${CMake_BINARY_DIR}/Tests/CTestTestZeroTimeout/test.cmake"
  2684. @ONLY ESCAPE_QUOTES)
  2685. add_test(CTestTestZeroTimeout ${CMAKE_CTEST_COMMAND}
  2686. -S "${CMake_BINARY_DIR}/Tests/CTestTestZeroTimeout/test.cmake" -V
  2687. --output-log
  2688. "${CMake_BINARY_DIR}/Tests/CTestTestZeroTimeout/testOutput.log")
  2689. set_tests_properties(CTestTestZeroTimeout PROPERTIES
  2690. FAIL_REGULAR_EXPRESSION "\\*\\*\\*Timeout")
  2691. configure_file(
  2692. "${CMake_SOURCE_DIR}/Tests/CTestTestDepends/test.cmake.in"
  2693. "${CMake_BINARY_DIR}/Tests/CTestTestDepends/test.cmake"
  2694. @ONLY ESCAPE_QUOTES)
  2695. add_test(CTestTestDepends ${CMAKE_CTEST_COMMAND}
  2696. -C "\${CTestTest_CONFIG}"
  2697. -S "${CMake_BINARY_DIR}/Tests/CTestTestDepends/test.cmake" -V
  2698. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestDepends/testOutput.log"
  2699. )
  2700. configure_file(
  2701. "${CMake_SOURCE_DIR}/Tests/CTestTestCycle/test.cmake.in"
  2702. "${CMake_BINARY_DIR}/Tests/CTestTestCycle/test.cmake"
  2703. @ONLY ESCAPE_QUOTES)
  2704. add_test(CTestTestCycle ${CMAKE_CTEST_COMMAND}
  2705. -C "\${CTestTest_CONFIG}"
  2706. -S "${CMake_BINARY_DIR}/Tests/CTestTestCycle/test.cmake" -V
  2707. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestCycle/testOutput.log"
  2708. )
  2709. set_tests_properties(CTestTestCycle PROPERTIES
  2710. PASS_REGULAR_EXPRESSION "a cycle exists in the test dependency graph")
  2711. configure_file(
  2712. "${CMake_SOURCE_DIR}/Tests/CTestTestRunScript/test.cmake.in"
  2713. "${CMake_BINARY_DIR}/Tests/CTestTestRunScript/test.cmake"
  2714. @ONLY ESCAPE_QUOTES)
  2715. configure_file(
  2716. "${CMake_SOURCE_DIR}/Tests/CTestTestRunScript/hello.cmake.in"
  2717. "${CMake_BINARY_DIR}/Tests/CTestTestRunScript/hello.cmake"
  2718. @ONLY ESCAPE_QUOTES)
  2719. add_test(CTestTestRunScript ${CMAKE_CTEST_COMMAND}
  2720. -S "${CMake_BINARY_DIR}/Tests/CTestTestRunScript/test.cmake" -V
  2721. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestRunScript/testOutput.log"
  2722. )
  2723. add_test(CTestTestShowOnly ${CMAKE_CTEST_COMMAND} -N)
  2724. add_test(CTestBatchTest ${CMAKE_CTEST_COMMAND} -B)
  2725. configure_file(
  2726. "${CMake_SOURCE_DIR}/Tests/CTestTestFdSetSize/test.cmake.in"
  2727. "${CMake_BINARY_DIR}/Tests/CTestTestFdSetSize/test.cmake"
  2728. @ONLY ESCAPE_QUOTES)
  2729. add_test(CTestTestFdSetSize ${CMAKE_CTEST_COMMAND}
  2730. -S "${CMake_BINARY_DIR}/Tests/CTestTestFdSetSize/test.cmake" -j20 -V --timeout 120
  2731. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestFdSetSize/testOutput.log"
  2732. )
  2733. if (CMAKE_TESTS_CDASH_SERVER)
  2734. set(regex "^([^:]+)://([^/]+)(.*)$")
  2735. if ("${CMAKE_TESTS_CDASH_SERVER}" MATCHES "${regex}")
  2736. set(protocol "${CMAKE_MATCH_1}")
  2737. set(server "${CMAKE_MATCH_2}")
  2738. set(path "${CMAKE_MATCH_3}")
  2739. else ()
  2740. set(protocol "http")
  2741. set(server "open.cdash.org")
  2742. set(path "")
  2743. message("warning: CMAKE_TESTS_CDASH_SERVER does not match expected regex...")
  2744. message(" ...using default url='${protocol}://${server}${path}' for CTestTest[23]")
  2745. endif ()
  2746. endif ()
  2747. if (CTEST_TEST_CTEST AND CMAKE_RUN_LONG_TESTS AND CMAKE_TESTS_CDASH_SERVER)
  2748. configure_file("${CMake_SOURCE_DIR}/Tests/CTestTest/test.cmake.in"
  2749. "${CMake_BINARY_DIR}/Tests/CTestTest/test.cmake" @ONLY ESCAPE_QUOTES)
  2750. add_test(CTestTest ${CMAKE_CTEST_COMMAND}
  2751. -S "${CMake_BINARY_DIR}/Tests/CTestTest/test.cmake" -V
  2752. --output-log "${CMake_BINARY_DIR}/Tests/CTestTest/testOutput.log"
  2753. )
  2754. configure_file("${CMake_SOURCE_DIR}/Tests/CTestTest2/test.cmake.in"
  2755. "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" @ONLY ESCAPE_QUOTES)
  2756. add_test(CTestTest2 ${CMAKE_CTEST_COMMAND}
  2757. -S "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" -V
  2758. --output-log "${CMake_BINARY_DIR}/Tests/CTestTest2/testOutput.log"
  2759. )
  2760. if("${CMAKE_GENERATOR}" MATCHES "Makefiles" OR "${CMAKE_GENERATOR}" MATCHES "Ninja")
  2761. configure_file("${CMake_SOURCE_DIR}/Tests/CTestTestLaunchers/test.cmake.in"
  2762. "${CMake_BINARY_DIR}/Tests/CTestTestLaunchers/test.cmake" @ONLY ESCAPE_QUOTES)
  2763. add_test(CTestTestLaunchers ${CMAKE_CTEST_COMMAND}
  2764. -S "${CMake_BINARY_DIR}/Tests/CTestTestLaunchers/test.cmake" -V
  2765. --output-log "${CMake_BINARY_DIR}/Tests/CTestTestLaunchers/testOutput.log"
  2766. )
  2767. set_tests_properties(CTestTestLaunchers PROPERTIES
  2768. PASS_REGULAR_EXPRESSION "CTEST_TEST_LAUNCHER_SUCCESS")
  2769. endif()
  2770. configure_file("${CMake_SOURCE_DIR}/Tests/CTestTestChecksum/test.cmake.in"
  2771. "${CMake_BINARY_DIR}/Tests/CTestTestChecksum/test.cmake" @ONLY
  2772. ESCAPE_QUOTES)
  2773. add_test(CTestTestChecksum ${CMAKE_CTEST_COMMAND}
  2774. -S "${CMake_BINARY_DIR}/Tests/CTestTestChecksum/test.cmake" -V
  2775. --output-log
  2776. "${CMake_BINARY_DIR}/Tests/CTestTestChecksum/testOutput.log"
  2777. )
  2778. set_tests_properties(CTestTestChecksum PROPERTIES PASS_REGULAR_EXPRESSION
  2779. "Submission failed: Checksum failed for file")
  2780. # these tests take a long time, make sure they have it
  2781. # if timeouts have not already been set
  2782. get_test_property(CTestTest TIMEOUT PREVIOUS_TIMEOUT)
  2783. if ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND)
  2784. set_tests_properties ( CTestTest
  2785. PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT})
  2786. endif ()
  2787. get_test_property(CTestTest2 TIMEOUT PREVIOUS_TIMEOUT)
  2788. if ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND)
  2789. set_tests_properties ( CTestTest2
  2790. PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT})
  2791. endif ()
  2792. endif ()
  2793. if("${CMAKE_GENERATOR}" MATCHES Xcode)
  2794. set(CMAKE_SKIP_BOOTSTRAP_TEST 1)
  2795. endif()
  2796. if(EXISTS "${CMake_BINARY_DIR}/CMakeLists.txt")
  2797. # If there is CMakeLists.txt in the binary tree, assume in-source build
  2798. set(CMAKE_SKIP_BOOTSTRAP_TEST 1)
  2799. endif()
  2800. set(bootstrap "")
  2801. if(CMAKE_RUN_LONG_TESTS AND NOT CMAKE_SKIP_BOOTSTRAP_TEST)
  2802. if(UNIX)
  2803. set(bootstrap ${CMake_SOURCE_DIR}/bootstrap)
  2804. elseif(MSYS)
  2805. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/bootstrap.bat.in
  2806. ${CMAKE_CURRENT_BINARY_DIR}/bootstrap.bat @ONLY)
  2807. set(bootstrap ${CMAKE_CURRENT_BINARY_DIR}/bootstrap.bat)
  2808. endif()
  2809. endif()
  2810. if(bootstrap)
  2811. add_test(NAME BootstrapTest
  2812. COMMAND ${CMAKE_CMAKE_COMMAND}
  2813. -D "bootstrap=${bootstrap}"
  2814. -D "bin_dir=${CMake_BINARY_DIR}/Tests/BootstrapTest"
  2815. -P ${CMAKE_CURRENT_SOURCE_DIR}/BootstrapTest.cmake
  2816. )
  2817. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BootstrapTest")
  2818. # This test will use all processors.
  2819. set_tests_properties(BootstrapTest PROPERTIES RUN_SERIAL 1)
  2820. # provide more time for the bootstrap test
  2821. get_test_property(BootstrapTest TIMEOUT PREVIOUS_TIMEOUT)
  2822. if ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND)
  2823. set_tests_properties ( BootstrapTest
  2824. PROPERTIES TIMEOUT 5400)
  2825. endif ()
  2826. endif()
  2827. if(CMAKE_Fortran_COMPILER)
  2828. add_test(Fortran ${CMAKE_CTEST_COMMAND}
  2829. --build-and-test
  2830. "${CMake_SOURCE_DIR}/Tests/Fortran"
  2831. "${CMake_BINARY_DIR}/Tests/Fortran"
  2832. ${build_generator_args}
  2833. --build-project testf
  2834. --build-two-config
  2835. --build-options ${build_options}
  2836. --test-command testf)
  2837. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Fortran")
  2838. if(CMAKE_Fortran_COMPILER_SUPPORTS_F90)
  2839. add_test(FortranModules ${CMAKE_CTEST_COMMAND}
  2840. --build-and-test
  2841. "${CMake_SOURCE_DIR}/Tests/FortranModules"
  2842. "${CMake_BINARY_DIR}/Tests/FortranModules"
  2843. ${build_generator_args}
  2844. --build-project FortranModules
  2845. --build-options ${build_options}
  2846. -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM}
  2847. -DCMake_TEST_Fortran_SUBMODULES:BOOL=${CMake_TEST_Fortran_SUBMODULES}
  2848. )
  2849. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/FortranModules")
  2850. endif()
  2851. # FortranCInterface tests.
  2852. if(UNIX)
  2853. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/FortranC/Flags.cmake.in
  2854. ${CMAKE_CURRENT_BINARY_DIR}/FortranC/Flags.cmake @ONLY)
  2855. add_test(FortranC.Flags ${CMAKE_CMAKE_COMMAND} -P
  2856. ${CMAKE_CURRENT_BINARY_DIR}/FortranC/Flags.cmake)
  2857. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/FortranC/Flags")
  2858. else()
  2859. add_test(FortranC ${CMAKE_CTEST_COMMAND}
  2860. --build-and-test
  2861. "${CMake_SOURCE_DIR}/Tests/FortranC"
  2862. "${CMake_BINARY_DIR}/Tests/FortranC"
  2863. ${build_generator_args}
  2864. --build-project FortranC
  2865. --build-two-config
  2866. --build-options ${build_options}
  2867. --test-command CMakeFiles/FortranCInterface/FortranCInterface)
  2868. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/FortranC")
  2869. endif()
  2870. endif()
  2871. find_package(Java COMPONENTS Development QUIET)
  2872. if(Java_JAVA_EXECUTABLE AND Java_JAVAC_EXECUTABLE AND Java_JAR_EXECUTABLE AND NOT MINGW
  2873. AND NOT "${CMAKE_GENERATOR}" MATCHES "Xcode")
  2874. set(JavaExportImport_BUILD_OPTIONS -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM})
  2875. ADD_TEST_MACRO(JavaExportImport JavaExportImport)
  2876. get_filename_component(JNIPATH ${JAVA_COMPILE} PATH)
  2877. find_file(JNI_H jni.h
  2878. "${JNIPATH}/../include"
  2879. "${JNIPATH}/../java/include")
  2880. if(JNI_H AND EXISTS "${JNI_H}") # in case jni.h is a broken symlink
  2881. file(READ "${JNI_H}" JNI_FILE)
  2882. if("${JNI_FILE}" MATCHES "JDK1_2")
  2883. add_test(Java.Jar ${CMAKE_CTEST_COMMAND}
  2884. --build-and-test
  2885. "${CMake_SOURCE_DIR}/Tests/Java"
  2886. "${CMake_BINARY_DIR}/Tests/JavaJar"
  2887. ${build_generator_args}
  2888. --build-project hello
  2889. --build-target hello
  2890. --build-two-config
  2891. --build-run-dir "${CMake_BINARY_DIR}/Tests/JavaJar/"
  2892. --build-options ${build_options}
  2893. --test-command ${JAVA_RUNTIME} -classpath hello.jar HelloWorld)
  2894. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJar")
  2895. add_test(Java.JarSourceList ${CMAKE_CTEST_COMMAND}
  2896. --build-and-test
  2897. "${CMake_SOURCE_DIR}/Tests/Java"
  2898. "${CMake_BINARY_DIR}/Tests/JavaJarSourceList"
  2899. ${build_generator_args}
  2900. --build-project hello
  2901. --build-target hello2
  2902. --build-two-config
  2903. --build-run-dir "${CMake_BINARY_DIR}/Tests/JavaJarSourceList/"
  2904. --build-options ${build_options}
  2905. --test-command ${JAVA_RUNTIME} -classpath hello2.jar HelloWorld)
  2906. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJarSourceList")
  2907. # For next test, java tool must have same architecture as toolchain
  2908. math(EXPR _object_mode "${CMAKE_SIZEOF_VOID_P} * 8")
  2909. execute_process(
  2910. COMMAND "${Java_JAVA_EXECUTABLE}" -d${_object_mode} -version
  2911. OUTPUT_QUIET ERROR_QUIET RESULT_VARIABLE _result
  2912. )
  2913. if(_result EQUAL 0)
  2914. if(CMAKE_CONFIGURATION_TYPES)
  2915. set (JAVAH_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaJavah/$<CONFIGURATION>)
  2916. else()
  2917. set (JAVAH_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaJavah)
  2918. endif()
  2919. add_test(NAME Java.Javah COMMAND ${CMAKE_CTEST_COMMAND}
  2920. --build-and-test
  2921. "${CMake_SOURCE_DIR}/Tests/JavaJavah"
  2922. "${CMake_BINARY_DIR}/Tests/JavaJavah"
  2923. ${build_generator_args}
  2924. --build-project helloJavah
  2925. --build-two-config
  2926. --build-run-dir "${CMake_BINARY_DIR}/Tests/JavaJavah/"
  2927. --build-options ${build_options}
  2928. --test-command ${JAVA_RUNTIME} -Djava.library.path=${JAVAH_LIBRARY_PATH} -classpath hello3.jar HelloWorld2)
  2929. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJavah")
  2930. endif()
  2931. endif()
  2932. endif()
  2933. endif()
  2934. # add some cross compiler tests, for now only with makefile based generators
  2935. if(CMAKE_GENERATOR MATCHES "Makefiles" OR CMAKE_GENERATOR MATCHES "KDevelop")
  2936. # if sdcc is found, build the SimpleCOnly project with sdcc
  2937. find_program(SDCC_EXECUTABLE sdcc)
  2938. mark_as_advanced(SDCC_EXECUTABLE)
  2939. if(SDCC_EXECUTABLE)
  2940. add_test(SimpleCOnly_sdcc ${CMAKE_CTEST_COMMAND}
  2941. --build-and-test
  2942. "${CMake_SOURCE_DIR}/Tests/SimpleCOnly"
  2943. "${CMake_BINARY_DIR}/Tests/SimpleCOnly_sdcc"
  2944. ${build_generator_args}
  2945. --build-project SimpleC
  2946. --build-options ${build_options}
  2947. "-DCMAKE_SYSTEM_NAME=Generic"
  2948. "-DCMAKE_C_COMPILER=${SDCC_EXECUTABLE}")
  2949. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SimpleCOnly_sdcc")
  2950. endif()
  2951. # If a Linux -> MinGW cross compiler is found then try it
  2952. find_program(MINGW_CC_LINUX2WIN_EXECUTABLE i586-mingw32msvc-gcc)
  2953. find_program(MINGW_CXX_LINUX2WIN_EXECUTABLE i586-mingw32msvc-g++)
  2954. find_program(MINGW_RC_LINUX2WIN_EXECUTABLE i586-mingw32msvc-windres)
  2955. mark_as_advanced(MINGW_CC_LINUX2WIN_EXECUTABLE MINGW_CXX_LINUX2WIN_EXECUTABLE MINGW_RC_LINUX2WIN_EXECUTABLE)
  2956. if(MINGW_CC_LINUX2WIN_EXECUTABLE AND MINGW_CXX_LINUX2WIN_EXECUTABLE AND MINGW_RC_LINUX2WIN_EXECUTABLE)
  2957. add_test(Simple_Mingw_Linux2Win ${CMAKE_CTEST_COMMAND}
  2958. --build-and-test
  2959. "${CMake_SOURCE_DIR}/Tests/Simple"
  2960. "${CMake_BINARY_DIR}/Tests/Simple_Mingw_Linux2Win"
  2961. ${build_generator_args}
  2962. --build-project Simple
  2963. --build-options ${build_options}
  2964. "-DCMAKE_SYSTEM_NAME=Windows"
  2965. "-DCMAKE_C_COMPILER=${MINGW_CC_LINUX2WIN_EXECUTABLE}"
  2966. "-DCMAKE_CXX_COMPILER=${MINGW_CXX_LINUX2WIN_EXECUTABLE}"
  2967. "-DCMAKE_RC_COMPILER=${MINGW_RC_LINUX2WIN_EXECUTABLE}"
  2968. )
  2969. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Simple_Mingw_Linux2Win")
  2970. endif()
  2971. endif()
  2972. if(CMAKE_TEST_PROJECT_CSE_DIR)
  2973. set(script "${CMAKE_TEST_PROJECT_CSE_DIR}/BuildProjectCSE.cmake")
  2974. if(NOT EXISTS "${script}")
  2975. set(script "${CMAKE_TEST_PROJECT_CSE_DIR}/cse_build.cmake")
  2976. endif()
  2977. if(NOT EXISTS "${script}")
  2978. message("warning: CMAKE_TEST_PROJECT_CSE_DIR set, but no build script found...")
  2979. endif()
  2980. add_test(BuildCSE ${CMAKE_CTEST_COMMAND} -V -S "${script}")
  2981. set_tests_properties(BuildCSE PROPERTIES TIMEOUT 5400)
  2982. endif()
  2983. if(CMAKE_TEST_PLPLOT_DIR)
  2984. add_test(plplot ${CMAKE_CTEST_COMMAND} -V -S ${CMAKE_TEST_PLPLOT_DIR}/../../EasyDashboardScripts/plplot.cmake )
  2985. set_tests_properties ( plplot PROPERTIES TIMEOUT 5400)
  2986. endif()
  2987. if(CMAKE_TEST_CHICKEN_DIR)
  2988. add_test(Chicken ${CMAKE_CTEST_COMMAND} -V -S ${CMAKE_TEST_CHICKEN_DIR}/../../EasyDashboardScripts/Chicken.cmake )
  2989. set_tests_properties ( Chicken PROPERTIES TIMEOUT 5400)
  2990. endif()
  2991. if(CMAKE_TEST_KDELIBS_ALPHA_1_DIR)
  2992. add_test(KDELibsAlpha1 ${CMAKE_CTEST_COMMAND} -V -S ${CMAKE_TEST_KDELIBS_ALPHA_1_DIR}/../../EasyDashboardScripts/kdelibs.cmake )
  2993. set_tests_properties ( KDELibsAlpha1 PROPERTIES TIMEOUT 5400)
  2994. endif()
  2995. # If this is not an in-source build, provide a target to wipe out
  2996. # all the test build directories.
  2997. if(NOT EXISTS "${CMake_BINARY_DIR}/CMakeLists.txt")
  2998. configure_file(${CMake_SOURCE_DIR}/Tests/test_clean.cmake.in
  2999. ${CMake_BINARY_DIR}/Tests/test_clean.cmake @ONLY)
  3000. add_custom_target(test_clean
  3001. COMMAND ${CMAKE_COMMAND} -P ${CMake_BINARY_DIR}/Tests/test_clean.cmake
  3002. COMMENT "Removing test build directories."
  3003. )
  3004. endif()
  3005. add_test(NAME CMakeWizardTest COMMAND cmake -i)
  3006. set_property(TEST CMakeWizardTest PROPERTY PASS_REGULAR_EXPRESSION
  3007. "The \"cmake -i\" wizard mode is no longer supported.")
  3008. # If the cache variable CMAKE_CONTRACT_PROJECTS is set
  3009. # then the dashboard will run a contract with CMake test of that
  3010. # name. For example CMAKE_CONTRACT_PROJECTS = vtk542 would run
  3011. # the vtk542 contract test.
  3012. # For each Contract test, the project should provide a directory
  3013. # with at least one CMakeLists.txt file that uses ExternalProject
  3014. # to download and configure the project. The directory should also
  3015. # contain a RunTest.cmake file that has a single set of the format:
  3016. # set(project_RUN_TEST testToRun)
  3017. # The testToRun should be a test executable that can be run to
  3018. # smoke test the build.
  3019. foreach(project ${CMAKE_CONTRACT_PROJECTS})
  3020. include(Contracts/${project}/RunTest.cmake)
  3021. ADD_TEST_MACRO(Contracts.${project}
  3022. ${${project}_RUN_TEST})
  3023. # Contract test timeout in seconds.
  3024. # Default to 6 hours.
  3025. if(DEFINED ${project}_TEST_TIMEOUT)
  3026. set(timeout ${${project}_TEST_TIMEOUT})
  3027. elseif(CMAKE_CONTRACT_TEST_TIMEOUT_DEFAULT)
  3028. set(timeout ${CMAKE_CONTRACT_TEST_TIMEOUT_DEFAULT})
  3029. else()
  3030. set(timeout 21600)
  3031. endif()
  3032. set_tests_properties(Contracts.${project} PROPERTIES TIMEOUT ${timeout})
  3033. endforeach()
  3034. if(TEST_CompileCommandOutput)
  3035. set(CompileCommandOutput_BUILD_OPTIONS
  3036. -DMAKE_SUPPORTS_SPACES=${MAKE_SUPPORTS_SPACES})
  3037. ADD_TEST_MACRO(CompileCommandOutput
  3038. "${CMake_BINARY_DIR}/Tests/CMakeLib/runcompilecommands")
  3039. endif()
  3040. add_test(IncludeDirectories ${CMAKE_CTEST_COMMAND}
  3041. --build-and-test
  3042. "${CMake_SOURCE_DIR}/Tests/IncludeDirectories"
  3043. "${CMake_BINARY_DIR}/Tests/IncludeDirectories"
  3044. --build-two-config
  3045. ${build_generator_args}
  3046. --build-project IncludeDirectories
  3047. --build-options ${build_options}
  3048. --test-command IncludeDirectories)
  3049. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/IncludeDirectories")
  3050. add_test(InterfaceLinkLibraries ${CMAKE_CTEST_COMMAND}
  3051. --build-and-test
  3052. "${CMake_SOURCE_DIR}/Tests/InterfaceLinkLibraries"
  3053. "${CMake_BINARY_DIR}/Tests/InterfaceLinkLibraries"
  3054. --build-two-config
  3055. ${build_generator_args}
  3056. --build-project InterfaceLinkLibraries
  3057. --build-options ${build_options}
  3058. --test-command InterfaceLinkLibraries)
  3059. list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/InterfaceLinkLibraries")
  3060. if(CMAKE_USE_KWSTYLE AND KWSTYLE_EXECUTABLE)
  3061. # The "make StyleCheck" command line as a test. If the test fails, look
  3062. # for lines like "Error #0 (624) Line length exceed 88 (max=79)" in the
  3063. # output to find where the style errors are...
  3064. add_test(KWStyle ${KWSTYLE_EXECUTABLE}
  3065. -xml ${CMake_BINARY_DIR}/CMake.kws.xml
  3066. -o ${CMake_SOURCE_DIR}/Utilities/KWStyle/CMakeOverwrite.txt
  3067. -v
  3068. -D ${CMake_BINARY_DIR}/CMakeKWSFiles.txt
  3069. )
  3070. set_tests_properties(KWStyle PROPERTIES
  3071. WORKING_DIRECTORY ${CMake_BINARY_DIR}/Utilities/KWStyle)
  3072. endif()
  3073. if(NOT CMake_TEST_EXTERNAL_CMAKE)
  3074. add_subdirectory(CMakeTests)
  3075. endif()
  3076. endif()