CMakeLists.txt 113 KB

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