CMakeLists.txt 143 KB

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