CMakeLists.txt 129 KB

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