CMakeLists.txt 106 KB

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